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.
1240 1241 1242 1243 |
# File 'lib/commands.rb', line 1240 def initialize(*args) super(*args) @variables = [] end |
Instance Attribute Details
#variables ⇒ Object
Returns the value of attribute variables.
1238 1239 1240 |
# File 'lib/commands.rb', line 1238 def variables @variables end |
Instance Method Details
#steps ⇒ Object
1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 |
# File 'lib/commands.rb', line 1245 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 |