Sha256: ff3299236234549e0b0e2d51a7c81ebd0b4083cfbce78f0589acafe4c81efcff

Contents?: true

Size: 859 Bytes

Versions: 16

Compression:

Stored size: 859 Bytes

Contents

require 'rbconfig'
require 'uri'

module URI

  # Ruby does not have built-in support for filesystem URIs, and definitely does not have built-in support for
  # using open-uri with filesystem URIs
  class File < Generic

    COMPONENT = [
          :scheme,
          :path,
          :fragment,
          :host
        ].freeze

    def initialize(*arg)
      # arg[2] is the 'host'; this logic to set it to "" causes file schemes with UNC to break
      # so don't do it on windows platforms
      is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
      arg[2] = "" unless is_windows
      super(*arg)
    end

    def self.build(args)
      tmp = Util::make_components_hash(self, args)
      return super(tmp)
    end

    def open(*rest, &block)
      ::File.open(self.path, *rest, &block)
    end

    @@schemes['FILE'] = File
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
json-schema-2.4.1 lib/json-schema/uri/file.rb
json-schema-2.4.0 lib/json-schema/uri/file.rb
json-schema-2.3.0 lib/json-schema/uri/file.rb
json-schema-2.2.5 lib/json-schema/uri/file.rb
json-schema-pvdgm-2.3.1 lib/json-schema/uri/file.rb
json-schema-2.2.4 lib/json-schema/uri/file.rb
json-schema-2.2.3 lib/json-schema/uri/file.rb
json-schema-2.2.2 lib/json-schema/uri/file.rb
json-schema-2.2.1 lib/json-schema/uri/file.rb
json-schema-2.2.0 lib/json-schema/uri/file.rb
json-schema-2.1.9 lib/json-schema/uri/file.rb
json-schema-2.1.8 lib/json-schema/uri/file.rb
json-schema-2.1.7 lib/json-schema/uri/file.rb
json-schema-2.1.6 lib/json-schema/uri/file.rb
json-schema-2.1.5 lib/json-schema/uri/file.rb
json-schema-2.1.4 lib/json-schema/uri/file.rb