lib/henry/container.rb in henry-container-0.0.3 vs lib/henry/container.rb in henry-container-0.0.4

- old
+ new

@@ -44,14 +44,28 @@ 2 => 0 }, } } + # Returns the input file path based on the given options. + # + # @return [String] the input file path. + def input_file_path + "#{@opts[:"in-dir"]}#{@opts[:in]}" + end + + # Returns the output file path based on the given options. + # + # @return [String] the output file path. + def output_file_path + "#{@opts[:"out-dir"]}#{@opts[:out]}" + end + # Executes required validations before execution. def before_execution - unless File.exists?(@opts[:in]) - abort "#{"'#{@opts[:in]}' file does not exist.".red}\n #{'*'.red} If running isolated make sure to create it first.\n #{'*'.red} If running from Henry contact us at henry@despegar.it." + unless File.exists?(self.input_file_path) + abort "#{"'#{self.input_file_path}' file does not exist.".red}\n #{'*'.red} If running isolated make sure to create it first.\n #{'*'.red} If running from Henry contact us at henry@despegar.it." end unless File.exists?('henry-context.yml') abort "'henry-context.yml' file does not exist. You need it in order to execute a Henry compatible test.".red end @@ -60,11 +74,11 @@ # Loads and parses the @opts[:in] params. # # @return [{String => String}] the execution params. def params - @params ||= JSON.parse(File.read(@opts[:in])) + @params ||= JSON.parse(File.read(self.input_file_path)) end # Returns the default params. # @note Custom task_params will overwrite the defaults. # @@ -126,10 +140,10 @@ end end # Writes into @opts[:out] the execution results. def dump_results - File.open(@opts[:out], 'w') { |f| f.write(results.to_json) } + File.open(self.output_file_path, 'w') { |f| f.write(results.to_json) } end end end