Module: Equilibrium::Mixins::InputOutput
- Included in:
- Commands::ActualCommand, Commands::AnalyzeCommand, Commands::CatalogCommand, Commands::ExpectedCommand, Commands::UncatalogCommand
- Defined in:
- lib/equilibrium/mixins/input_output.rb
Overview
Module for input/output operations - reading files, parsing JSON, formatting output
Instance Method Summary collapse
- #format_output(data, format, summary_type = nil) ⇒ Object
- #read_input_data(file_path = nil, usage_message = "No input provided") ⇒ Object
Instance Method Details
#format_output(data, format, summary_type = nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/equilibrium/mixins/input_output.rb', line 19 def format_output(data, format, summary_type = nil) case format when "json" puts JSON.pretty_generate(data) when "summary" if summary_type formatter = SummaryFormatter.new case summary_type when "expected", "actual" formatter.(data, summary_type) when "analysis" formatter.print_analysis_summary(data) end else puts JSON.pretty_generate(data) end else puts JSON.pretty_generate(data) end end |
#read_input_data(file_path = nil, usage_message = "No input provided") ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/equilibrium/mixins/input_output.rb', line 10 def read_input_data(file_path = nil, = "No input provided") input = file_path ? File.read(file_path) : $stdin.read input = input.strip raise if input.empty? input end |