json_refs 0.1.7 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/json_refs/loader.rb +1 -1
- data/lib/json_refs/version.rb +1 -1
- data/lib/json_refs.rb +16 -9
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac8b41fb0b17e6fd994f10e4300d37be8e32c96a45f86a565d79a72315f858e3
|
4
|
+
data.tar.gz: cdc3180ec3c492f86ac4250e2a716953d0c70523ade7aa749411998761d16174
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f01c5505778ec33889fb382607eedd229b35d6d5ee5f209c79bc64ce0d6dca516f8deba10ecda62021d4def351dcc6acdf9a8d7097c571899b8b894cb229af5
|
7
|
+
data.tar.gz: f6fc1d89b79506dba84759e5d88e09b0909d6e4f593614c74cabdeb2095a22e7ca97361774b73aeed83e2ce8c9c50117c79e1c54b72dbf2b38b57473a576e7af
|
data/README.md
CHANGED
data/lib/json_refs/loader.rb
CHANGED
data/lib/json_refs/version.rb
CHANGED
data/lib/json_refs.rb
CHANGED
@@ -4,16 +4,23 @@ require 'json_refs/dereference_handler'
|
|
4
4
|
module JsonRefs
|
5
5
|
class << self
|
6
6
|
def call(doc, options = {})
|
7
|
-
Dereferencer.new(doc, options).call
|
7
|
+
Dereferencer.new(Dir.pwd, doc, options).call
|
8
8
|
end
|
9
9
|
|
10
10
|
alias_method :dereference, :call
|
11
|
+
|
12
|
+
def load(filename, options = {})
|
13
|
+
doc_dir = File.dirname(filename)
|
14
|
+
doc = Loader.handle(filename)
|
15
|
+
Dereferencer.new(doc_dir, doc, options).call
|
16
|
+
end
|
11
17
|
end
|
12
18
|
|
13
19
|
class Dereferencer
|
14
|
-
def initialize(doc, options = {})
|
20
|
+
def initialize(doc_dir, doc, options = {})
|
15
21
|
@doc = doc
|
16
22
|
@options = options
|
23
|
+
@doc_dir = doc_dir
|
17
24
|
end
|
18
25
|
|
19
26
|
def call(doc = @doc, keys = [])
|
@@ -35,6 +42,8 @@ module JsonRefs
|
|
35
42
|
|
36
43
|
private
|
37
44
|
|
45
|
+
attr_reader :doc_dir
|
46
|
+
|
38
47
|
def dereference(paths, referenced_path)
|
39
48
|
key = paths.pop
|
40
49
|
target = paths.inject(@doc) do |obj, key|
|
@@ -95,15 +104,13 @@ module JsonRefs
|
|
95
104
|
end
|
96
105
|
|
97
106
|
def recursive_dereference(referenced_path, klass)
|
107
|
+
unless File.absolute_path?(referenced_path)
|
108
|
+
referenced_path = "#{doc_dir}/#{referenced_path}"
|
109
|
+
end
|
98
110
|
directory = File.dirname(referenced_path)
|
99
|
-
filename = File.basename(referenced_path)
|
100
111
|
|
101
|
-
|
102
|
-
|
103
|
-
referenced_doc = klass.new(path: filename, doc: @doc).call
|
104
|
-
dereferenced_doc = Dereferencer.new(referenced_doc, @options).call
|
105
|
-
end
|
106
|
-
dereferenced_doc
|
112
|
+
referenced_doc = klass.new(path: referenced_path, doc: @doc).call
|
113
|
+
Dereferencer.new(directory, referenced_doc, @options).call
|
107
114
|
end
|
108
115
|
end
|
109
116
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_refs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Makoto Tajitsu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hana
|
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
- !ruby/object:Gem::Version
|
107
107
|
version: '0'
|
108
108
|
requirements: []
|
109
|
-
rubygems_version: 3.2.
|
109
|
+
rubygems_version: 3.2.31
|
110
110
|
signing_key:
|
111
111
|
specification_version: 4
|
112
112
|
summary: Dereference JSON Pointer
|