Class: Ddenv::Goals::GemInstalled

Inherits:
Ddenv::Goal show all
Defined in:
lib/ddenv/goals/gem_installed.rb

Instance Method Summary collapse

Methods inherited from Ddenv::Goal

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

Constructor Details

#initialize(gem_name) ⇒ GemInstalled

Returns a new instance of GemInstalled.



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

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

Instance Method Details

#achieveObject



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

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

#achieved?Boolean

Returns:

  • (Boolean)


15
16
17
18
19
# File 'lib/ddenv/goals/gem_installed.rb', line 15

def achieved?
  cmd = TTY::Command.new(printer: :null)
  stdout, _stderr = cmd.run("shadowenv", "exec", "--", "gem", "list", "-i", "^#{@gem_name}$")
  stdout.chomp == "true"
end

#messageObject



11
12
13
# File 'lib/ddenv/goals/gem_installed.rb', line 11

def message
  "Installing Ruby gem #{@gem_name}"
end

#propsObject



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

def props
  [@gem_name]
end