Module: Scruber::Core::Extensions::CsvOutput::CoreMethods
- Defined in:
- lib/scruber/core/extensions/csv_output.rb
Class Method Summary collapse
-
.included(base) ⇒ void
Registering method missing callbacks on including to crawling class.
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ void
This method returns an undefined value.
Registering method missing callbacks on including to crawling class
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/scruber/core/extensions/csv_output.rb', line 40 def self.included(base) Scruber::Core::Crawler.register_method_missing /\Acsv_(\w+)_file\Z/ do |meth, scan_results, args| file_id = scan_results.first.first.to_sym path, = args = {} if .nil? csv_file path, .merge({file_id: file_id}) Scruber::Core::Crawler.class_eval do define_method "csv_#{file_id}_out".to_sym do |fields| Scruber::Core::Extensions::CsvOutput.csv_out(file_id, fields) end end end end |
Instance Method Details
#csv_file(path, options = {}) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/scruber/core/extensions/csv_output.rb', line 20 def csv_file(path, ={}) file_id = .fetch(:file_id) { :default }.to_sym .delete(:file_id) Scruber::Core::Extensions::CsvOutput.register_csv file_id, path, on_complete -1 do Scruber::Core::Extensions::CsvOutput.close_all end end |