json-ld 0.1.0 → 0.1.2

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.
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.1.0
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,33 +9,33 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-06 00:00:00.000000000Z
12
+ date: 2012-04-20 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdf
16
- requirement: &2164716620 !ruby/object:Gem::Requirement
16
+ requirement: &70185823761420 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: 0.3.4
21
+ version: 0.3.5
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2164716620
24
+ version_requirements: *70185823761420
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: json
27
- requirement: &2164715740 !ruby/object:Gem::Requirement
27
+ requirement: &70185823760820 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
- version: 1.5.1
32
+ version: 1.6.5
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2164715740
35
+ version_requirements: *70185823760820
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: equivalent-xml
38
- requirement: &2164714880 !ruby/object:Gem::Requirement
38
+ requirement: &70185823760180 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,32 +43,32 @@ dependencies:
43
43
  version: 0.2.8
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2164714880
46
+ version_requirements: *70185823760180
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: open-uri-cached
49
- requirement: &2164713440 !ruby/object:Gem::Requirement
49
+ requirement: &70185823759520 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.0.4
54
+ version: 0.0.5
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2164713440
57
+ version_requirements: *70185823759520
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: yard
60
- requirement: &2164711940 !ruby/object:Gem::Requirement
60
+ requirement: &70185823758900 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
64
64
  - !ruby/object:Gem::Version
65
- version: 0.6.0
65
+ version: 0.7.4
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2164711940
68
+ version_requirements: *70185823758900
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: spira
71
- requirement: &2164710920 !ruby/object:Gem::Requirement
71
+ requirement: &70185823758300 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,43 +76,54 @@ dependencies:
76
76
  version: 0.0.12
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2164710920
79
+ version_requirements: *70185823758300
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: rspec
82
- requirement: &2164701920 !ruby/object:Gem::Requirement
82
+ requirement: &70185823757580 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
86
86
  - !ruby/object:Gem::Version
87
- version: 2.5.0
87
+ version: 2.8.0
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2164701920
90
+ version_requirements: *70185823757580
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rdf-spec
93
- requirement: &2164701020 !ruby/object:Gem::Requirement
93
+ requirement: &70185823756980 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
97
97
  - !ruby/object:Gem::Version
98
- version: 0.3.4
98
+ version: 0.3.5
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *2164701020
101
+ version_requirements: *70185823756980
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: rdf-turtle
104
- requirement: &2164700360 !ruby/object:Gem::Requirement
104
+ requirement: &70185823756340 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: 0.1.1
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: *70185823756340
113
+ - !ruby/object:Gem::Dependency
114
+ name: rdf-trig
115
+ requirement: &70185823755720 !ruby/object:Gem::Requirement
105
116
  none: false
106
117
  requirements:
107
118
  - - ! '>='
108
119
  - !ruby/object:Gem::Version
109
- version: 0.1.0
120
+ version: 0.1.1
110
121
  type: :development
111
122
  prerelease: false
112
- version_requirements: *2164700360
123
+ version_requirements: *70185823755720
113
124
  - !ruby/object:Gem::Dependency
114
125
  name: rdf-isomorphic
115
- requirement: &2164699180 !ruby/object:Gem::Requirement
126
+ requirement: &70185823755100 !ruby/object:Gem::Requirement
116
127
  none: false
117
128
  requirements:
118
129
  - - ! '>='
@@ -120,10 +131,10 @@ dependencies:
120
131
  version: 0.3.4
121
132
  type: :development
122
133
  prerelease: false
123
- version_requirements: *2164699180
134
+ version_requirements: *70185823755100
124
135
  - !ruby/object:Gem::Dependency
125
136
  name: sparql
126
- requirement: &2164698500 !ruby/object:Gem::Requirement
137
+ requirement: &70185823754420 !ruby/object:Gem::Requirement
127
138
  none: false
128
139
  requirements:
129
140
  - - ! '>='
@@ -131,8 +142,9 @@ dependencies:
131
142
  version: 0.0.2
132
143
  type: :development
133
144
  prerelease: false
134
- version_requirements: *2164698500
135
- description: JSON-LD reader/writer for Ruby.
145
+ version_requirements: *70185823754420
146
+ description: JSON::LD parses and serializes JSON-LD into RDF and implements expansion,
147
+ compaction and framing API interfaces.
136
148
  email: public-rdf-ruby@w3.org
137
149
  executables: []
138
150
  extensions: []
@@ -144,11 +156,16 @@ files:
144
156
  - UNLICENSE
145
157
  - VERSION
146
158
  - lib/json/ld/api.rb
159
+ - lib/json/ld/compact.rb
147
160
  - lib/json/ld/evaluation_context.rb
161
+ - lib/json/ld/expand.rb
148
162
  - lib/json/ld/extensions.rb
149
163
  - lib/json/ld/format.rb
150
- - lib/json/ld/normalize.rb
164
+ - lib/json/ld/frame.rb
165
+ - lib/json/ld/from_rdf.rb
151
166
  - lib/json/ld/reader.rb
167
+ - lib/json/ld/to_rdf.rb
168
+ - lib/json/ld/utils.rb
152
169
  - lib/json/ld/version.rb
153
170
  - lib/json/ld/writer.rb
154
171
  - lib/json/ld.rb
