Class: Ddenv::Goals::NodeShadowenvCreated

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

Constant Summary collapse

PATH =
".shadowenv.d/20_node.lisp"

Instance Method Summary collapse

Methods inherited from Ddenv::Goal

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

Constructor Details

#initialize(node_version, node_path) ⇒ NodeShadowenvCreated

Returns a new instance of NodeShadowenvCreated.



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

def initialize(node_version, node_path)
  super()

  @node_version = node_version
  @node_path = node_path
end

Instance Method Details

#achieveObject



23
24
25
26
27
28
29
# File 'lib/ddenv/goals/node_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/node_shadowenv_created.rb', line 19

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

#messageObject



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

def message
  "Adding Node to shadowenv"
end

#pre_goalsObject



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

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

#propsObject



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

def props
  [@node_version, @node_path]
end