rdf-rdfa 1.1.4.1 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.4.1
1
+ 1.1.5
@@ -1,70 +1,38 @@
1
+ require 'rdf/aggregate_repo'
2
+
1
3
  module RDF::RDFa
2
4
  ##
3
5
  # The Expansion module performs a subset of OWL entailment rules on the base class,
4
6
  # which implementes RDF::Readable.
5
7
  module Expansion
6
- ##
7
- # Pre-processed vocabularies used to simplify loading of common vocabularies
8
- COOKED_VOCAB_STATEMENTS = []
9
8
 
10
9
  ##
11
10
  # Perform vocabulary expansion on the resulting default graph.
12
11
  #
13
- # Vocabulary expansion relies on a sub-set of OWL entailment to add
14
- # triples to the default graph based on rules and property/class relationships
15
- # described in referenced vocabularies.
16
- #
17
- # For all objects that are the target of an rdfa:usesVocabulary property, load the IRI into
18
- # a repository.
19
- #
20
- # Subsequently, perform OWL expansion using rules prp-spo1, prp-eqp1,
21
- # prp-eqp2, cax-sco, cax-eqc1, and cax-eqc2 placing resulting triples into the default
22
- # graph. Iterate on this step until no more triples are added.
23
- #
24
- # @example
25
- # scm-spo
26
- # {pq rdfs:subPropertyOf pw . pw rdfs:subPropertyOf p3} => {p1 rdfs:subPropertyOf p3}
27
- #
28
- # rdprp-spo1fs7
29
- # {p1 rdfs:subPropertyOf p2 . x p1 y} => {x p2 y}
30
- #
31
- # cax-sco
32
- # {c1 rdfs:subClassOf c2 . x rdf:type c1} => {x rdf:type c2}
33
- #
34
- # scm-sco
35
- # {c1 rdfs:subClassOf c2 . c2 rdfs:subClassOf c3} => {c1 rdfs:subClassOf c3}
12
+ # Vocabulary expansion uses the built-in reasoner using included vocabularies from RDF.rb.
36
13
  #
37
14
  # @param [RDF::Repository] repository
38
15
  # @see [OWL2 PROFILES](http://www.w3.org/TR/2009/REC-owl2-profiles-20091027/#Reasoning_in_OWL_2_RL_and_RDF_Graphs_using_Rules)
39
16
  def expand(repository)
40
- count = repository.count
41
- add_debug("expand") {"Repository has #{repository.size} statements"}
42
-
43
- # Vocabularies managed in vocab_repo, and copied to repo for processing.
44
- # This allows for persistent storage of vocabularies
45
- @@vocab_repo = @options[:vocab_repository] if @options.has_key?(:vocab_repository)
46
- @@vocab_repo ||= RDF::Repository.new.insert(*COOKED_VOCAB_STATEMENTS)
47
-
17
+ add_debug("expand") {"Repository has #{repository.count} statements"}
18
+
19
+ # Load missing vocabularies
48
20
  vocabs = repository.query(:predicate => RDF::RDFA.usesVocabulary).to_a.map(&:object)
49
- vocabs.each do |vocab|
21
+ vocabs.map! do |vocab|
50
22
  begin
51
- unless @@vocab_repo.has_context?(vocab)
52
- add_debug("expand", "Load #{vocab}")
53
- @@vocab_repo.load(vocab, :context => vocab)
54
- end
23
+ # Create the name with a predictable name so that it is enumerated and can be found
24
+ v = RDF::Vocabulary.find(vocab) ||
25
+ RDF::Vocabulary.load(vocab, class_name: "D#{Digest::MD5.hexdigest vocab}")
55
26
  rescue Exception => e
56
27
  # indicate the warning if the vocabulary fails to laod
57
28
  add_warning("expand", "Error loading vocabulary #{vocab}: #{e.message}", RDF::RDFA.UnresolvedVocabulary)
29
+ nil
58
30
  end
59
- end
60
-
61
- @@vocab_repo.each do |statement|
62
- if vocabs.include?(statement.context)
63
- repository << statement
64
- end
65
- end
31
+ end.compact
32
+
33
+ entailment(repository, vocabs)
34
+ add_debug("expand") {"Repository now has #{repository.count} statements"}
66
35
 
67
- entailment(repository)
68
36
  end
69
37
 
70
38
  ##
@@ -223,9 +191,28 @@ module RDF::RDFa
223
191
  # Perform OWL entailment rules on repository
224
192
  # @param [RDF::Repository] repository
225
193
  # @return [RDF::Repository]
