Class: PuppetGenerator::Middleware::ReadInput
- Inherits:
-
Object
- Object
- PuppetGenerator::Middleware::ReadInput
- Defined in:
- lib/puppet_generator/middleware/read_input.rb
Instance Method Summary collapse
- #call(task) ⇒ Object
-
#initialize(app) ⇒ ReadInput
constructor
A new instance of ReadInput.
Constructor Details
#initialize(app) ⇒ ReadInput
Returns a new instance of ReadInput.
5 6 7 |
# File 'lib/puppet_generator/middleware/read_input.rb', line 5 def initialize(app) @app = app end |
Instance Method Details
#call(task) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/puppet_generator/middleware/read_input.rb', line 9 def call(task) PuppetGenerator.logger.debug(self.class.name){ "Read data from input \"#{task.[:source]}\"." } raise Exceptions::FilesystemError unless PuppetGenerator::Models::Importer.existing_source?(task.[:source].to_s) raise Exceptions::InvalidSource unless PuppetGenerator::Models::Importer.valid_source?(task.[:source].to_s) importer = PuppetGenerator::Models::Importer.find( reads_from: task.[:source].to_s, enabled: true ) raise PuppetGenerator::Exceptions::InvalidSource unless importer PuppetGenerator.logger.debug(self.class.name){ "Using importer \"#{importer.name}\" to read data." } task.body = importer.read( task.[:source] ) PuppetGenerator.logger.debug(self.class.name) { "Count input lines: #{task.body.size}" } @app.call(task) end |