Class: Ddenv::Goals::RubyShadowenvCreated

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

Constant Summary collapse

PATH =
".shadowenv.d/10_ruby.lisp"

Instance Method Summary collapse

Methods inherited from Ddenv::Goal

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

Constructor Details

#initialize(ruby_version, ruby_path) ⇒ RubyShadowenvCreated

Returns a new instance of RubyShadowenvCreated.



8
9
10
11
12
13
# File 'lib/ddenv/goals/ruby_shadowenv_created.rb', line 8

def initialize(ruby_version, ruby_path)
  super()

  @ruby_version = ruby_version
  @ruby_path = ruby_path
end

Instance Method Details

#achieveObject



23
24
25
26
27
28
29
# File 'lib/ddenv/goals/ruby_shadowenv_created.rb', line 23

def achieve
  File.write(PATH, shadowenv_contents)

  # TODO: use :pretty when passing --verbose
  cmd = TTY::Command.new(printer: :null)
  cmd.run("shadowenv", "trust")
end

#achieved?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/ddenv/goals/ruby_shadowenv_created.rb', line 19

def achieved?
  File.file?(PATH) && File.read(PATH) == shadowenv_contents
end

#messageObject



15
16
17
# File 'lib/ddenv/goals/ruby_shadowenv_created.rb', line 15

def message
  "Adding Ruby to shadowenv"
end

#pre_goalsObject



31
32
33
34
35
# File 'lib/ddenv/goals/ruby_shadowenv_created.rb', line 31

def pre_goals
  [
    Ddenv::Goals::ShadowenvDirCreated.new
  ]
end

#propsObject



37
38
39
# File 'lib/ddenv/goals/ruby_shadowenv_created.rb', line 37

def props
  [@ruby_version, @ruby_path]
end