json-ld 2.0.0.beta3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/json/ld/format.rb +109 -89
- data/spec/format_spec.rb +8 -8
- metadata +32 -74
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dced97bd11d57cf20ab905c11bbfc68b84e629c4
|
4
|
+
data.tar.gz: 46c0cd1ab31c76d955de5f20ab2f79b5107300bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 560e981ff5251b643694da6d19233d498282d1059549eb3b3d518cdde977b8cbf43fd49878ba84cbc9858022127fcd479124293b1765ab622dc0851e4cc706be
|
7
|
+
data.tar.gz: d58df746aa3f62cd0dd610099a2cf4b514b1ac954ac242e0ef16604806c18fef25bf2ae1a6a28077bf63fa232d81a4315abb01293575a2bc4f01792d3d989865
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0
|
1
|
+
2.0.0
|
data/lib/json/ld/format.rb
CHANGED
@@ -47,123 +47,143 @@ module JSON::LD
|
|
47
47
|
# @return [Hash{Symbol => Lambda(Array, Hash)}]
|
48
48
|
def self.cli_commands
|
49
49
|
{
|
50
|
-
expand:
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
50
|
+
expand: {
|
51
|
+
description: "Expand JSON-LD or parsed RDF",
|
52
|
+
parse: false,
|
53
|
+
help: "expand [--context <context-file>] files ...",
|
54
|
+
lambda: ->(files, options) do
|
55
|
+
out = options[:output] || $stdout
|
56
|
+
out.set_encoding(Encoding::UTF_8) if RUBY_PLATFORM == "java"
|
57
|
+
options = options.merge(expandContext: options.delete(:context)) if options.has_key?(:context)
|
58
|
+
if options[:format] == :jsonld
|
59
|
+
if files.empty?
|
60
|
+
# If files are empty, either use options[:execute]
|
61
|
+
input = options[:evaluate] ? StringIO.new(options[:evaluate]) : STDIN
|
62
|
+
input.set_encoding(options.fetch(:encoding, Encoding::UTF_8))
|
63
|
+
JSON::LD::API.expand(input, options) do |expanded|
|
64
|
+
out.puts expanded.to_json(JSON::LD::JSON_STATE)
|
65
|
+
end
|
66
|
+
else
|
67
|
+
files.each do |file|
|
68
|
+
JSON::LD::API.expand(file, options) do |expanded|
|
69
|
+
out.puts expanded.to_json(JSON::LD::JSON_STATE)
|
70
|
+
end
|
71
|
+
end
|
61
72
|
end
|
62
73
|
else
|
63
|
-
|
64
|
-
|
74
|
+
# Turn RDF into JSON-LD first
|
75
|
+
RDF::CLI.parse(files, options) do |reader|
|
76
|
+
JSON::LD::API.fromRdf(reader) do |expanded|
|
65
77
|
out.puts expanded.to_json(JSON::LD::JSON_STATE)
|
66
78
|
end
|
67
79
|
end
|
68
80
|
end
|
69
|
-
else
|
70
|
-
# Turn RDF into JSON-LD first
|
71
|
-
RDF::CLI.parse(files, options) do |reader|
|
72
|
-
JSON::LD::API.fromRdf(reader) do |expanded|
|
73
|
-
out.puts expanded.to_json(JSON::LD::JSON_STATE)
|
74
|
-
end
|
75
|
-
end
|
76
81
|
end
|
77
|
-
|
78
|
-
compact:
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
JSON::LD::API.compact(file, options[:context], options) do |compacted|
|
82
|
+
},
|
83
|
+
compact: {
|
84
|
+
description: "Compact JSON-LD or parsed RDF",
|
85
|
+
parse: false,
|
86
|
+
help: "compact --context <context-file> files ...",
|
87
|
+
lambda: ->(files, options) do
|
88
|
+
raise ArgumentError, "Compacting requires a context" unless options[:context]
|
89
|
+
out = options[:output] || $stdout
|
90
|
+
out.set_encoding(Encoding::UTF_8) if RUBY_PLATFORM == "java"
|
91
|
+
if options[:format] == :jsonld
|
92
|
+
if files.empty?
|
93
|
+
# If files are empty, either use options[:execute]
|
94
|
+
input = options[:evaluate] ? StringIO.new(options[:evaluate]) : STDIN
|
95
|
+
input.set_encoding(options.fetch(:encoding, Encoding::UTF_8))
|
96
|
+
JSON::LD::API.compact(input, options[:context], options) do |compacted|
|
93
97
|
out.puts compacted.to_json(JSON::LD::JSON_STATE)
|
94
98
|
end
|
99
|
+
else
|
100
|
+
files.each do |file|
|
101
|
+
JSON::LD::API.compact(file, options[:context], options) do |compacted|
|
102
|
+
out.puts compacted.to_json(JSON::LD::JSON_STATE)
|
103
|
+
end
|
104
|
+
end
|
95
105
|
end
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
106
|
+
else
|
107
|
+
# Turn RDF into JSON-LD first
|
108
|
+
RDF::CLI.parse(files, options) do |reader|
|
109
|
+
JSON::LD::API.fromRdf(reader) do |expanded|
|
110
|
+
JSON::LD::API.compact(expanded, options[:context], options) do |compacted|
|
111
|
+
out.puts compacted.to_json(JSON::LD::JSON_STATE)
|
112
|
+
end
|
103
113
|
end
|
104
114
|
end
|
105
115
|
end
|
106
116
|
end
|
107
|
-
|
108
|
-
flatten:
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
JSON::LD::API.flatten(file, options[:context], options) do |flattened|
|
117
|
+
},
|
118
|
+
flatten: {
|
119
|
+
description: "Flatten JSON-LD or parsed RDF",
|
120
|
+
parse: false,
|
121
|
+
help: "flatten [--context <context-file>] files ...",
|
122
|
+
lambda: ->(files, options) do
|
123
|
+
out = options[:output] || $stdout
|
124
|
+
out.set_encoding(Encoding::UTF_8) if RUBY_PLATFORM == "java"
|
125
|
+
if options[:format] == :jsonld
|
126
|
+
if files.empty?
|
127
|
+
# If files are empty, either use options[:execute]
|
128
|
+
input = options[:evaluate] ? StringIO.new(options[:evaluate]) : STDIN
|
129
|
+
input.set_encoding(options.fetch(:encoding, Encoding::UTF_8))
|
130
|
+
JSON::LD::API.flatten(input, options[:context], options) do |flattened|
|
122
131
|
out.puts flattened.to_json(JSON::LD::JSON_STATE)
|
123
132
|
end
|
133
|
+
else
|
134
|
+
files.each do |file|
|
135
|
+
JSON::LD::API.flatten(file, options[:context], options) do |flattened|
|
136
|
+
out.puts flattened.to_json(JSON::LD::JSON_STATE)
|
137
|
+
end
|
138
|
+
end
|
124
139
|
end
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
140
|
+
else
|
141
|
+
# Turn RDF into JSON-LD first
|
142
|
+
RDF::CLI.parse(files, options) do |reader|
|
143
|
+
JSON::LD::API.fromRdf(reader) do |expanded|
|
144
|
+
JSON::LD::API.flatten(expanded, options[:context], options) do |flattened|
|
145
|
+
out.puts flattened.to_json(JSON::LD::JSON_STATE)
|
146
|
+
end
|
132
147
|
end
|
133
148
|
end
|
134
149
|
end
|
135
150
|
end
|
136
|
-
|
137
|
-
frame:
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
JSON::LD::API.frame(file, options[:frame], options) do |framed|
|
151
|
+
},
|
152
|
+
frame: {
|
153
|
+
description: "Flatten JSON-LD or parsed RDF",
|
154
|
+
parse: false,
|
155
|
+
help: "flatten --frame <frame-file> files ...",
|
156
|
+
lambda: ->(files, options) do
|
157
|
+
raise ArgumentError, "Framing requires a frame" unless options[:frame]
|
158
|
+
out = options[:output] || $stdout
|
159
|
+
out.set_encoding(Encoding::UTF_8) if RUBY_PLATFORM == "java"
|
160
|
+
if options[:format] == :jsonld
|
161
|
+
if files.empty?
|
162
|
+
# If files are empty, either use options[:execute]
|
163
|
+
input = options[:evaluate] ? StringIO.new(options[:evaluate]) : STDIN
|
164
|
+
input.set_encoding(options.fetch(:encoding, Encoding::UTF_8))
|
165
|
+
JSON::LD::API.frame(input, options[:frame], options) do |framed|
|
152
166
|
out.puts framed.to_json(JSON::LD::JSON_STATE)
|
153
167
|
end
|
168
|
+
else
|
169
|
+
files.each do |file|
|
170
|
+
JSON::LD::API.frame(file, options[:frame], options) do |framed|
|
171
|
+
out.puts framed.to_json(JSON::LD::JSON_STATE)
|
172
|
+
end
|
173
|
+
end
|
154
174
|
end
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
175
|
+
else
|
176
|
+
# Turn RDF into JSON-LD first
|
177
|
+
RDF::CLI.parse(files, options) do |reader|
|
178
|
+
JSON::LD::API.fromRdf(reader) do |expanded|
|
179
|
+
JSON::LD::API.frame(expanded, options[:frame], options) do |framed|
|
180
|
+
out.puts framed.to_json(JSON::LD::JSON_STATE)
|
181
|
+
end
|
162
182
|
end
|
163
183
|
end
|
164
184
|
end
|
165
185
|
end
|
166
|
-
|
186
|
+
},
|
167
187
|
}
|
168
188
|
end
|
169
189
|
|
data/spec/format_spec.rb
CHANGED
@@ -75,37 +75,37 @@ describe JSON::LD::Format do
|
|
75
75
|
|
76
76
|
describe "#expand" do
|
77
77
|
it "expands RDF" do
|
78
|
-
expect {RDF::CLI.
|
78
|
+
expect {RDF::CLI.exec(["expand", ttl], format: :ttl)}.to write.to(:output)
|
79
79
|
end
|
80
80
|
it "expands JSON" do
|
81
|
-
expect {RDF::CLI.
|
81
|
+
expect {RDF::CLI.exec(["expand", json], format: :jsonld)}.to write.to(:output)
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
85
|
describe "#compact" do
|
86
86
|
it "compacts RDF" do
|
87
|
-
expect {RDF::CLI.
|
87
|
+
expect {RDF::CLI.exec(["compact", ttl], context: context, format: :ttl)}.to write.to(:output)
|
88
88
|
end
|
89
89
|
it "compacts JSON" do
|
90
|
-
expect {RDF::CLI.
|
90
|
+
expect {RDF::CLI.exec(["compact", json], context: context, format: :jsonld)}.to write.to(:output)
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
94
|
describe "#flatten" do
|
95
95
|
it "flattens RDF" do
|
96
|
-
expect {RDF::CLI.
|
96
|
+
expect {RDF::CLI.exec(["flatten", ttl], context: context, format: :ttl)}.to write.to(:output)
|
97
97
|
end
|
98
98
|
it "flattens JSON" do
|
99
|
-
expect {RDF::CLI.
|
99
|
+
expect {RDF::CLI.exec(["flatten", json], context: context, format: :jsonld)}.to write.to(:output)
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
103
|
describe "#frame" do
|
104
104
|
it "frames RDF" do
|
105
|
-
expect {RDF::CLI.
|
105
|
+
expect {RDF::CLI.exec(["frame", ttl], frame: context, format: :ttl)}.to write.to(:output)
|
106
106
|
end
|
107
107
|
it "frames JSON" do
|
108
|
-
expect {RDF::CLI.
|
108
|
+
expect {RDF::CLI.exec(["frame", json], frame: context, format: :jsonld)}.to write.to(:output)
|
109
109
|
end
|
110
110
|
end
|
111
111
|
end
|
metadata
CHANGED
@@ -1,35 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json-ld
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregg Kellogg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdf
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 2.0.0.beta
|
20
|
-
- - "<"
|
17
|
+
- - "~>"
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
19
|
+
version: '2.0'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 2.0.0.beta
|
30
|
-
- - "<"
|
24
|
+
- - "~>"
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
26
|
+
version: '2.0'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: multi_json
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,122 +126,86 @@ dependencies:
|
|
132
126
|
name: rdf-isomorphic
|
133
127
|
requirement: !ruby/object:Gem::Requirement
|
134
128
|
requirements:
|
135
|
-
- - "
|
136
|
-
- !ruby/object:Gem::Version
|
137
|
-
version: 2.0.0.beta
|
138
|
-
- - "<"
|
129
|
+
- - "~>"
|
139
130
|
- !ruby/object:Gem::Version
|
140
|
-
version: '
|
131
|
+
version: '2.0'
|
141
132
|
type: :development
|
142
133
|
prerelease: false
|
143
134
|
version_requirements: !ruby/object:Gem::Requirement
|
144
135
|
requirements:
|
145
|
-
- - "
|
146
|
-
- !ruby/object:Gem::Version
|
147
|
-
version: 2.0.0.beta
|
148
|
-
- - "<"
|
136
|
+
- - "~>"
|
149
137
|
- !ruby/object:Gem::Version
|
150
|
-
version: '
|
138
|
+
version: '2.0'
|
151
139
|
- !ruby/object:Gem::Dependency
|
152
140
|
name: rdf-spec
|
153
141
|
requirement: !ruby/object:Gem::Requirement
|
154
142
|
requirements:
|
155
|
-
- - "
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: 2.0.0.beta
|
158
|
-
- - "<"
|
143
|
+
- - "~>"
|
159
144
|
- !ruby/object:Gem::Version
|
160
|
-
version: '
|
145
|
+
version: '2.0'
|
161
146
|
type: :development
|
162
147
|
prerelease: false
|
163
148
|
version_requirements: !ruby/object:Gem::Requirement
|
164
149
|
requirements:
|
165
|
-
- - "
|
166
|
-
- !ruby/object:Gem::Version
|
167
|
-
version: 2.0.0.beta
|
168
|
-
- - "<"
|
150
|
+
- - "~>"
|
169
151
|
- !ruby/object:Gem::Version
|
170
|
-
version: '
|
152
|
+
version: '2.0'
|
171
153
|
- !ruby/object:Gem::Dependency
|
172
154
|
name: rdf-trig
|
173
155
|
requirement: !ruby/object:Gem::Requirement
|
174
156
|
requirements:
|
175
|
-
- - "
|
176
|
-
- !ruby/object:Gem::Version
|
177
|
-
version: 2.0.0.beta
|
178
|
-
- - "<"
|
157
|
+
- - "~>"
|
179
158
|
- !ruby/object:Gem::Version
|
180
|
-
version: '
|
159
|
+
version: '2.0'
|
181
160
|
type: :development
|
182
161
|
prerelease: false
|
183
162
|
version_requirements: !ruby/object:Gem::Requirement
|
184
163
|
requirements:
|
185
|
-
- - "
|
186
|
-
- !ruby/object:Gem::Version
|
187
|
-
version: 2.0.0.beta
|
188
|
-
- - "<"
|
164
|
+
- - "~>"
|
189
165
|
- !ruby/object:Gem::Version
|
190
|
-
version: '
|
166
|
+
version: '2.0'
|
191
167
|
- !ruby/object:Gem::Dependency
|
192
168
|
name: rdf-turtle
|
193
169
|
requirement: !ruby/object:Gem::Requirement
|
194
170
|
requirements:
|
195
|
-
- - "
|
196
|
-
- !ruby/object:Gem::Version
|
197
|
-
version: 2.0.0.beta
|
198
|
-
- - "<"
|
171
|
+
- - "~>"
|
199
172
|
- !ruby/object:Gem::Version
|
200
|
-
version: '
|
173
|
+
version: '2.0'
|
201
174
|
type: :development
|
202
175
|
prerelease: false
|
203
176
|
version_requirements: !ruby/object:Gem::Requirement
|
204
177
|
requirements:
|
205
|
-
- - "
|
206
|
-
- !ruby/object:Gem::Version
|
207
|
-
version: 2.0.0.beta
|
208
|
-
- - "<"
|
178
|
+
- - "~>"
|
209
179
|
- !ruby/object:Gem::Version
|
210
|
-
version: '
|
180
|
+
version: '2.0'
|
211
181
|
- !ruby/object:Gem::Dependency
|
212
182
|
name: rdf-vocab
|
213
183
|
requirement: !ruby/object:Gem::Requirement
|
214
184
|
requirements:
|
215
|
-
- - "
|
216
|
-
- !ruby/object:Gem::Version
|
217
|
-
version: 2.0.0.beta
|
218
|
-
- - "<"
|
185
|
+
- - "~>"
|
219
186
|
- !ruby/object:Gem::Version
|
220
|
-
version: '
|
187
|
+
version: '2.0'
|
221
188
|
type: :development
|
222
189
|
prerelease: false
|
223
190
|
version_requirements: !ruby/object:Gem::Requirement
|
224
191
|
requirements:
|
225
|
-
- - "
|
226
|
-
- !ruby/object:Gem::Version
|
227
|
-
version: 2.0.0.beta
|
228
|
-
- - "<"
|
192
|
+
- - "~>"
|
229
193
|
- !ruby/object:Gem::Version
|
230
|
-
version: '
|
194
|
+
version: '2.0'
|
231
195
|
- !ruby/object:Gem::Dependency
|
232
196
|
name: rdf-xsd
|
233
197
|
requirement: !ruby/object:Gem::Requirement
|
234
198
|
requirements:
|
235
|
-
- - "
|
236
|
-
- !ruby/object:Gem::Version
|
237
|
-
version: 2.0.0.beta
|
238
|
-
- - "<"
|
199
|
+
- - "~>"
|
239
200
|
- !ruby/object:Gem::Version
|
240
|
-
version: '
|
201
|
+
version: '2.0'
|
241
202
|
type: :development
|
242
203
|
prerelease: false
|
243
204
|
version_requirements: !ruby/object:Gem::Requirement
|
244
205
|
requirements:
|
245
|
-
- - "
|
246
|
-
- !ruby/object:Gem::Version
|
247
|
-
version: 2.0.0.beta
|
248
|
-
- - "<"
|
206
|
+
- - "~>"
|
249
207
|
- !ruby/object:Gem::Version
|
250
|
-
version: '
|
208
|
+
version: '2.0'
|
251
209
|
- !ruby/object:Gem::Dependency
|
252
210
|
name: rspec
|
253
211
|
requirement: !ruby/object:Gem::Requirement
|
@@ -415,9 +373,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
415
373
|
version: '2.0'
|
416
374
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
417
375
|
requirements:
|
418
|
-
- - "
|
376
|
+
- - ">="
|
419
377
|
- !ruby/object:Gem::Version
|
420
|
-
version:
|
378
|
+
version: '0'
|
421
379
|
requirements: []
|
422
380
|
rubyforge_project: json-ld
|
423
381
|
rubygems_version: 2.4.8
|