Sha256: e740fc25d6e9ad23bdb1ac5f4a3aef89e1e5441a050742f52c234af0709045b0

Contents?: true

Size: 626 Bytes

Versions: 2

Compression:

Stored size: 626 Bytes

Contents

# frozen_string_literal: true

require 'aranha/parsers/source_address/http_get'

module Aranha
  module Parsers
    class SourceAddress
      class File < ::Aranha::Parsers::SourceAddress::HttpGet
        SCHEME = 'file://'

        class << self
          def valid_source?(source)
            source.to_s.start_with?("#{SCHEME}/", '/')
          end
        end

        def initialize(source)
          super(source.to_s.gsub(/\A#{Regexp.quote(SCHEME)}/, ''))
        end

        def url
          "#{SCHEME}#{source}"
        end

        def content
          ::File.read(source)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aranha-parsers-0.23.1 lib/aranha/parsers/source_address/file.rb
aranha-parsers-0.23.0 lib/aranha/parsers/source_address/file.rb