Class: Commands::JsonStepCommand
- Inherits:
-
StepCommand
- Object
- Command
- StepCommand
- Commands::JsonStepCommand
- Defined in:
- lib/commands.rb
Instance Attribute Summary collapse
-
#variables ⇒ Object
Returns the value of attribute variables.
Attributes inherited from StepCommand
#apps_path, #args, #beta_path, #enable_debugging_path, #hive_cmd, #hive_path, #pig_cmd, #pig_path, #script_runner_path, #step_action, #step_name
Attributes inherited from Command
#arg, #commands, #description, #logger, #name
Instance Method Summary collapse
-
#initialize(*args) ⇒ JsonStepCommand
constructor
A new instance of JsonStepCommand.
- #steps ⇒ Object
Methods inherited from StepCommand
#default_enable_debugging_path, #default_hive_cmd, #default_hive_path, #default_pig_cmd, #default_pig_path, #default_resize_jobflow_cmd, #default_script_runner_path, #ensure_install_cmd, #extra_args, #reorder_steps, #script_args, #validate
Methods inherited from Command
#enact, #get_field, #has_value, #have, #option, #require, #require_single_jobflow, #resolve, #validate
Constructor Details
#initialize(*args) ⇒ JsonStepCommand
Returns a new instance of JsonStepCommand.
1284 1285 1286 1287 |
# File 'lib/commands.rb', line 1284 def initialize(*args) super(*args) @variables = [] end |
Instance Attribute Details
#variables ⇒ Object
Returns the value of attribute variables.
1282 1283 1284 |
# File 'lib/commands.rb', line 1282 def variables @variables end |
Instance Method Details
#steps ⇒ Object
1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 |
# File 'lib/commands.rb', line 1289 def steps content = steps = nil filename = get_field(:arg) begin content = File.read(filename) rescue Exception => e raise RuntimeError, "Couldn't read json file #{filename}" end for var in get_field(:variables, []) do content.gsub!(var[:key], var[:value]) end begin steps = JSON.parse(content) rescue Exception => e raise RuntimeError, "Error parsing json from file #{filename}" end if steps.is_a?(Array) then return steps else return [ steps ] end end |