Class: FacterStatistax::Common::OutputWriter
- Inherits:
-
Object
- Object
- FacterStatistax::Common::OutputWriter
- Includes:
- Singleton
- Defined in:
- lib/common/output_writer.rb
Instance Attribute Summary collapse
-
#facts ⇒ Object
readonly
Returns the value of attribute facts.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#test_run ⇒ Object
readonly
Returns the value of attribute test_run.
Instance Method Summary collapse
-
#initialize ⇒ OutputWriter
constructor
A new instance of OutputWriter.
- #write ⇒ Object
- #write_run(fact_name, time) ⇒ Object
- #write_test_suite(facter_version, test_run_name) ⇒ Object
Constructor Details
#initialize ⇒ OutputWriter
Returns a new instance of OutputWriter.
11 12 13 14 15 |
# File 'lib/common/output_writer.rb', line 11 def initialize @output = [] @test_run = {} @facts = [] end |
Instance Attribute Details
#facts ⇒ Object (readonly)
Returns the value of attribute facts.
10 11 12 |
# File 'lib/common/output_writer.rb', line 10 def facts @facts end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
10 11 12 |
# File 'lib/common/output_writer.rb', line 10 def output @output end |
#test_run ⇒ Object (readonly)
Returns the value of attribute test_run.
10 11 12 |
# File 'lib/common/output_writer.rb', line 10 def test_run @test_run end |
Instance Method Details
#write ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/common/output_writer.rb', line 17 def write test_run = @test_run.merge(facts: facts) output << test_run ::File.open(File.join(LOG_DIR, 'output.json'), 'w') do |file| file.write(output.to_json) end end |
#write_run(fact_name, time) ⇒ Object
29 30 31 32 33 |
# File 'lib/common/output_writer.rb', line 29 def write_run(fact_name, time) fact_name = 'all' if fact_name.empty? fact = { 'name' => fact_name, 'average' => time.real } facts << fact end |
#write_test_suite(facter_version, test_run_name) ⇒ Object
25 26 27 |
# File 'lib/common/output_writer.rb', line 25 def write_test_suite(facter_version, test_run_name) @test_run = @test_run.merge(test_run_name: test_run_name, facter_gem?: facter_version) end |