Class: Kibou::Package

Inherits:
Object
  • Object
show all
Includes:
Utility::Helpers
Defined in:
lib/kibou/package.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utility::Helpers

#brew, #brew_installed?, #capture, #info, #outdated, #package_included?, #package_install, #package_installed?, #package_outdated?, #package_upgrade, #run, #search, #update!

Constructor Details

#initialize(name, options = {}) ⇒ Package

Returns a new instance of Package.



8
9
10
11
12
13
14
# File 'lib/kibou/package.rb', line 8

def initialize(name, options = {})
  @name         = name.to_s
  @options      = options
  @dependencies = (options[:require] || []).map {|dep| Kibou::Dependency.new(self, dep) }
  @completed    = false
  @outdated     = false
end

Instance Attribute Details

#dependenciesObject (readonly)

Returns the value of attribute dependencies.



6
7
8
# File 'lib/kibou/package.rb', line 6

def dependencies
  @dependencies
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/kibou/package.rb', line 6

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



6
7
8
# File 'lib/kibou/package.rb', line 6

def options
  @options
end

Instance Method Details

#completed?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/kibou/package.rb', line 24

def completed?
  !!@completed
end

#performObject



16
17
18
19
20
21
22
# File 'lib/kibou/package.rb', line 16

def perform
  return invoke_proc        if options[:proc].present?
  return install            if options[:via].present?
  return not_found_message  unless package_included?(name)
  return install            unless package_installed?(name)
  outdated? ? upgrade : up_to_date_message
end