Class: DMG::Pkg

Inherits:
Object
  • Object
show all
Includes:
OutputHelpers
Defined in:
lib/dmg/pkg.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from OutputHelpers

#alert, #debug, #info

Constructor Details

#initialize(args) ⇒ Pkg

Returns a new instance of Pkg.



21
22
23
24
25
26
27
# File 'lib/dmg/pkg.rb', line 21

def initialize(args)
  @name = args['name']
  @package = args['package']
  @url = args['url']
  @volume_dir = args['volume_dir'] || @package
  @mpkg = args['mpkg']
end

Instance Attribute Details

#mpkgObject (readonly)

Returns the value of attribute mpkg.



19
20
21
# File 'lib/dmg/pkg.rb', line 19

def mpkg
  @mpkg
end

#nameObject (readonly)

Returns the value of attribute name.



19
20
21
# File 'lib/dmg/pkg.rb', line 19

def name
  @name
end

#packageObject (readonly)

Returns the value of attribute package.



19
20
21
# File 'lib/dmg/pkg.rb', line 19

def package
  @package
end

#urlObject (readonly)

Returns the value of attribute url.



19
20
21
# File 'lib/dmg/pkg.rb', line 19

def url
  @url
end

#volume_dirObject (readonly)

Returns the value of attribute volume_dir.



19
20
21
# File 'lib/dmg/pkg.rb', line 19

def volume_dir
  @volume_dir
end

Class Method Details

.find!(pkg_name) ⇒ Object

Raises:



12
13
14
15
16
17
# File 'lib/dmg/pkg.rb', line 12

def self.find!(pkg_name)
  pkg = all.select { |pkg| pkg.name == pkg_name }.first
  raise PackageNotFound, "Can't find a package called '#{pkg_name}'" unless pkg

  pkg
end

.install(pkg_names) ⇒ Object



7
8
9
10
# File 'lib/dmg/pkg.rb', line 7

def self.install(pkg_names)
  pkgs = pkg_names.map { |pkg_name| find!(pkg_name) }
  pkgs.each(&:install!)
end

.listObject



3
4
5
# File 'lib/dmg/pkg.rb', line 3

def self.list
  all.map(&:name).sort
end