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 CHANGED
@@ -1,7 +1,7 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 40681daafe7cedbce21f62257a4ba28469da8f0d
4
- data.tar.gz: 0d9ecb3af38b10bf0c568769bf40b2bc325d004a
5
- SHA512:
6
- metadata.gz: 9ee2cc6a336620c287ab5c04c3b726e8b7eed9ae6ac3ab53c28c05e522e6532adc38b0a44863badcddedf5ff64ba00bdbffabc9a5c0768e146d1576a36f45efb
7
- data.tar.gz: 20427fde217f5853177a98d9f961c482c992e30767ff6a66e0054ae96682e8ce8bdccf7eb849e52c7b5a237eb8256382b57a9bfc4556fd0b315b45ecd382a01c
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.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 '--execute' then input = arg
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
@@ -3,7 +3,7 @@ require 'rdf' # @see http://rubygems.org/gems/rdf
3
3
 
4
4
  module JSON
5
5
  ##
6
- # **`JSON::LD`** is a JSON-LD plugin for RDF.rb.
6
+ # **`JSON::LD`** is a JSON-LD extension for RDF.rb.
7
7
  #
8
8
  # @example Requiring the `JSON::LD` module
9
9
  # require 'json/ld'
@@ -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 == 'http://schema.org/'
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"
@@ -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?
@@ -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
 
@@ -26,52 +26,87 @@ describe JSON::LD::Reader do
26
26
  end
27
27
 
28
28
  context :interface do
29
- subject { %q({
30
- "@context": {"foaf": "http://xmlns.com/foaf/0.1/"},
31
- "@id": "_:bnode1",
32
- "@type": "foaf:Person",
33
- "foaf:homepage": "http://example.com/bob/",
34
- "foaf:name": "Bob"
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
- describe "#initialize" do
38
- it "yields reader given string" do
39
- inner = double("inner")
40
- inner.should_receive(:called).with(JSON::LD::Reader)
41
- JSON::LD::Reader.new(subject) do |reader|
42
- inner.called(reader.class)
43
- end
44
- end
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
- it "yields reader given IO" do
47
- inner = double("inner")
48
- inner.should_receive(:called).with(JSON::LD::Reader)
49
- JSON::LD::Reader.new(StringIO.new(subject)) do |reader|
50
- inner.called(reader.class)
51
- end
52
- end
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
- it "returns reader" do
55
- JSON::LD::Reader.new(subject).should be_a(JSON::LD::Reader)
56
- end
57
- end
87
+ it "returns reader" do
88
+ JSON::LD::Reader.new(subject).should be_a(JSON::LD::Reader)
89
+ end
90
+ end
58
91
 
59
- describe "#each_statement" do
60
- it "yields statements" do
61
- inner = double("inner")
62
- inner.should_receive(:called).with(RDF::Statement).exactly(3)
63
- JSON::LD::Reader.new(subject).each_statement do |statement|
64
- inner.called(statement.class)
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
- describe "#each_triple" do
70
- it "yields statements" do
71
- inner = double("inner")
72
- inner.should_receive(:called).exactly(3)
73
- JSON::LD::Reader.new(subject).each_triple do |subject, predicate, object|
74
- inner.called(subject.class, predicate.class, object.class)
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.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
- date: 2014-01-10 00:00:00 Z
13
- dependencies:
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
- prerelease: false
17
- requirement: &id001 !ruby/object:Gem::Requirement
18
- requirements:
19
- - - ">="
20
- - !ruby/object:Gem::Version
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
- requirement: &id002 !ruby/object:Gem::Requirement
28
- requirements:
29
- - - ">="
30
- - !ruby/object:Gem::Version
31
- version: 0.2.8
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
- requirement: &id003 !ruby/object:Gem::Requirement
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
- requirement: &id004 !ruby/object:Gem::Requirement
48
- requirements:
49
- - - ">="
50
- - !ruby/object:Gem::Version
51
- version: 0.8.3
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
- requirement: &id005 !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: 2.12.0
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
- requirement: &id006 !ruby/object:Gem::Requirement
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- version: "1.0"
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
- requirement: &id007 !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: 1.0.7
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
- requirement: &id008 !ruby/object:Gem::Requirement
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- version: 1.0.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
- requirement: &id009 !ruby/object:Gem::Requirement
98
- requirements:
99
- - &id010
100
- - ">="
101
- - !ruby/object:Gem::Version
102
- version: "0"
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
- requirement: &id011 !ruby/object:Gem::Requirement
109
- requirements:
110
- - *id010
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
- version_requirements: *id011
113
- description: JSON::LD parses and serializes JSON-LD into RDF and implements expansion, compaction and framing API interfaces.
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
- - *id010
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.1
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