json-ld 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -7
- data/README.md +2 -0
- data/VERSION +1 -1
- data/bin/jsonld +1 -1
- data/lib/json/ld.rb +1 -1
- data/lib/json/ld/context.rb +1 -1
- data/lib/json/ld/reader.rb +3 -0
- data/lib/json/ld/to_rdf.rb +2 -2
- data/spec/reader_spec.rb +75 -40
- metadata +149 -105
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
5
|
-
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0a4d576cf93b10353456ecea80868f8bd5a5f88f
|
4
|
+
data.tar.gz: ba90774a7b26b1fbbf48cd9d5bc1e45023ba4fed
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 36a0b17ed90f36a359767dfdea6b75f1da97ace869092a1b63ce0dd8efe23a14c29286eeda81b58291ca16a6f1ec8df1d5d40247709cada7a815ab8cadac2480
|
7
|
+
data.tar.gz: e1f530dc401c5654848ac8270a4ad528e1c02f73724b8cc4f4e21cb8ad665538224db76483731d395d95f81dfbc9a667b45cba2f3ce381c5341dd04d23c2a555
|
data/README.md
CHANGED
@@ -216,6 +216,8 @@ Install with `gem install json-ld`
|
|
216
216
|
|
217
217
|
`RDF::GRAPH#dump` can also take a `:context` option to use a separately defined context
|
218
218
|
|
219
|
+
As JSON-LD may come from many different sources, included as an embedded script tag within an HTML document, the RDF Reader will strip input before the leading `{` or `[` and after the trailing `}` or `]`.
|
220
|
+
|
219
221
|
## Documentation
|
220
222
|
Full documentation available on [RubyDoc](http://rubydoc.info/gems/json-ld/file/README.md)
|
221
223
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.2
|
data/bin/jsonld
CHANGED
@@ -116,7 +116,7 @@ opts.each do |opt, arg|
|
|
116
116
|
when '--dbg' then parser_options[:debug] = ::JSON::LD::debug = true
|
117
117
|
when '--compact' then options[:compact] = true
|
118
118
|
when '--context' then options[:context] = arg
|
119
|
-
when '--
|
119
|
+
when '--evaluate' then input = arg
|
120
120
|
when '--expand' then options[:expand] = true
|
121
121
|
when '--format' then options[:output_format] = arg.to_sym
|
122
122
|
when '--flatten' then options[:flatten] = arg
|
data/lib/json/ld.rb
CHANGED
data/lib/json/ld/context.rb
CHANGED
@@ -274,7 +274,7 @@ module JSON::LD
|
|
274
274
|
raise
|
275
275
|
rescue Exception => e
|
276
276
|
# Speical case for schema.org, until they get their act together
|
277
|
-
if context.to_s
|
277
|
+
if context.to_s.start_with?('http://schema.org')
|
278
278
|
RDF::Util::File.open_file("http://json-ld.org/contexts/schema.org.jsonld") do |f|
|
279
279
|
context = JSON.parse(f.read)['@context']
|
280
280
|
if @options[:processingMode] == "json-ld-1.0"
|
data/lib/json/ld/reader.rb
CHANGED
@@ -30,6 +30,9 @@ module JSON::LD
|
|
30
30
|
super do
|
31
31
|
@options[:base] ||= base_uri.to_s if base_uri
|
32
32
|
begin
|
33
|
+
# Trim non-JSON stuff in script.
|
34
|
+
input = input.read if input.respond_to?(:read)
|
35
|
+
input = input.to_s.sub(%r(\A[^{\[]*)m, '').sub(%r([^}\]]*\Z)m, '')
|
33
36
|
@doc = JSON.load(input)
|
34
37
|
rescue JSON::ParserError => e
|
35
38
|
raise RDF::ReaderError, "Failed to parse input document: #{e.message}" if validate?
|
data/lib/json/ld/to_rdf.rb
CHANGED
@@ -101,10 +101,10 @@ module JSON::LD
|
|
101
101
|
#
|
102
102
|
# @param [Array] list
|
103
103
|
# The Array to serialize as a list
|
104
|
-
# @param [Array<RDF::Statement>] list_results
|
105
|
-
# Statements for each item in the list
|
106
104
|
# @yield statement
|
107
105
|
# @yieldparam [RDF::Resource] statement
|
106
|
+
# @return [Array<RDF::Statement>]
|
107
|
+
# Statements for each item in the list
|
108
108
|
def parse_list(list)
|
109
109
|
debug('parse_list') {"list: #{list.inspect}"}
|
110
110
|
|
data/spec/reader_spec.rb
CHANGED
@@ -26,52 +26,87 @@ describe JSON::LD::Reader do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
context :interface do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
{
|
30
|
+
plain: %q({
|
31
|
+
"@context": {"foaf": "http://xmlns.com/foaf/0.1/"},
|
32
|
+
"@id": "_:bnode1",
|
33
|
+
"@type": "foaf:Person",
|
34
|
+
"foaf:homepage": "http://example.com/bob/",
|
35
|
+
"foaf:name": "Bob"
|
36
|
+
}),
|
37
|
+
leading_comment: %q(
|
38
|
+
// A comment before content
|
39
|
+
{
|
40
|
+
"@context": {"foaf": "http://xmlns.com/foaf/0.1/"},
|
41
|
+
"@id": "_:bnode1",
|
42
|
+
"@type": "foaf:Person",
|
43
|
+
"foaf:homepage": "http://example.com/bob/",
|
44
|
+
"foaf:name": "Bob"
|
45
|
+
}
|
46
|
+
),
|
47
|
+
script: %q(<script type="application/ld+json">
|
48
|
+
{
|
49
|
+
"@context": {"foaf": "http://xmlns.com/foaf/0.1/"},
|
50
|
+
"@id": "_:bnode1",
|
51
|
+
"@type": "foaf:Person",
|
52
|
+
"foaf:homepage": "http://example.com/bob/",
|
53
|
+
"foaf:name": "Bob"
|
54
|
+
}
|
55
|
+
</script>),
|
56
|
+
script_comments: %q(<script type="application/ld+json">
|
57
|
+
// A comment before content
|
58
|
+
{
|
59
|
+
"@context": {"foaf": "http://xmlns.com/foaf/0.1/"},
|
60
|
+
"@id": "_:bnode1",
|
61
|
+
"@type": "foaf:Person",
|
62
|
+
"foaf:homepage": "http://example.com/bob/",
|
63
|
+
"foaf:name": "Bob"
|
64
|
+
}
|
65
|
+
</script>),
|
66
|
+
}.each do |variant, src|
|
67
|
+
context variant do
|
68
|
+
subject {src}
|
36
69
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
70
|
+
describe "#initialize" do
|
71
|
+
it "yields reader given string" do
|
72
|
+
inner = double("inner")
|
73
|
+
inner.should_receive(:called).with(JSON::LD::Reader)
|
74
|
+
JSON::LD::Reader.new(subject) do |reader|
|
75
|
+
inner.called(reader.class)
|
76
|
+
end
|
77
|
+
end
|
45
78
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
79
|
+
it "yields reader given IO" do
|
80
|
+
inner = double("inner")
|
81
|
+
inner.should_receive(:called).with(JSON::LD::Reader)
|
82
|
+
JSON::LD::Reader.new(StringIO.new(subject)) do |reader|
|
83
|
+
inner.called(reader.class)
|
84
|
+
end
|
85
|
+
end
|
53
86
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
87
|
+
it "returns reader" do
|
88
|
+
JSON::LD::Reader.new(subject).should be_a(JSON::LD::Reader)
|
89
|
+
end
|
90
|
+
end
|
58
91
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
92
|
+
describe "#each_statement" do
|
93
|
+
it "yields statements" do
|
94
|
+
inner = double("inner")
|
95
|
+
inner.should_receive(:called).with(RDF::Statement).exactly(3)
|
96
|
+
JSON::LD::Reader.new(subject).each_statement do |statement|
|
97
|
+
inner.called(statement.class)
|
98
|
+
end
|
99
|
+
end
|
65
100
|
end
|
66
|
-
end
|
67
|
-
end
|
68
101
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
102
|
+
describe "#each_triple" do
|
103
|
+
it "yields statements" do
|
104
|
+
inner = double("inner")
|
105
|
+
inner.should_receive(:called).exactly(3)
|
106
|
+
JSON::LD::Reader.new(subject).each_triple do |subject, predicate, object|
|
107
|
+
inner.called(subject.class, predicate.class, object.class)
|
108
|
+
end
|
109
|
+
end
|
75
110
|
end
|
76
111
|
end
|
77
112
|
end
|
metadata
CHANGED
@@ -1,124 +1,169 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: json-ld
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.1.2
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Gregg Kellogg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2014-04-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
15
14
|
name: rdf
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
version: 1.0.8
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.1'
|
22
20
|
type: :runtime
|
23
|
-
version_requirements: *id001
|
24
|
-
- !ruby/object:Gem::Dependency
|
25
|
-
name: equivalent-xml
|
26
21
|
prerelease: false
|
27
|
-
|
28
|
-
requirements:
|
29
|
-
- -
|
30
|
-
- !ruby/object:Gem::Version
|
31
|
-
version:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: equivalent-xml
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.4'
|
32
34
|
type: :development
|
33
|
-
version_requirements: *id002
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
name: open-uri-cached
|
36
35
|
prerelease: false
|
37
|
-
|
38
|
-
requirements:
|
39
|
-
- -
|
40
|
-
- !ruby/object:Gem::Version
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: open-uri-cached
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.0'
|
48
|
+
- - '>='
|
49
|
+
- !ruby/object:Gem::Version
|
41
50
|
version: 0.0.5
|
42
51
|
type: :development
|
43
|
-
version_requirements: *id003
|
44
|
-
- !ruby/object:Gem::Dependency
|
45
|
-
name: yard
|
46
52
|
prerelease: false
|
47
|
-
|
48
|
-
requirements:
|
49
|
-
- -
|
50
|
-
- !ruby/object:Gem::Version
|
51
|
-
version: 0.
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ~>
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0.0'
|
58
|
+
- - '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 0.0.5
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: yard
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ~>
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0.8'
|
52
68
|
type: :development
|
53
|
-
version_requirements: *id004
|
54
|
-
- !ruby/object:Gem::Dependency
|
55
|
-
name: rspec
|
56
69
|
prerelease: false
|
57
|
-
|
58
|
-
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version:
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ~>
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0.8'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rspec
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ~>
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '2.14'
|
62
82
|
type: :development
|
63
|
-
version_requirements: *id005
|
64
|
-
- !ruby/object:Gem::Dependency
|
65
|
-
name: rdf-spec
|
66
83
|
prerelease: false
|
67
|
-
|
68
|
-
requirements:
|
69
|
-
- -
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
version:
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ~>
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '2.14'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rdf-spec
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ~>
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '1.1'
|
72
96
|
type: :development
|
73
|
-
version_requirements: *id006
|
74
|
-
- !ruby/object:Gem::Dependency
|
75
|
-
name: rdf-turtle
|
76
97
|
prerelease: false
|
77
|
-
|
78
|
-
requirements:
|
79
|
-
- -
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
version: 1.
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ~>
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '1.1'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: rdf-turtle
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '1.1'
|
82
110
|
type: :development
|
83
|
-
version_requirements: *id007
|
84
|
-
- !ruby/object:Gem::Dependency
|
85
|
-
name: rdf-trig
|
86
111
|
prerelease: false
|
87
|
-
|
88
|
-
requirements:
|
89
|
-
- -
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
version: 1.
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ~>
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '1.1'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: rdf-trig
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ~>
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '1.1'
|
92
124
|
type: :development
|
93
|
-
version_requirements: *id008
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
name: rdf-isomorphic
|
96
125
|
prerelease: false
|
97
|
-
|
98
|
-
requirements:
|
99
|
-
-
|
100
|
-
-
|
101
|
-
|
102
|
-
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ~>
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '1.1'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: rdf-isomorphic
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ~>
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '1.1'
|
103
138
|
type: :development
|
104
|
-
version_requirements: *id009
|
105
|
-
- !ruby/object:Gem::Dependency
|
106
|
-
name: rdf-xsd
|
107
139
|
prerelease: false
|
108
|
-
|
109
|
-
requirements:
|
110
|
-
-
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ~>
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '1.1'
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: rdf-xsd
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ~>
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '1.1'
|
111
152
|
type: :development
|
112
|
-
|
113
|
-
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - ~>
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '1.1'
|
159
|
+
description: JSON::LD parses and serializes JSON-LD into RDF and implements expansion,
|
160
|
+
compaction and framing API interfaces.
|
114
161
|
email: public-linked-json@w3.org
|
115
|
-
executables:
|
162
|
+
executables:
|
116
163
|
- jsonld
|
117
164
|
extensions: []
|
118
|
-
|
119
165
|
extra_rdoc_files: []
|
120
|
-
|
121
|
-
files:
|
166
|
+
files:
|
122
167
|
- AUTHORS
|
123
168
|
- README.md
|
124
169
|
- UNLICENSE
|
@@ -221,31 +266,30 @@ files:
|
|
221
266
|
- spec/to_rdf_spec.rb
|
222
267
|
- spec/writer_spec.rb
|
223
268
|
homepage: http://github.com/ruby-rdf/json-ld
|
224
|
-
licenses:
|
269
|
+
licenses:
|
225
270
|
- Public Domain
|
226
271
|
metadata: {}
|
227
|
-
|
228
272
|
post_install_message:
|
229
273
|
rdoc_options: []
|
230
|
-
|
231
|
-
require_paths:
|
274
|
+
require_paths:
|
232
275
|
- lib
|
233
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
234
|
-
requirements:
|
235
|
-
- -
|
236
|
-
- !ruby/object:Gem::Version
|
276
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
277
|
+
requirements:
|
278
|
+
- - '>='
|
279
|
+
- !ruby/object:Gem::Version
|
237
280
|
version: 1.9.2
|
238
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
239
|
-
requirements:
|
240
|
-
-
|
281
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
282
|
+
requirements:
|
283
|
+
- - '>='
|
284
|
+
- !ruby/object:Gem::Version
|
285
|
+
version: '0'
|
241
286
|
requirements: []
|
242
|
-
|
243
287
|
rubyforge_project: json-ld
|
244
|
-
rubygems_version: 2.2.
|
288
|
+
rubygems_version: 2.2.2
|
245
289
|
signing_key:
|
246
290
|
specification_version: 4
|
247
291
|
summary: JSON-LD reader/writer for Ruby.
|
248
|
-
test_files:
|
292
|
+
test_files:
|
249
293
|
- spec/api_spec.rb
|
250
294
|
- spec/compact_spec.rb
|
251
295
|
- spec/context_spec.rb
|
@@ -267,9 +311,9 @@ test_files:
|
|
267
311
|
- spec/suite_helper.rb
|
268
312
|
- spec/suite_remote_doc_spec.rb
|
269
313
|
- spec/suite_to_rdf_spec.rb
|
314
|
+
- spec/support/extensions.rb
|
270
315
|
- spec/to_rdf_spec.rb
|
271
316
|
- spec/writer_spec.rb
|
272
|
-
- spec/support/extensions.rb
|
273
317
|
- spec/test-files/test-1-automatic.json
|
274
318
|
- spec/test-files/test-1-compacted.json
|
275
319
|
- spec/test-files/test-1-context.json
|