Module: Performa::ResultsHelper
- Defined in:
- lib/performa/results_helper.rb
Class Method Summary collapse
- .output_to_directory(results, directory:) ⇒ Object
- .output_to_stdout(results) ⇒ Object
- .process(results, config:) ⇒ Object
Class Method Details
.output_to_directory(results, directory:) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/performa/results_helper.rb', line 28 def output_to_directory(results, directory:) FileUtils.mkdir_p(directory) filenames = [] results.each_pair do |env_name, result| filename = File.join(directory, env_name + ".txt") filenames << filename File.open(filename, "w+") do |file| file.write(result) end end = +"Command outputs are now present in the following files:\n" << filenames.join("\n") puts puts .colorize(:green) puts end |
.output_to_stdout(results) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/performa/results_helper.rb', line 18 def output_to_stdout(results) results.each_pair do |env_name, result| puts puts "== Output for #{env_name}".colorize(:green) puts puts result end puts end |
.process(results, config:) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/performa/results_helper.rb', line 10 def process(results, config:) if config["output"].nil? || config["output"] == "STDOUT" output_to_stdout(results) else output_to_directory(results, directory: config["output"]) end end |