Module: Chronicle::ETL::Loaders::Helpers::StdoutHelper
- Included in:
- CSVLoader, JSONLoader
- Defined in:
- lib/chronicle/etl/loaders/helpers/stdout_helper.rb
Instance Method Summary collapse
- #create_stdout_temp_file ⇒ Object
-
#output_to_stdout? ⇒ Boolean
TODO: let users use "stdout" as an option for the
output
setting Assume we're using stdout if no output is specified. - #write_to_stdout(output) ⇒ Object
- #write_to_stdout_from_temp_file(file) ⇒ Object
Instance Method Details
#create_stdout_temp_file ⇒ Object
18 19 20 21 22 |
# File 'lib/chronicle/etl/loaders/helpers/stdout_helper.rb', line 18 def create_stdout_temp_file file = Tempfile.new('chronicle-stdout') file.unlink file end |
#output_to_stdout? ⇒ Boolean
TODO: let users use "stdout" as an option for the output
setting
Assume we're using stdout if no output is specified
14 15 16 |
# File 'lib/chronicle/etl/loaders/helpers/stdout_helper.rb', line 14 def output_to_stdout? !@config.output end |
#write_to_stdout(output) ⇒ Object
29 30 31 32 33 34 35 |
# File 'lib/chronicle/etl/loaders/helpers/stdout_helper.rb', line 29 def write_to_stdout(output) # We .dup because rspec overwrites $stdout (in helper #capture) to # capture output. stdout = $stdout.dup stdout.write(output) stdout.flush end |
#write_to_stdout_from_temp_file(file) ⇒ Object
24 25 26 27 |
# File 'lib/chronicle/etl/loaders/helpers/stdout_helper.rb', line 24 def write_to_stdout_from_temp_file(file) file.rewind write_to_stdout(file.read) end |