json-ld 3.2.4 → 3.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/json/ld/api.rb +807 -771
  4. data/lib/json/ld/compact.rb +304 -304
  5. data/lib/json/ld/conneg.rb +179 -161
  6. data/lib/json/ld/context.rb +2080 -1913
  7. data/lib/json/ld/expand.rb +745 -666
  8. data/lib/json/ld/extensions.rb +14 -13
  9. data/lib/json/ld/flatten.rb +257 -247
  10. data/lib/json/ld/format.rb +202 -194
  11. data/lib/json/ld/frame.rb +525 -502
  12. data/lib/json/ld/from_rdf.rb +223 -204
  13. data/lib/json/ld/html/nokogiri.rb +123 -121
  14. data/lib/json/ld/html/rexml.rb +151 -147
  15. data/lib/json/ld/reader.rb +107 -100
  16. data/lib/json/ld/resource.rb +224 -205
  17. data/lib/json/ld/streaming_reader.rb +574 -507
  18. data/lib/json/ld/streaming_writer.rb +93 -92
  19. data/lib/json/ld/to_rdf.rb +171 -169
  20. data/lib/json/ld/utils.rb +270 -264
  21. data/lib/json/ld/version.rb +24 -14
  22. data/lib/json/ld/writer.rb +334 -311
  23. data/lib/json/ld.rb +103 -96
  24. metadata +55 -198
  25. data/spec/api_spec.rb +0 -132
  26. data/spec/compact_spec.rb +0 -3482
  27. data/spec/conneg_spec.rb +0 -373
  28. data/spec/context_spec.rb +0 -2056
  29. data/spec/expand_spec.rb +0 -4496
  30. data/spec/flatten_spec.rb +0 -1203
  31. data/spec/format_spec.rb +0 -115
  32. data/spec/frame_spec.rb +0 -2541
  33. data/spec/from_rdf_spec.rb +0 -1072
  34. data/spec/matchers.rb +0 -20
  35. data/spec/rdfstar_spec.rb +0 -25
  36. data/spec/reader_spec.rb +0 -883
  37. data/spec/resource_spec.rb +0 -76
  38. data/spec/spec_helper.rb +0 -281
  39. data/spec/streaming_reader_spec.rb +0 -237
  40. data/spec/streaming_writer_spec.rb +0 -145
  41. data/spec/suite_compact_spec.rb +0 -22
  42. data/spec/suite_expand_spec.rb +0 -36
  43. data/spec/suite_flatten_spec.rb +0 -34
  44. data/spec/suite_frame_spec.rb +0 -29
  45. data/spec/suite_from_rdf_spec.rb +0 -22
  46. data/spec/suite_helper.rb +0 -411
  47. data/spec/suite_html_spec.rb +0 -22
  48. data/spec/suite_http_spec.rb +0 -35
  49. data/spec/suite_remote_doc_spec.rb +0 -22
  50. data/spec/suite_to_rdf_spec.rb +0 -30
  51. data/spec/support/extensions.rb +0 -44
  52. data/spec/test-files/test-1-compacted.jsonld +0 -10
  53. data/spec/test-files/test-1-context.jsonld +0 -7
  54. data/spec/test-files/test-1-expanded.jsonld +0 -5
  55. data/spec/test-files/test-1-input.jsonld +0 -10
  56. data/spec/test-files/test-1-rdf.ttl +0 -8
  57. data/spec/test-files/test-2-compacted.jsonld +0 -20
  58. data/spec/test-files/test-2-context.jsonld +0 -7
  59. data/spec/test-files/test-2-expanded.jsonld +0 -16
  60. data/spec/test-files/test-2-input.jsonld +0 -20
  61. data/spec/test-files/test-2-rdf.ttl +0 -14
  62. data/spec/test-files/test-3-compacted.jsonld +0 -11
  63. data/spec/test-files/test-3-context.jsonld +0 -8
  64. data/spec/test-files/test-3-expanded.jsonld +0 -10
  65. data/spec/test-files/test-3-input.jsonld +0 -11
  66. data/spec/test-files/test-3-rdf.ttl +0 -8
  67. data/spec/test-files/test-4-compacted.jsonld +0 -10
  68. data/spec/test-files/test-4-context.jsonld +0 -7
  69. data/spec/test-files/test-4-expanded.jsonld +0 -6
  70. data/spec/test-files/test-4-input.jsonld +0 -10
  71. data/spec/test-files/test-4-rdf.ttl +0 -5
  72. data/spec/test-files/test-5-compacted.jsonld +0 -13
  73. data/spec/test-files/test-5-context.jsonld +0 -7
  74. data/spec/test-files/test-5-expanded.jsonld +0 -9
  75. data/spec/test-files/test-5-input.jsonld +0 -13
  76. data/spec/test-files/test-5-rdf.ttl +0 -7
  77. data/spec/test-files/test-6-compacted.jsonld +0 -10
  78. data/spec/test-files/test-6-context.jsonld +0 -7
  79. data/spec/test-files/test-6-expanded.jsonld +0 -10
  80. data/spec/test-files/test-6-input.jsonld +0 -10
  81. data/spec/test-files/test-6-rdf.ttl +0 -6
  82. data/spec/test-files/test-7-compacted.jsonld +0 -23
  83. data/spec/test-files/test-7-context.jsonld +0 -4
  84. data/spec/test-files/test-7-expanded.jsonld +0 -20
  85. data/spec/test-files/test-7-input.jsonld +0 -23
  86. data/spec/test-files/test-7-rdf.ttl +0 -14
  87. data/spec/test-files/test-8-compacted.jsonld +0 -34
  88. data/spec/test-files/test-8-context.jsonld +0 -11
  89. data/spec/test-files/test-8-expanded.jsonld +0 -24
  90. data/spec/test-files/test-8-frame.jsonld +0 -18
  91. data/spec/test-files/test-8-framed.jsonld +0 -25
  92. data/spec/test-files/test-8-input.jsonld +0 -30
  93. data/spec/test-files/test-8-rdf.ttl +0 -15
  94. data/spec/test-files/test-9-compacted.jsonld +0 -20
  95. data/spec/test-files/test-9-context.jsonld +0 -13
  96. data/spec/test-files/test-9-expanded.jsonld +0 -14
  97. data/spec/test-files/test-9-input.jsonld +0 -12
  98. data/spec/to_rdf_spec.rb +0 -1684
  99. data/spec/writer_spec.rb +0 -427