226
- def entailment(repository)
194
+ def entailment(repository, vocabs)
227
195
  old_count = 0
228
196
 
197
+ # Create an aggregate repo containing base repository and relevant entailment rules from the included vocabularies
198
+ v_repo = RDF::Repository.new do |r|
199
+ vocabs.each do |v|
200
+ v.each_statement do |statement|
201
+ r << statement if [
202
+ RDF::OWL.equivalentProperty,
203
+ RDF::OWL.equivalentClass,
204
+ RDF::RDFS.subPropertyOf,
205
+ RDF::RDFS.subClassOf
206
+ ].include?(statement.predicate)
207
+ end
208
+ end
209
+ end
210
+
211
+ ag_repo = RDF::MergeGraph.new do
212
+ source repository, false
213
+ source v_repo, false
214
+ end
215
+
229
216
  # Continue as long as new statements are added to repository
230
217
  while old_count < (count = repository.count)
231
218
  #add_debug("entailment") {"old: #{old_count} count: #{count}"}
@@ -233,7 +220,7 @@ module RDF::RDFa
233
220
  to_add = []
234
221
 
235
222
  RULES.each do |rule|
236
- rule.execute(repository) do |statement|
223
+ rule.execute(ag_repo) do |statement|
237
224
  #add_debug("entailment(#{rule.name})") {statement.inspect}
238
225
  to_add << statement
239
226
  end
@@ -241,8 +228,6 @@ module RDF::RDFa
241
228
 
242
229
  repository.insert(*to_add)
243
230
  end
244
-
245
- add_debug("entailment", "final count: #{count}")
246
231
  end
247
232
 
248
233
  ##
@@ -281,6 +266,3 @@ module RDF::RDFa
281
266
  end
282
267
  end
283
268
  end
284
-
285
- # Load cooked vocabularies
286
- Dir.glob(File.join(File.expand_path(File.dirname(__FILE__)), 'expansion', '*')).each {|f| load f}
@@ -386,7 +386,7 @@ module RDF::RDFa
386
386
  end
387
387
 
388
388
  # Look for Embedded Turtle and RDF/XML
389
- unless @root.xpath("//rdf:RDF", "xmlns:rdf" => "http://www.w3.org/1999/02/22-rdf-syntax-ns#").empty?
389
+ unless @root.xpath("//rdf:RDF", "rdf" => "http://www.w3.org/1999/02/22-rdf-syntax-ns#").empty?
390
390
  extract_script(@root, @doc, "application/rdf+xml", @options) do |statement|
391
391
  @repository << statement
392
392
  end
@@ -120,29 +120,41 @@ module RDF::RDFa
120
120
  @node.children.map(&:to_s).join
121
121
  end
122
122
 
123
+ def attribute_nodes
124
+ attrs = @node.attributes.dup.keep_if do |name, attr|
125
+ !name.start_with?('xmlns')
126
+ end
127
+ @attribute_nodes ||= (attrs.empty? ? attrs : NodeSetProxy.new(attrs, self))
128
+ end
129
+
123
130
  ##
124
131
  # Node type accessors
125
132
  #
126
133
  # @return [Boolean]
134
+ def text?
135
+ @node.is_a?(::REXML::Text)
136
+ end
137
+
127
138
  def element?
128
139
  @node.is_a?(::REXML::Element)
129
140
  end
130
141
 
131
- def attribute_nodes
132
- @attribute_nodes ||= NodeSetProxy.new(@node.children.select {|n| n.is_a?(::REXML::Attribute)}, self)
142
+ def blank?
143
+ @node.is_a?(::REXML::Text) && @node.empty?
133
144
  end
134
145
 
146
+ def to_s; @node.to_s; end
147
+
135
148
  def xpath(*args)
136
- #NodeSetProxy.new(::REXML::XPath.match(@node, path, namespaces), self)
137
149
  ::REXML::XPath.match(@node, *args).map do |n|
138
- # Get node ancestors
139
- parent = n.ancestors.reverse.inject(nil) do |p,node|
140
- NodeProxy.new(node, p)
141
- end rescue nil
142
150
  NodeProxy.new(n, parent)
143
151
  end
144
152
  end
145
153
 
154
+ def at_xpath(*args)
155
+ xpath(*args).first
156
+ end
157
+
146
158
  # Simple case for &lt;script&gt;
147
159
  def css(path)
