lib/scout/workflow/task/inputs.rb in scout-gear-8.1.0 vs lib/scout/workflow/task/inputs.rb in scout-gear-9.0.0

- old
+ new

@@ -18,11 +18,11 @@ value end end end - def assign_inputs(provided_inputs = {}) + def assign_inputs(provided_inputs = {}, id = nil) if self.inputs.nil? || (self.inputs.empty? && Array === provided_inputs) case provided_inputs when Array return [provided_inputs, provided_inputs] else @@ -41,27 +41,30 @@ provided = Hash === provided_inputs ? provided_inputs[name] : provided_inputs[i] provided = Task.format_input(provided, type, options || {}) if ! provided.nil? && provided != value non_default_inputs << name.to_sym input_array << provided + elsif options && options[:jobname] + input_array << id else input_array << value end end NamedArray.setup(input_array, input_names) [input_array, non_default_inputs] end - def process_inputs(provided_inputs = {}) - input_array, non_default_inputs = assign_inputs provided_inputs + def process_inputs(provided_inputs = {}, id = nil) + input_array, non_default_inputs = assign_inputs provided_inputs, id digest_str = Misc.digest_str(input_array) [input_array, non_default_inputs, digest_str] end def save_file_input(orig_file, directory) + orig_file = orig_file.path if Step === orig_file basename = File.basename(orig_file) digest = Misc.digest(orig_file) if basename.include? '.' basename.sub!(/(.*)\.(.*)/, '\1-' + digest + '.\2') else @@ -79,25 +82,25 @@ name, type, desc, value, options = p next unless provided_inputs.include?(name) value = provided_inputs[name] input_file = File.join(directory, name.to_s) - if type == :file + if Path.is_filename?(value) relative_file = save_file_input(value, directory) + Open.write(input_file + ".as_file", relative_file) + elsif type == :file + relative_file = save_file_input(value, directory) Persist.save(relative_file, input_file, :file) elsif type == :file_array new_files = value.collect do |orig_file| save_file_input(orig_file, directory) end Persist.save(new_files, input_file, type) - elsif Path.is_filename?(value) - relative_file = save_file_input(value, directory) - Open.write(input_file + ".as_file", relative_file) elsif Open.is_stream?(value) - Persist.save(input_file, value, type) + Persist.save(value, input_file, type) elsif Open.has_stream?(value) - Persist.save(input_file, value.stream, type) + Persist.save(value.stream, input_file, type) else Persist.save(value, input_file, type) end end end @@ -110,9 +113,11 @@ if Open.exists?(filename) || filename = Dir.glob(File.join(filename + ".*")).first if filename.end_with?('.as_file') value = Open.read(filename).strip value.sub!(/^\./, File.dirname(filename)) if value.start_with?("./") inputs[name] = value + elsif (options && (options[:noload] || options[:stream] || options[:nofile])) + inputs[name] = filename else inputs[name] = Persist.load(filename, type) end end end