Class: Aranha::DefaultProcessor

Inherits:
Object
  • Object
show all
Defined in:
lib/aranha/default_processor.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.sanitize_uri(uri) ⇒ Object



9
10
11
12
13
14
# File 'lib/aranha/default_processor.rb', line 9

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

#dataObject



31
32
33
# File 'lib/aranha/default_processor.rb', line 31

def data
  @data ||= parser.data
end

#parserObject



35
36
37
# File 'lib/aranha/default_processor.rb', line 35

def parser
  @parser ||= parser_class.new(target_uri)
end

#parser_classObject



39
40
41
42
43
44
# File 'lib/aranha/default_processor.rb', line 39

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

#processObject



23
24
25
# File 'lib/aranha/default_processor.rb', line 23

def process
  raise 'Implement method process'
end

#target_uriObject



27
28
29
# File 'lib/aranha/default_processor.rb', line 27

def target_uri
  source_uri
end