Class: Puppet::Util::PTomulik::Package::Ports::PkgRecord

Inherits:
Record
  • Object
show all
Defined in:
lib/puppet/util/ptomulik/package/ports/pkg_record.rb

Overview

Represents single data record returned by Puppet::Util::PTomulik::Package::Ports::PkgSearch#search_packages.

This is a kind of hash to hold results obtained from ‘portversion` command.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.default_fieldsObject



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/puppet/util/ptomulik/package/ports/pkg_record.rb', line 24

def self.default_fields
  [
    :pkgname,
    :portname,
    :portorigin,
    :pkgversion,
    :portstatus,
    :portinfo,
    :options,
    :options_file,
    :options_files
  ]
end

.deps_for_amendObject

If we want #amend! to add extra fields to PkgRecord we must first ensure that we request certain fields from Puppet::Util::PTomulik::Package::Ports::PkgSearch#search_packages. For example, to determine ‘:pkgversion` field, one needs to have the `:pkgname` field in the `portversion`s search result.

The following hash describes these dependencies. See also Record.deps_for_amend.

See [portversion(1)](www.freebsd.org/cgi/man.cgi?query=portversion&manpath=ports&sektion=1) for more information about ‘portversion`.



48
49
50
51
52
53
54
55
# File 'lib/puppet/util/ptomulik/package/ports/pkg_record.rb', line 48

def self.deps_for_amend
  {
    :options        => [:portname, :portorigin],
    :options_file   => [:portname, :portorigin],
    :options_files  => [:portname, :portorigin],
    :pkgversion     => [:pkgname],
  }
end

.std_fieldsObject

These fields may be obtained directly from Puppet::Util::PTomulik::Package::Ports::PkgSearch#search_packages without doing #amend!. See also Record.std_fields.



13
14
15
16
17
18
19
20
# File 'lib/puppet/util/ptomulik/package/ports/pkg_record.rb', line 13

def self.std_fields
  [
    :pkgname,
    :portorigin,
    :portstatus,
    :portinfo
  ]
end

Instance Method Details

#amend!(fields) ⇒ Object

Add extra fields to an already existing PkgRecord.

Most of the extra fields that can be added do not introduce any new information in fact - they’re just computed from already existing fields. The exception is the ‘:options` field. Options are loaded from existing port options files (`/var/db/ports/*/optionsPuppet::Util::PTomulik::Package::Ports::PkgRecord.,,.local).

Parameters:

  • fields (Array)

    list of fields to be included in output

Returns:

  • self



67
68
69
70
71
72
# File 'lib/puppet/util/ptomulik/package/ports/pkg_record.rb', line 67

def amend!(fields)
  if self[:pkgname]
    self[:portname], self[:pkgversion] = self.class.split_pkgname(self[:pkgname])
  end
  super
end