Class: Remocon::Command::Create

Inherits:
Object
  • Object
show all
Includes:
InterpreterHelper
Defined in:
lib/remocon/command/create_command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from InterpreterHelper

#condition_array, #condition_names, #parameter_hash, #read_conditions, #read_parameters

Constructor Details

#initialize(opts) ⇒ Create

Returns a new instance of Create.



10
11
12
13
# File 'lib/remocon/command/create_command.rb', line 10

def initialize(opts)
  @config = Remocon::Config.new(opts)
  @cmd_opts = { validate_only: false }
end

Instance Attribute Details

#cmd_optsObject (readonly)

Returns the value of attribute cmd_opts.



8
9
10
# File 'lib/remocon/command/create_command.rb', line 8

def cmd_opts
  @cmd_opts
end

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/remocon/command/create_command.rb', line 8

def config
  @config
end

Instance Method Details

#require_conditions_file_pathObject



19
20
21
# File 'lib/remocon/command/create_command.rb', line 19

def require_conditions_file_path
  config.conditions_file_path
end

#require_parameters_file_pathObject



15
16
17
# File 'lib/remocon/command/create_command.rb', line 15

def require_parameters_file_path
  config.parameters_file_path
end

#runObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/remocon/command/create_command.rb', line 23

def run
  validate_options

  artifact = {
    conditions: condition_array,
    parameters: parameter_hash
  }.skip_nil_values.stringify_values

  File.open(config.config_json_file_path, "w+") do |f|
    # remote config allows only string values ;(
    f.write(JSON.pretty_generate(artifact))
    f.flush
  end

  artifact
end