Skip to content

Commit

Permalink
Revert some unnecessary changes
Browse files Browse the repository at this point in the history
I'll submit a separate PR to add pry (and pry-byebug) as dependencies in
the Gemfile.

Reverted some changes I made to attributes/ref.rb that would conflict
with #186.
  • Loading branch information
pd committed Nov 30, 2014
1 parent 5c9d9a6 commit f81a896
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ gem "json", :platforms => :mri_18
group :development do
gem "rake"
gem "minitest", '~> 5.0'
gem "pry"
end
12 changes: 6 additions & 6 deletions lib/json-schema/attributes/ref.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module JSON
class Schema
class RefAttribute < Attribute
def self.validate(current_schema, data, fragments, processor, validator, options = {})
uri, schema = get_referenced_uri_and_schema(current_schema.schema, current_schema, validator)
uri,schema = get_referenced_uri_and_schema(current_schema.schema, current_schema, validator)

if schema
schema.validate(data, fragments, processor, options)
Expand All @@ -18,22 +18,22 @@ def self.validate(current_schema, data, fragments, processor, validator, options
end
end

def self.get_referenced_uri_and_schema(contents, current_schema, validator)
uri, schema = nil,nil
def self.get_referenced_uri_and_schema(s, current_schema, validator)
uri,schema = nil,nil

temp_uri = Addressable::URI.parse(contents['$ref'])
temp_uri = Addressable::URI.parse(s['$ref'])
if temp_uri.relative?
temp_uri = current_schema.uri.clone
# Check for absolute path
path = contents['$ref'].split("#")[0]
path = s['$ref'].split("#")[0]
if path.nil? || path == ''
temp_uri.path = current_schema.uri.path
elsif path[0,1] == "/"
temp_uri.path = Pathname.new(path).cleanpath.to_s
else
temp_uri = current_schema.uri.join(path)
end
temp_uri.fragment = contents['$ref'].split("#")[1]
temp_uri.fragment = s['$ref'].split("#")[1]
end
temp_uri.fragment = "" if temp_uri.fragment.nil?

Expand Down

0 comments on commit f81a896

Please sign in to comment.