148
160
  xpath("//script[@type]")
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf-rdfa
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4.1
4
+ version: 1.1.5
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Gregg
@@ -9,228 +10,258 @@ authors:
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2014-09-25 00:00:00.000000000 Z
13
+ date: 2014-11-11 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: rdf
16
17
  requirement: !ruby/object:Gem::Requirement
18
+ none: false
17
19
  requirements:
18
- - - "~>"
20
+ - - ~>
19
21
  - !ruby/object:Gem::Version
20
22
  version: '1.1'
21
- - - ">="
23
+ - - ! '>='
22
24
  - !ruby/object:Gem::Version
23
25
  version: 1.1.6
24
26
  type: :runtime
25
27
  prerelease: false
26
28
  version_requirements: !ruby/object:Gem::Requirement
29
+ none: false
27
30
  requirements:
28
- - - "~>"
31
+ - - ~>
29
32
  - !ruby/object:Gem::Version
30
33
  version: '1.1'
31
- - - ">="
34
+ - - ! '>='
32
35
  - !ruby/object:Gem::Version
33
36
  version: 1.1.6
34
37
  - !ruby/object:Gem::Dependency
35
38
  name: haml
36
39
  requirement: !ruby/object:Gem::Requirement
40
+ none: false
37
41
  requirements:
38
- - - "~>"
42
+ - - ~>
39
43
  - !ruby/object:Gem::Version
40
44
  version: '4.0'
41
45
  type: :runtime
42
46
  prerelease: false
43
47
  version_requirements: !ruby/object:Gem::Requirement
48
+ none: false
44
49
  requirements:
45
- - - "~>"
50
+ - - ~>
46
51
  - !ruby/object:Gem::Version
47
52
  version: '4.0'
48
53
  - !ruby/object:Gem::Dependency
49
54
  name: rdf-xsd
50
55
  requirement: !ruby/object:Gem::Requirement
56
+ none: false
51
57
  requirements:
52
- - - "~>"
58
+ - - ~>
53
59
  - !ruby/object:Gem::Version
54
60
  version: '1.1'
55
61
  type: :runtime
56
62
  prerelease: false
57
63
  version_requirements: !ruby/object:Gem::Requirement
64
+ none: false
58
65
  requirements:
59
- - - "~>"
66
+ - - ~>
60
67
  - !ruby/object:Gem::Version
61
68
  version: '1.1'
62
69
  - !ruby/object:Gem::Dependency
63
- name: htmlentities
70
+ name: rdf-aggregate-repo
64
71
  requirement: !ruby/object:Gem::Requirement
72
+ none: false
65
73
  requirements:
66
- - - "~>"
74
+ - - ! '>='
67
75
  - !ruby/object:Gem::Version
68
- version: '4.3'
76
+ version: '0'
69
77
  type: :runtime
70
78
  prerelease: false
71
79
  version_requirements: !ruby/object:Gem::Requirement
80
+ none: false
72
81
  requirements:
73
- - - "~>"
82
+ - - ! '>='
74
83
  - !ruby/object:Gem::Version
75
- version: '4.3'
84
+ version: '0'
76
85
  - !ruby/object:Gem::Dependency
77
- name: equivalent-xml
86
+ name: htmlentities
78
87
  requirement: !ruby/object:Gem::Requirement
88
+ none: false
79
89
  requirements:
80
- - - "~>"
90
+ - - ~>
81
91
  - !ruby/object:Gem::Version
82
- version: '0.4'
83
- type: :development
92
+ version: '4.3'
93
+ type: :runtime
84
94
  prerelease: false
85
95
  version_requirements: !ruby/object:Gem::Requirement
96
+ none: false
86
97
  requirements:
87
- - - "~>"
98
+ - - ~>
88
99
  - !ruby/object:Gem::Version
89
- version: '0.4'
100
+ version: '4.3'
90
101
  - !ruby/object:Gem::Dependency
91
102
  name: open-uri-cached
92
103
  requirement: !ruby/object:Gem::Requirement
104
+ none: false
93
105
  requirements:
94
- - - "~>"
106
+ - - ~>
95
107
  - !ruby/object:Gem::Version
96
108
  version: '0.0'
97
- - - ">="
109
+ - - ! '>='
98
110
  - !ruby/object:Gem::Version
99
111
  version: 0.0.5
100
112
  type: :development
101
113
  prerelease: false
102
114
  version_requirements: !ruby/object:Gem::Requirement
115
+ none: false
103
116
  requirements:
104
- - - "~>"
117
+ - - ~>
105
118
  - !ruby/object:Gem::Version
106
119
  version: '0.0'