data/spec/format_spec.rb DELETED
@@ -1,115 +0,0 @@
1
- # coding: utf-8
2
- require_relative 'spec_helper'
3
- require 'rdf/spec/format'
4
-
5
- describe JSON::LD::Format do
6
- it_behaves_like 'an RDF::Format' do
7
- let(:format_class) {JSON::LD::Format}
8
- end
9
-
10
- describe ".for" do
11
- formats = [
12
- :jsonld,
13
- "etc/doap.jsonld",
14
- {file_name: 'etc/doap.jsonld'},
15
- {file_extension: 'jsonld'},
16
- {content_type: 'application/ld+json'},
17
- {content_type: 'application/x-ld+json'},
18
- ].each do |arg|
19
- it "discovers with #{arg.inspect}" do
20
- expect(RDF::Format.for(arg)).to eq described_class
21
- end
22
- end
23
-
24
- {
25
- jsonld: '{"@context" => "foo"}',
26
- context: %({\n"@context": {),
27
- id: %({\n"@id": {),
28
- type: %({\n"@type": {),
29
- }.each do |sym, str|
30
- it "detects #{sym}" do
31
- expect(described_class.for {str}).to eq described_class
32
- end
33
- end
34
-
35
- it "should discover 'jsonld'" do
36
- expect(RDF::Format.for(:jsonld).reader).to eq JSON::LD::Reader
37
- end
38
- end
39
-
40
- describe "#to_sym" do
41
- specify {expect(described_class.to_sym).to eq :jsonld}
42
- end
43
-
44
- describe "#to_uri" do
45
- specify {expect(described_class.to_uri).to eq RDF::URI('http://www.w3.org/ns/formats/JSON-LD')}
46
- end
47
-
48
- describe ".detect" do
49
- {
50
- jsonld: '{"@context" => "foo"}',
51
- }.each do |sym, str|
52
- it "detects #{sym}" do
53
- expect(described_class.detect(str)).to be_truthy
54
- end
55
- end
56
-
57
- {
58
- n3: "@prefix foo: <bar> .\nfoo:bar = {<a> <b> <c>} .",
59
- nquads: "<a> <b> <c> <d> . ",
60
- rdfxml: '<rdf:RDF about="foo"></rdf:RDF>',
61
- rdfa: '<div about="foo"></div>',
62
- microdata: '<div itemref="bar"></div>',
63
- ntriples: "<a> <b> <c> .",
64
- multi_line: '<a>\n <b>\n "literal"\n .',
65
- turtle: "@prefix foo: <bar> .\n foo:a foo:b <c> .",
66
- }.each do |sym, str|
67
- it "does not detect #{sym}" do
68
- expect(described_class.detect(str)).to be_falsey
69
- end
70
- end
71
- end
72
-
73
- describe ".cli_commands", skip: Gem.win_platform? do
74
- require 'rdf/cli'
75
- let(:ttl) {File.expand_path("../test-files/test-1-rdf.ttl", __FILE__)}
76
- let(:json) {File.expand_path("../test-files/test-1-input.jsonld", __FILE__)}
77
- let(:context) {File.expand_path("../test-files/test-1-context.jsonld", __FILE__)}
78
-
79
- describe "#expand" do
80
- it "expands RDF" do
81
- expect {RDF::CLI.exec(["expand", ttl], format: :ttl, output_format: :jsonld)}.to write.to(:output)
82
- end
83
- it "expands JSON" do
84
- expect {RDF::CLI.exec(["expand", json], format: :jsonld, output_format: :jsonld, validate: false)}.to write.to(:output)
85
- end
86
- end
87
-
88
- describe "#compact" do
89
- it "compacts RDF" do
90
- expect {RDF::CLI.exec(["compact", ttl], context: context, format: :ttl, output_format: :jsonld, validate: false)}.to write.to(:output)
91
- end
92
- it "compacts JSON" do
93
- expect {RDF::CLI.exec(["compact", json], context: context, format: :jsonld, output_format: :jsonld, validate: false)}.to write.to(:output)
94
- end
95
- end
96
-
97
- describe "#flatten" do
98
- it "flattens RDF" do
99
- expect {RDF::CLI.exec(["flatten", ttl], context: context, format: :ttl, output_format: :jsonld, validate: false)}.to write.to(:output)
100
- end
101
- it "flattens JSON" do
102
- expect {RDF::CLI.exec(["flatten", json], context: context, format: :jsonld, output_format: :jsonld, validate: false)}.to write.to(:output)
103
- end
104
- end
105
-
106
- describe "#frame" do
107
- it "frames RDF" do
108
- expect {RDF::CLI.exec(["frame", ttl], frame: context, format: :ttl, output_format: :jsonld)}.to write.to(:output)
109
- end
110
- it "frames JSON" do
111
- expect {RDF::CLI.exec(["frame", json], frame: context, format: :jsonld, output_format: :jsonld, validate: false)}.to write.to(:output)
112
- end
113
- end
114
- end
115
- end