Class: Ddenv::Goals::HomebrewPackageInstalled

Inherits:
Ddenv::Goal
  • Object
show all
Defined in:
lib/ddenv/goals/homebrew_package_installed.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Ddenv::Goal

#==, #eql?, #hash, #post_goals, #pre_goals, #with_pre_and_post_goals

Constructor Details

#initialize(package_name) ⇒ HomebrewPackageInstalled

Returns a new instance of HomebrewPackageInstalled.



8
9
10
11
# File 'lib/ddenv/goals/homebrew_package_installed.rb', line 8

def initialize(package_name)
  super()
  @package_name = package_name
end

Instance Attribute Details

#package_nameObject (readonly)

Returns the value of attribute package_name.



6
7
8
# File 'lib/ddenv/goals/homebrew_package_installed.rb', line 6

def package_name
  @package_name
end

Instance Method Details

#achieveObject



21
22
23
24
25
# File 'lib/ddenv/goals/homebrew_package_installed.rb', line 21

def achieve
  # TODO: use :pretty when passing --verbose
  cmd = TTY::Command.new(printer: :null)
  cmd.run("brew", "install", @package_name)
end

#achieved?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/ddenv/goals/homebrew_package_installed.rb', line 17

def achieved?
  Homebrew.package_installed?(@package_name)
end

#messageObject



13
14
15
# File 'lib/ddenv/goals/homebrew_package_installed.rb', line 13

def message
  "Installing Homebrew package #{@package_name}"
end

#propsObject



27
28
29
# File 'lib/ddenv/goals/homebrew_package_installed.rb', line 27

def props
  [@package_name]
end