107
- - - ">="
120
+ - - ! '>='
108
121
  - !ruby/object:Gem::Version
109
122
  version: 0.0.5
110
123
  - !ruby/object:Gem::Dependency
111
124
  name: json-ld
112
125
  requirement: !ruby/object:Gem::Requirement
126
+ none: false
113
127
  requirements:
114
- - - "~>"
128
+ - - ~>
115
129
  - !ruby/object:Gem::Version
116
130
  version: '1.1'
117
131
  type: :development
118
132
  prerelease: false
119
133
  version_requirements: !ruby/object:Gem::Requirement
134
+ none: false
120
135
  requirements:
121
- - - "~>"
136
+ - - ~>
122
137
  - !ruby/object:Gem::Version
123
138
  version: '1.1'
124
139
  - !ruby/object:Gem::Dependency
125
140
  name: rspec
126
141
  requirement: !ruby/object:Gem::Requirement
142
+ none: false
127
143
  requirements:
128
- - - "~>"
144
+ - - ~>
129
145
  - !ruby/object:Gem::Version
130
146
  version: '3.0'
131
147
  type: :development
132
148
  prerelease: false
133
149
  version_requirements: !ruby/object:Gem::Requirement
150
+ none: false
134
151
  requirements:
135
- - - "~>"
152
+ - - ~>
136
153
  - !ruby/object:Gem::Version
137
154
  version: '3.0'
138
155
  - !ruby/object:Gem::Dependency
139
156
  name: rspec-its
140
157
  requirement: !ruby/object:Gem::Requirement
158
+ none: false
141
159
  requirements:
142
- - - "~>"
160
+ - - ~>
143
161
  - !ruby/object:Gem::Version
144
162
  version: '1.0'
145
163
  type: :development
146
164
  prerelease: false
147
165
  version_requirements: !ruby/object:Gem::Requirement
166
+ none: false
148
167
  requirements:
149
- - - "~>"
168
+ - - ~>
150
169
  - !ruby/object:Gem::Version
151
170
  version: '1.0'
152
171
  - !ruby/object:Gem::Dependency
153
172
  name: rdf-spec
154
173
  requirement: !ruby/object:Gem::Requirement
174
+ none: false
155
175
  requirements:
156
- - - "~>"
176
+ - - ~>
157
177
  - !ruby/object:Gem::Version
158
178
  version: '1.1'
159
179
  type: :development
160
180
  prerelease: false
161
181
  version_requirements: !ruby/object:Gem::Requirement
182
+ none: false
162
183
  requirements:
163
- - - "~>"
184
+ - - ~>
164
185
  - !ruby/object:Gem::Version
165
186
  version: '1.1'
166
187
  - !ruby/object:Gem::Dependency
167
188
  name: rdf-turtle
168
189
  requirement: !ruby/object:Gem::Requirement
190
+ none: false
169
191
  requirements:
170
- - - "~>"
192
+ - - ~>
171
193
  - !ruby/object:Gem::Version
172
194
  version: '1.1'
173
195
  type: :development
174
196
  prerelease: false
175
197
  version_requirements: !ruby/object:Gem::Requirement
198
+ none: false
176
199
  requirements:
177
- - - "~>"
200
+ - - ~>
178
201
  - !ruby/object:Gem::Version
179
202
  version: '1.1'
180
203
  - !ruby/object:Gem::Dependency
181
204
  name: rdf-rdfxml
182
205
  requirement: !ruby/object:Gem::Requirement
206
+ none: false
183
207
  requirements:
184
- - - "~>"
208
+ - - ~>
185
209
  - !ruby/object:Gem::Version
186
210
  version: '1.1'
187
211
  type: :development
188
212
  prerelease: false
189
213
  version_requirements: !ruby/object:Gem::Requirement
214
+ none: false
190
215
  requirements:
191
- - - "~>"
216
+ - - ~>
192
217
  - !ruby/object:Gem::Version
193
218
  version: '1.1'
194
219
  - !ruby/object:Gem::Dependency
195
220
  name: rdf-isomorphic
196
221
  requirement: !ruby/object:Gem::Requirement
222
+ none: false
197
223
  requirements:
198
- - - "~>"
224
+ - - ~>
199
225
  - !ruby/object:Gem::Version
200
226
  version: '1.1'
201
227
  type: :development
202
228
  prerelease: false
203
229
  version_requirements: !ruby/object:Gem::Requirement
230
+ none: false
204
231
  requirements:
205
- - - "~>"
232
+ - - ~>
206
233
  - !ruby/object:Gem::Version
