Sha256: 14a693352f80b8b9e94560eb6d125d027219fe4172af33d12deb8f53d28d82f4

Contents?: true

Size: 710 Bytes

Versions: 1

Compression:

Stored size: 710 Bytes

Contents

# frozen_string_literal: true

require 'aranha/parsers/source_address/http_get'
require 'eac_ruby_utils/core_ext'

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

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

        def content
          ::File.read(source)
        end

        # @return [Addressable::URI]
        def uri
          source_as_uri? ? source_as_uri : "#{SCHEME}#{source}".to_uri
        end

        # @return [Boolean]
        def valid?
          source.to_s.start_with?("#{SCHEME}/", '/')
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aranha-parsers-0.24.0 lib/aranha/parsers/source_address/file.rb