Sha256: bba2ca8f6dcfe1522bfa133c6e4ff5918445c799813f4f5ec1def3213658e689
Contents?: true
Size: 897 Bytes
Versions: 9
Compression:
Stored size: 897 Bytes
Contents
# frozen_string_literal: true require 'addressable' module Aranha class DefaultProcessor attr_reader :source_uri, :extra_data 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 def initialize(source_uri, extra_data) @source_uri = self.class.sanitize_uri(source_uri) @extra_data = extra_data end def process raise 'Implement method process' end protected def target_uri source_uri end def data @data ||= parser_class.new(target_uri).data 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
9 entries across 9 versions & 1 rubygems