207
234
  version: '1.1'
208
235
  - !ruby/object:Gem::Dependency
209
236
  name: sparql
210
237
  requirement: !ruby/object:Gem::Requirement
238
+ none: false
211
239
  requirements:
212
- - - "~>"
240
+ - - ~>
213
241
  - !ruby/object:Gem::Version
214
242
  version: '1.1'
215
243
  type: :development
216
244
  prerelease: false
217
245
  version_requirements: !ruby/object:Gem::Requirement
246
+ none: false
218
247
  requirements:
219
- - - "~>"
248
+ - - ~>
220
249
  - !ruby/object:Gem::Version
221
250
  version: '1.1'
222
251
  - !ruby/object:Gem::Dependency
223
252
  name: yard
224
253
  requirement: !ruby/object:Gem::Requirement
254
+ none: false
225
255
  requirements:
226
- - - "~>"
256
+ - - ~>
227
257
  - !ruby/object:Gem::Version
228
258
  version: '0.8'
229
259
  type: :development
230
260
  prerelease: false
231
261
  version_requirements: !ruby/object:Gem::Requirement
262
+ none: false
232
263
  requirements:
233
- - - "~>"
264
+ - - ~>
234
265
  - !ruby/object:Gem::Version
235
266
  version: '0.8'
236
267
  description: RDF::RDFa is an RDFa reader/writer for Ruby using the RDF.rb library
@@ -244,54 +275,45 @@ files:
244
275
  - README
245
276
  - UNLICENSE
246
277
  - VERSION
247
- - lib/rdf/rdfa.rb
248
- - lib/rdf/rdfa/context.rb
249
278
  - lib/rdf/rdfa/context/html.rb
250
279
  - lib/rdf/rdfa/context/xhtml.rb
251
280
  - lib/rdf/rdfa/context/xml.rb
281
+ - lib/rdf/rdfa/context.rb
252
282
  - lib/rdf/rdfa/expansion.rb
253
- - lib/rdf/rdfa/expansion/cc.rb
254
- - lib/rdf/rdfa/expansion/dc.rb
255
- - lib/rdf/rdfa/expansion/doap.rb
256
- - lib/rdf/rdfa/expansion/foaf.rb
257
- - lib/rdf/rdfa/expansion/gr.rb
258
- - lib/rdf/rdfa/expansion/schema.rb
259
- - lib/rdf/rdfa/expansion/sioc.rb
260
- - lib/rdf/rdfa/expansion/skos.rb
261
- - lib/rdf/rdfa/expansion/skosxl.rb
262
- - lib/rdf/rdfa/expansion/v.rb
263
283
  - lib/rdf/rdfa/format.rb
264
284
  - lib/rdf/rdfa/patches/string_hacks.rb
265
- - lib/rdf/rdfa/reader.rb
266
285
  - lib/rdf/rdfa/reader/nokogiri.rb
267
286
  - lib/rdf/rdfa/reader/rexml.rb
287
+ - lib/rdf/rdfa/reader.rb
268
288
  - lib/rdf/rdfa/version.rb
269
289
  - lib/rdf/rdfa/vocab.rb
270
- - lib/rdf/rdfa/writer.rb
271
290
  - lib/rdf/rdfa/writer/haml_templates.rb
291
+ - lib/rdf/rdfa/writer.rb
292
+ - lib/rdf/rdfa.rb
272
293
  homepage: http://ruby-rdf.github.com/rdf-rdfa
273
294
  licenses:
274
295
  - Public Domain
275
- metadata: {}
276
296
  post_install_message:
277
297
  rdoc_options: []
278
298
  require_paths:
279
299
  - lib
280
300
  required_ruby_version: !ruby/object:Gem::Requirement
301
+ none: false
281
302
  requirements:
282
- - - ">="
303
+ - - ! '>='
283
304
  - !ruby/object:Gem::Version
284
305
  version: 1.9.3
285
306
  required_rubygems_version: !ruby/object:Gem::Requirement
307
+ none: false
286
308
  requirements:
287
- - - ">="
309
+ - - ! '>='
288
310
  - !ruby/object:Gem::Version
289
311
  version: '0'
290
312
  requirements: []
291
313
  rubyforge_project: rdf-rdfa
292
- rubygems_version: 2.2.2
314
+ rubygems_version: 1.8.23.2
293
315
  signing_key:
294
- specification_version: 4
316
+ specification_version: 3
295
317
  summary: RDFa reader/writer for RDF.rb.
296
318
  test_files: []
297
319
  has_rdoc: false