@@ -173,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
190
  version: '0'
174
191
  requirements: []
175
192
  rubyforge_project: json-ld
176
- rubygems_version: 1.8.10
193
+ rubygems_version: 1.8.17
177
194
  signing_key:
178
195
  specification_version: 3
179
196
  summary: JSON-LD reader/writer for Ruby.
@@ -1,120 +0,0 @@
1
- module JSON::LD
2
- ##
3
- # Normalize Nodes in a graph. Uses [Normalization Algorithm](http://json-ld.org/spec/latest/#normalization-1)
4
- # from [JSON-LD specification](http://json-ld.org/spec/latest/).
5
- #
6
- # This module takes a graph and returns a new graph, with BNode names normalized to allow
7
- # for a canonical ordering of all statements within a graph.
8
- #
9
- # @example Normalize a graph
10
- # JSON::LD::normalize(graph) => graph
11
- #
12
- # @see http://json-ld.org/spec/latest
13
- # @see http://json-ld.org/spec/latest/#normalization-1
14
- # @author [Gregg Kellogg](http://greggkellogg.net/)
15
- class Normalize
16
- ##
17
- # Create a new normalization instance
18
- # @param [RDF::Enumerable] graph
19
- def initialize(graph)
20
- @graph = graph
21
- end
22
-
23
- ##
24
- # Perform normalization, and return a new graph with node identifiers normalized
25
- # @return [RDF::Graph]
26
- def normalize
27
- # Create an empty list of expanded nodes and recursively process every object in the expanded input that is not an
28
- # expanded IRI, typed literal or language literal
29
- nodes = graph.subjects.select {|s| s.node?}
30
-
31
- forward_mapping = {}
32
- reverse_mapping = {}
33
- @node_properties = {}
34
- graph.each_statment do |st|
35
- # Create a forward mapping that relates graph nodes to the IRIs of the targets nodes that they reference. For example,
36
- # if a node alpha refers to a node beta via a property, the key in the forward mapping is the subject IRI of alpha and
37
- # the value is an array containing at least the subject IRI of beta.
38
- if st.subject.node? && st.object.uri?
39
- forward_mapping[st.subject] ||= {}
40
- forward_mapping[st.subject] << st.object
41
- end
42
-
43
- # Create a reverse mapping that relates graph nodes to every other node that refers to them in the graph. For example,
44
- # if a node alpha refers to a node beta via a property, the key in the reverse mapping is the subject IRI for beta and
45
- # the value is an array containing at least the IRI for alpha.
46
- if st.object.node? && st.subject.uri?
47
- reverse_mapping[st.object] ||= {}
48
- reverse_mapping[st.object] << st.subject
49
- end
50
-
51
- # For node comparisons, keep track of properties of each node
52
- if st.subject.node?
53
- @node_properties[st.subject] ||= {}
54
- @node_properties[st.subject][st.predicate] ||= []
55
- @node_properties[st.subject][st.predicate] << st.object
56
- end
57
- end
58
-
59
- # Label every unlabeled node according to the Label Generation Algorithm in descending order using the Deep
60
- # Comparison Algorithm to determine the sort order.
61
- node_mapping = {}
62
- gen = "c14n_1"
63
- nodes.sort {|a, b| deep_comparison(a) <=> deep_comparison(b) }.each do |node|
64
- # name with Label Generation Algorithm and create mapping from original node to new name
65
- node_mapping[node] = RDF::Node.new(gen)
66
- gen = gen.succ
67
- end
68
-
69
- # Add statements to new graph using new node names
70
- graph = RDF::Graph.new
71
-
72
- @graph.each_statement do |st|
73
- if st.subject.node? || st.object.node?
74
- st = st.dup
75
- st.subject = node_mapping.fetch(st.subject, st.subject)
76
- st.object = node_mapping.fetch(st.object, st.object)
77
- end
78
- graph << st
79
- end
80
-
81
- # Return new graph
82
- graph
83
- end
84
-
85
- private
86
- def shallow_comparison(a, b)
87
- # 1. Compare the total number of node properties. The node with fewer properties is first.
88
- prop_count_a = @node_properties[a].keys.length
89
- prop_count_b = @node_properties[b].keys.length
90
- return prop_count_a <=> prop_count_b unless prop_count_a == prop_count_b
91
-
92
- # 2. Lexicographically sort the property IRIs for each node and compare the sorted lists. If an IRI is found to be
93
- # lexicographically smaller, the node containing that IRI is first.
94
- p_iri_a = @node_properties[a].keys.map(&:to_s).sort.first
95
- p_iri_b = @node_properties[a].keys.map(&:to_s).sort.first
96
- return p_iri_a <=> p_iri_b unless p_iri_a == p_iri_b
97
-
98
- # 3. Compare the property values against one another:
99
- @node_properties
100
- alpha_list
101
- end
102
-
103
- def deep_comparison(a, b)
104
- comp = shallow_comparison(a, b)
105
- if comp == 0
106
- end
107
- comp
108
- end
109
- end
110
-
111
- ##
112
- # Normalize a graph, returning a new graph with node names normalized
113
- def normalize(graph)
114
- norm = Normalize.new
115
- norm.normalize
116
- end
117
- module_meathod :normalize
118
-
119
- end
120
-