Sha256: 7236ec0c7cf725bf0a881e48022b05fea96d7a0b1b0fcf404134d976ba0be1e3
Contents?: true
Size: 947 Bytes
Versions: 6
Compression:
Stored size: 947 Bytes
Contents
# frozen_string_literal: true require 'addressable' require 'eac_ruby_utils/core_ext' module Aranha class DefaultProcessor class << self 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 end common_constructor :source_uri, :extra_data do self.source_uri = self.class.sanitize_uri(source_uri) end delegate :source_address, to: :parser def process raise 'Implement method process' end def target_uri source_uri end def data @data ||= parser.data end def parser @parser ||= parser_class.new(target_uri) end 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 end end
Version data entries
6 entries across 6 versions & 1 rubygems