Class: Aranha::DefaultProcessor
- Inherits:
-
Object
- Object
- Aranha::DefaultProcessor
- Defined in:
- lib/aranha/default_processor.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.sanitize_uri(uri) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/aranha/default_processor.rb', line 6 def sanitize_uri(uri) return uri if uri.is_a?(Hash) uri = uri.to_s.gsub(%r{\A/}, 'file:///') unless uri.is_a?(Addressable::URI) Addressable::URI.parse(uri) end |
Instance Method Details
#data ⇒ Object
28 29 30 |
# File 'lib/aranha/default_processor.rb', line 28 def data @data ||= parser.data end |
#parser ⇒ Object
32 33 34 |
# File 'lib/aranha/default_processor.rb', line 32 def parser @parser ||= parser_class.new(target_uri) end |
#parser_class ⇒ Object
36 37 38 39 40 41 |
# File 'lib/aranha/default_processor.rb', line 36 def parser_class r = self.class.name.gsub('::Processors::', '::Parsers::').constantize return r unless is_a?(r) raise "Parser can be not the process class: #{r}" end |
#process ⇒ Object
20 21 22 |
# File 'lib/aranha/default_processor.rb', line 20 def process raise 'Implement method process' end |
#target_uri ⇒ Object
24 25 26 |
# File 'lib/aranha/default_processor.rb', line 24 def target_uri source_uri end |