Sha256: 0f7ef41cfe5f27a35f4a67eb5bf53ca0478c9e26c41662488a640ef33b63b24f

Contents?: true

Size: 1.12 KB

Versions: 27

Compression:

Stored size: 1.12 KB

Contents

=begin
* Description: Patches json-schema gem to work on windows
* Author: Josh Bradley
* Date: 2014-09-17
* License: Public Domain
=end

module JSON

    class Validator

        def load_ref_schema(parent_schema, ref)
            uri = URI.parse(ref)
            if uri.relative?
                uri = parent_schema.uri.clone

                # Check for absolute path
                path = ref.split("#")[0]

                # This is a self reference and thus the schema does not need to be re-loaded
                if path.nil? || path == ''
                    return
                end

                if path && path[0, 1] == '/'
                    uri.path = Pathname.new(path).cleanpath.to_s
                else
                    uri = parent_schema.uri.merge(path)
                end
                uri.fragment = ''
            end

            if Validator.schemas[uri.to_s].nil?
                schema = JSON::Schema.new(JSON::Validator.parse(open(uri.to_s.chomp('#')).read), uri, @options[:version])
                Validator.add_schema(schema)
                build_schemas(schema)
            end

        end

    end

end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
adiwg-mdtranslator-1.4.0 lib/adiwg/mdtranslator/readers/mdJson/validator.rb
adiwg-mdtranslator-1.4.0.beta14 lib/adiwg/mdtranslator/readers/mdJson/validator.rb
adiwg-mdtranslator-1.4.0.beta13 lib/adiwg/mdtranslator/readers/mdJson/validator.rb
adiwg-mdtranslator-1.4.0.beta12 lib/adiwg/mdtranslator/readers/mdJson/validator.rb
adiwg-mdtranslator-1.4.0.beta11 lib/adiwg/mdtranslator/readers/mdJson/validator.rb
adiwg-mdtranslator-1.4.0.beta10 lib/adiwg/mdtranslator/readers/mdJson/validator.rb
adiwg-mdtranslator-1.4.0.beta9 lib/adiwg/mdtranslator/readers/mdJson/validator.rb
adiwg-mdtranslator-1.4.0.beta8 lib/adiwg/mdtranslator/readers/mdJson/validator.rb
adiwg-mdtranslator-1.4.0.beta7 lib/adiwg/mdtranslator/readers/mdJson/validator.rb
adiwg-mdtranslator-1.4.0.beta6 lib/adiwg/mdtranslator/readers/mdJson/validator.rb
adiwg-mdtranslator-1.4.0.beta5 lib/adiwg/mdtranslator/readers/mdJson/validator.rb
adiwg-mdtranslator-1.4.0.beta4 lib/adiwg/mdtranslator/readers/mdJson/validator.rb
adiwg-mdtranslator-1.4.0.beta3 lib/adiwg/mdtranslator/readers/mdJson/validator.rb
adiwg-mdtranslator-1.4.0.beta2 lib/adiwg/mdtranslator/readers/mdJson/validator.rb
adiwg-mdtranslator-1.4.0.beta1 lib/adiwg/mdtranslator/readers/mdJson/validator.rb
adiwg-mdtranslator-1.3.0 lib/adiwg/mdtranslator/readers/mdJson/validator.rb
adiwg-mdtranslator-1.2.1 lib/adiwg/mdtranslator/readers/mdJson/validator.rb
adiwg-mdtranslator-1.2.0 lib/adiwg/mdtranslator/readers/mdJson/validator.rb
adiwg-mdtranslator-1.1.1 lib/adiwg/mdtranslator/readers/mdJson/validator.rb
adiwg-mdtranslator-1.1.0 lib/adiwg/mdtranslator/readers/mdJson/validator.rb