json-ld 0.3.2 → 0.9.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.
data/spec/expand_spec.rb CHANGED
@@ -9,7 +9,7 @@ describe JSON::LD::API do
9
9
  {
10
10
  "empty doc" => {
11
11
  :input => {},
12
- :output => [{}]
12
+ :output => []
13
13
  },
14
14
  "coerced IRI" => {
15
15
  :input => {
@@ -313,29 +313,25 @@ describe JSON::LD::API do
313
313
  :input => {
314
314
  "http://example.com/foo" => nil
315
315
  },
316
- :output => [{
317
- }]
316
+ :output => []
318
317
  },
319
318
  "@value" => {
320
319
  :input => {
321
320
  "http://example.com/foo" => {"@value" => nil}
322
321
  },
323
- :output => [{
324
- }]
322
+ :output => []
325
323
  },
326
324
  "@value and non-null @type" => {
327
325
  :input => {
328
326
  "http://example.com/foo" => {"@value" => nil, "@type" => "http://type"}
329
327
  },
330
- :output => [{
331
- }]
328
+ :output => []
332
329
  },
333
330
  "@value and non-null @language" => {
334
331
  :input => {
335
332
  "http://example.com/foo" => {"@value" => nil, "@language" => "en"}
336
333
  },
337
- :output => [{
338
- }]
334
+ :output => []
339
335
  },
340
336
  "non-null @value and null @type" => {
341
337
  :input => {
@@ -490,8 +486,7 @@ describe JSON::LD::API do
490
486
  :input => {
491
487
  "foo" => "bar"
492
488
  },
493
- :output => [{
494
- }]
489
+ :output => []
495
490
  },
496
491
  "unmapped @type as datatype" => {
497
492
  :input => {
@@ -505,9 +500,7 @@ describe JSON::LD::API do
505
500
  :input => {
506
501
  "@foo" => "bar"
507
502
  },
508
- :output => [{
509
- "@foo" => [{"@value" => "bar"}]
510
- }]
503
+ :output => []
511
504
  },
512
505
  "value" => {
513
506
  :input => {
@@ -515,9 +508,7 @@ describe JSON::LD::API do
515
508
  "@id" => "http://example.org/Subj",
516
509
  "idrange" => "unmapped"
517
510
  },
518
- :output => [{
519
- "@id" => "http://example.org/Subj",
520
- }]
511
+ :output => []
521
512
  },
522
513
  "context reset" => {
523
514
  :input => {
@@ -660,6 +651,183 @@ describe JSON::LD::API do
660
651
  end
661
652
  end
662
653
 
654
+ context "language maps" do
655
+ {
656
+ "simple map" => {
657
+ :input => {
658
+ "@context" => {
659
+ "vocab" => "http://example.com/vocab/",
660
+ "label" => {
661
+ "@id" => "vocab:label",
662
+ "@container" => "@language"
663
+ }
664
+ },
665
+ "@id" => "http://example.com/queen",
666
+ "label" => {
667
+ "en" => "The Queen",
668
+ "de" => [ "Die Königin", "Ihre Majestät" ]
669
+ }
670
+ },
671
+ :output => [
672
+ {
673
+ "@id" => "http://example.com/queen",
674
+ "http://example.com/vocab/label" => [
675
+ {"@value" => "Die Königin", "@language" => "de"},
676
+ {"@value" => "Ihre Majestät", "@language" => "de"},
677
+ {"@value" => "The Queen", "@language" => "en"}
678
+ ]
679
+ }
680
+ ]
681
+ },
682
+ "expand-0035" => {
683
+ :input => {
684
+ "@context" => {
685
+ "@vocab" => "http://example.com/vocab/",
686
+ "@language" => "it",
687
+ "label" => {
688
+ "@container" => "@language"
689
+ }
690
+ },
691
+ "@id" => "http://example.com/queen",
692
+ "label" => {
693
+ "en" => "The Queen",
694
+ "de" => [ "Die Königin", "Ihre Majestät" ]
695
+ },
696
+ "http://example.com/vocab/label" => [
697
+ "Il re",
698
+ { "@value" => "The king", "@language" => "en" }
699
+ ]
700
+ },
701
+ :output => [
702
+ {
703
+ "@id" => "http://example.com/queen",
704
+ "http://example.com/vocab/label" => [
705
+ {"@value" => "Il re", "@language" => "it"},
706
+ {"@value" => "The king", "@language" => "en"},
707
+ {"@value" => "Die Königin", "@language" => "de"},
708
+ {"@value" => "Ihre Majestät", "@language" => "de"},
709
+ {"@value" => "The Queen", "@language" => "en"},
710
+ ]
711
+ }
712
+ ]
713
+ }
714
+ }.each do |title, params|
715
+ it title do
716
+ jld = JSON::LD::API.expand(params[:input], nil, nil, :debug => @debug)
717
+ jld.should produce(params[:output], @debug)
718
+ end
719
+ end
720
+ end
721
+
722
+ context "annotations" do
723
+ {
724
+ "string annotation" => {
725
+ :input => {
726
+ "@context" => {
727
+ "container" => {
728
+ "@id" => "http://example.com/container",
729
+ "@container" => "@annotation"
730
+ }
731
+ },
732
+ "@id" => "http://example.com/annotationsTest",
733
+ "container" => {
734
+ "en" => "The Queen",
735
+ "de" => [ "Die Königin", "Ihre Majestät" ]
736
+ }
737
+ },
738
+ :output => [
739
+ {
740
+ "@id" => "http://example.com/annotationsTest",
741
+ "http://example.com/container" => [
742
+ {"@value" => "Die Königin", "@annotation" => "de"},
743
+ {"@value" => "Ihre Majestät", "@annotation" => "de"},
744
+ {"@value" => "The Queen", "@annotation" => "en"}
745
+ ]
746
+ }
747
+ ]
748
+ },
749
+ }.each do |title, params|
750
+ it title do
751
+ jld = JSON::LD::API.expand(params[:input], nil, nil, :debug => @debug)
752
+ jld.should produce(params[:output], @debug)
753
+ end
754
+ end
755
+ end
756
+
757
+ context "property generators" do
758
+ {
759
+ "expand-0038" => {
760
+ :input => {
761
+ "@context" => {
762
+ "site" => "http://example.com/",
763
+ "field_tags" => {
764
+ "@id" => [ "site:vocab/field_tags", "http://schema.org/about" ]
765
+ },
766
+ "field_related" => {
767
+ "@id" => [ "site:vocab/field_related", "http://schema.org/about" ]
768
+ }
769
+ },
770
+ "@id" => "site:node/1",
771
+ "field_tags" => [
772
+ { "@id" => "site:term/this-is-a-tag" }
773
+ ],
774
+ "field_related" => [
775
+ { "@id" => "site:node/this-is-related-news" }
776
+ ]
777
+ },
778
+ :output => [{
779
+ "@id" => "http://example.com/node/1",
780
+ "http://example.com/vocab/field_related" => [{
781
+ "@id" => "http://example.com/node/this-is-related-news"
782
+ }],
783
+ "http://schema.org/about" => [{
784
+ "@id" => "http://example.com/node/this-is-related-news"
785
+ }, {
786
+ "@id" => "http://example.com/term/this-is-a-tag"
787
+ }],
788
+ "http://example.com/vocab/field_tags" => [{
789
+ "@id" => "http://example.com/term/this-is-a-tag"
790
+ }]
791
+ }]
792
+ },
793
+ "generate bnodel ids" => {
794
+ :input => {
795
+ "@context" => {
796
+ "site" => "http://example.com/",
797
+ "field_tags" => {
798
+ "@id" => [ "site:vocab/field_tags", "http://schema.org/about" ]
799
+ }
800
+ },
801
+ "@id" => "site:node/1",
802
+ "field_tags" => [
803
+ { "@type" => "site:term/this-is-a-tag" },
804
+ "foo"
805
+ ]
806
+ },
807
+ :output => [{
808
+ "@id" => "http://example.com/node/1",
809
+ "http://schema.org/about" => [{
810
+ "@id" => "_:t0",
811
+ "@type" => ["http://example.com/term/this-is-a-tag"]
812
+ }, {
813
+ "@value" => "foo"
814
+ }],
815
+ "http://example.com/vocab/field_tags" => [{
816
+ "@id" => "_:t0",
817
+ "@type" => ["http://example.com/term/this-is-a-tag"]
818
+ }, {
819
+ "@value" => "foo"
820
+ }]
821
+ }]
822
+ }
823
+ }.each do |title, params|
824
+ it title do
825
+ jld = JSON::LD::API.expand(params[:input], nil, nil, :debug => @debug)
826
+ jld.should produce(params[:output], @debug)
827
+ end
828
+ end
829
+ end
830
+
663
831
  context "exceptions" do
664
832
  {
665
833
  "@list containing @list" => {
data/spec/flatten_spec.rb CHANGED
@@ -99,13 +99,11 @@ describe JSON::LD::API do
99
99
  @node_map = Hash.ordered
100
100
  graph = params[:graph] || '@merged'
101
101
  jld = nil
102
- JSON::LD::API.new(params[:input], nil, :debug => @debug) do |api|
103
- expanded_value = api.expand(api.value, nil, api.context)
102
+ expanded_value = JSON::LD::API.expand(params[:input])
103
+ JSON::LD::API.new(expanded_value, nil, :debug => @debug) do |api|
104
104
  api.generate_node_map(expanded_value,
105
105
  @node_map,
106
- graph,
107
- nil,
108
- JSON::LD::BlankNodeNamer.new("t"))
106
+ graph)
109
107
  end
110
108
  @node_map.keys.should produce([graph], @debug)
111
109
  subjects = @node_map[graph]
data/spec/frame_spec.rb CHANGED
@@ -5,7 +5,7 @@ require 'spec_helper'
5
5
  describe JSON::LD::API do
6
6
  before(:each) { @debug = []}
7
7
 
8
- describe ".frame" do
8
+ describe ".frame", :pending => "Must investigate" do
9
9
  {
10
10
  "frame with @type matches subject with @type" => {
11
11
  :frame => {
@@ -10,7 +10,10 @@ describe JSON::LD do
10
10
  m.entries.each do |t|
11
11
  specify "#{t.property('input')}: #{t.name}" do
12
12
  begin
13
- #pending("resolution of term rank in compact-0018") if t.property('input') == 'compact-0018-in.jsonld'
13
+ case t.property('input')
14
+ when /compact-(0032|0033|0034)/
15
+ pending("undesireable property generator corner cases")
16
+ end
14
17
  t.debug = ["test: #{t.inspect}", "source: #{t.input.read}"]
15
18
  t.debug << "context: #{t.context.read}" if t.property('context')
16
19
  result = JSON::LD::API.compact(t.input, t.context, nil,
@@ -11,10 +11,8 @@ describe JSON::LD do
11
11
  specify "#{t.property('input')}: #{t.name}" do
12
12
  begin
13
13
  case t.property('input')
14
- when /expand-0029/
15
- pending("resolution of @type resolution in expand-0029")
16
- when /expand-0030/
17
- pending("implementation of language maps")
14
+ when /expand-(0039)/
15
+ pending("As if!")
18
16
  end
19
17
  t.debug = ["test: #{t.inspect}", "source: #{t.input.read}"]
20
18
  t.debug << "context: #{t.context.read}" if t.property('context')
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ $:.unshift "."
3
+ require 'spec_helper'
4
+
5
+ describe JSON::LD do
6
+ describe "test suite" do
7
+ require 'suite_helper'
8
+ require 'suite_helper'
9
+ m = Fixtures::SuiteTest::Manifest.open('http://json-ld.org/test-suite/tests/flatten-manifest.jsonld')
10
+ describe m.name, :pending => "New flattening algorithm" do
11
+ m.entries.each do |t|
12
+ specify "#{t.property('input')}: #{t.name}" do
13
+ begin
14
+ t.debug = ["test: #{t.inspect}", "source: #{t.input.read}"]
15
+ t.debug << "frame: #{t.frame.read}" if t.property('frame')
16
+ result = JSON::LD::API.flatten(t.input, nil, t.context, nil,
17
+ :base => t.base,
18
+ :debug => t.debug)
19
+ expected = JSON.load(t.expect)
20
+ result.should produce(expected, t.debug)
21
+ rescue JSON::LD::ProcessingError => e
22
+ fail("Processing error: #{e.message}")
23
+ rescue JSON::LD::InvalidContext => e
24
+ fail("Invalid Context: #{e.message}")
25
+ rescue JSON::LD::InvalidFrame => e
26
+ fail("Invalid Frame: #{e.message}")
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end unless ENV['CI']
@@ -7,7 +7,7 @@ describe JSON::LD do
7
7
  require 'suite_helper'
8
8
  require 'suite_helper'
9
9
  m = Fixtures::SuiteTest::Manifest.open('http://json-ld.org/test-suite/tests/frame-manifest.jsonld')
10
- describe m.name do
10
+ describe m.name, :pending => "New framing algorithm" do
11
11
  m.entries.each do |t|
12
12
  specify "#{t.property('input')}: #{t.name}" do
13
13
  begin
data/spec/suite_helper.rb CHANGED
@@ -1,6 +1,3 @@
1
- # Spira class for manipulating test-manifest style test suites.
2
- # Used for SWAP tests
3
- require 'spira'
4
1
  require 'json/ld'
5
2
  require 'open-uri'
6
3
  require 'support/extensions'
@@ -2,19 +2,19 @@
2
2
  "@context": { "foaf": "http://xmlns.com/foaf/0.1/" },
3
3
  "@graph": [
4
4
  {
5
- "@id": "_:bnode1",
5
+ "@id": "_:t0",
6
6
  "@type": "foaf:Person",
7
7
  "foaf:homepage": "http://example.com/bob/",
8
8
  "foaf:name": "Bob"
9
9
  },
10
10
  {
11
- "@id": "_:bnode2",
11
+ "@id": "_:t1",
12
12
  "@type": "foaf:Person",
13
13
  "foaf:homepage": "http://example.com/eve/",
14
14
  "foaf:name": "Eve"
15
15
  },
16
16
  {
17
- "@id": "_:bnode3",
17
+ "@id": "_:t2",
18
18
  "@type": "foaf:Person",
19
19
  "foaf:homepage": "http://example.com/manu/",
20
20
  "foaf:name": "Manu"
@@ -1,18 +1,18 @@
1
1
  [
2
2
  {
3
- "@id": "_:bnode1",
3
+ "@id": "_:t0",
4
4
  "@type": ["http://xmlns.com/foaf/0.1/Person"],
5
5
  "http://xmlns.com/foaf/0.1/homepage": [{"@value": "http://example.com/bob/"}],
6
6
  "http://xmlns.com/foaf/0.1/name": [{"@value": "Bob"}]
7
7
  },
8
8
  {
9
- "@id": "_:bnode2",
9
+ "@id": "_:t1",
10
10
  "@type": ["http://xmlns.com/foaf/0.1/Person"],
11
11
  "http://xmlns.com/foaf/0.1/homepage": [{"@value": "http://example.com/eve/"}],
12
12
  "http://xmlns.com/foaf/0.1/name": [{"@value": "Eve"}]
13
13
  },
14
14
  {
15
- "@id": "_:bnode3",
15
+ "@id": "_:t2",
16
16
  "@type": ["http://xmlns.com/foaf/0.1/Person"],
17
17
  "http://xmlns.com/foaf/0.1/homepage": [{"@value": "http://example.com/manu/"}],
18
18
  "http://xmlns.com/foaf/0.1/name": [{"@value": "Manu"}]
data/spec/to_rdf_spec.rb CHANGED
@@ -100,7 +100,7 @@ describe JSON::LD::API do
100
100
  %q({
101
101
  "@type": "_:foo"
102
102
  }),
103
- %q([ a _:a ] .)
103
+ %q([ a _:foo ] .)
104
104
  ]
105
105
  }.each do |title, (js, nt)|
106
106
  it title do
data/spec/writer_spec.rb CHANGED
@@ -154,7 +154,7 @@ describe JSON::LD::Writer do
154
154
  owl:onClass <http://data.wikia.com/terms#Element>;
155
155
  owl:onProperty <http://data.wikia.com/terms#characterIn> .
156
156
  )
157
- serialize(input, :prefixes => {
157
+ serialize(input, :rename_bnodes => false, :prefixes => {
158
158
  :owl => "http://www.w3.org/2002/07/owl#",
159
159
  :rdfs => "http://www.w3.org/2000/01/rdf-schema#",
160
160
  :xsd => "http://www.w3.org/2001/XMLSchema#"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json-ld
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.9.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-06 00:00:00.000000000 Z
12
+ date: 2013-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdf
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.3.11
21
+ version: '1.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: 0.3.11
29
+ version: '1.0'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: json
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -91,22 +91,6 @@ dependencies:
91
91
  - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
93
  version: 0.8.3
94
- - !ruby/object:Gem::Dependency
95
- name: spira
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ! '>='
100
- - !ruby/object:Gem::Version
101
- version: 0.0.12
102
- type: :development
103
- prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: 0.0.12
110
94
  - !ruby/object:Gem::Dependency
111
95
  name: rspec
112
96
  requirement: !ruby/object:Gem::Requirement
@@ -130,7 +114,7 @@ dependencies:
130
114
  requirements:
131
115
  - - ! '>='
132
116
  - !ruby/object:Gem::Version
133
- version: 0.3.11
117
+ version: '1.0'
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
@@ -138,7 +122,7 @@ dependencies:
138
122
  requirements:
139
123
  - - ! '>='
140
124
  - !ruby/object:Gem::Version
141
- version: 0.3.11
125
+ version: '1.0'
142
126
  - !ruby/object:Gem::Dependency
143
127
  name: rdf-turtle
144
128
  requirement: !ruby/object:Gem::Requirement
@@ -146,7 +130,7 @@ dependencies:
146
130
  requirements:
147
131
  - - ! '>='
148
132
  - !ruby/object:Gem::Version
149
- version: 0.3.2
133
+ version: '0'
150
134
  type: :development
151
135
  prerelease: false
152
136
  version_requirements: !ruby/object:Gem::Requirement
@@ -154,7 +138,7 @@ dependencies:
154
138
  requirements:
155
139
  - - ! '>='
156
140
  - !ruby/object:Gem::Version
157
- version: 0.3.2
141
+ version: '0'
158
142
  - !ruby/object:Gem::Dependency
159
143
  name: rdf-trig
160
144
  requirement: !ruby/object:Gem::Requirement
@@ -162,7 +146,7 @@ dependencies:
162
146
  requirements:
163
147
  - - ! '>='
164
148
  - !ruby/object:Gem::Version
165
- version: 0.1.4
149
+ version: '0'
166
150
  type: :development
167
151
  prerelease: false
168
152
  version_requirements: !ruby/object:Gem::Requirement
@@ -170,7 +154,7 @@ dependencies:
170
154
  requirements:
171
155
  - - ! '>='
172
156
  - !ruby/object:Gem::Version
173
- version: 0.1.4
157
+ version: '0'
174
158
  - !ruby/object:Gem::Dependency
175
159
  name: rdf-isomorphic
176
160
  requirement: !ruby/object:Gem::Requirement
@@ -178,7 +162,7 @@ dependencies:
178
162
  requirements:
179
163
  - - ! '>='
180
164
  - !ruby/object:Gem::Version
181
- version: 0.3.4
165
+ version: '0'
182
166
  type: :development
183
167
  prerelease: false
184
168
  version_requirements: !ruby/object:Gem::Requirement
@@ -186,7 +170,7 @@ dependencies:
186
170
  requirements:
187
171
  - - ! '>='
188
172
  - !ruby/object:Gem::Version
189
- version: 0.3.4
173
+ version: '0'
190
174
  - !ruby/object:Gem::Dependency
191
175
  name: rdf-xsd
192
176
  requirement: !ruby/object:Gem::Requirement
@@ -194,7 +178,7 @@ dependencies:
194
178
  requirements:
195
179
  - - ! '>='
196
180
  - !ruby/object:Gem::Version
197
- version: 0.3.8
181
+ version: '0'
198
182
  type: :development
199
183
  prerelease: false
200
184
  version_requirements: !ruby/object:Gem::Requirement
@@ -202,7 +186,7 @@ dependencies:
202
186
  requirements:
203
187
  - - ! '>='
204
188
  - !ruby/object:Gem::Version
205
- version: 0.3.8
189
+ version: '0'
206
190
  - !ruby/object:Gem::Dependency
207
191
  name: backports
208
192
  requirement: !ruby/object:Gem::Requirement
@@ -261,6 +245,7 @@ files:
261
245
  - spec/spec_helper.rb
262
246
  - spec/suite_compact_spec.rb
263
247
  - spec/suite_expand_spec.rb
248
+ - spec/suite_flatten_spec.rb
264
249
  - spec/suite_frame_spec.rb
265
250
  - spec/suite_from_rdf_spec.rb
266
251
  - spec/suite_helper.rb
@@ -365,6 +350,7 @@ test_files:
365
350
  - spec/spec_helper.rb
366
351
  - spec/suite_compact_spec.rb
367
352
  - spec/suite_expand_spec.rb
353
+ - spec/suite_flatten_spec.rb
368
354
  - spec/suite_frame_spec.rb
369
355
  - spec/suite_from_rdf_spec.rb
370
356
  - spec/suite_helper.rb