rdf-rdfa 0.3.4.2 → 0.3.5.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.4.2
1
+ 0.3.5.1
@@ -266,8 +266,8 @@ module RDF::RDFa
266
266
  # Snif version based on input
267
267
  case input
268
268
  when Nokogiri::XML::Document, Nokogiri::HTML::Document
269
- doc_type_string = input.doc_type.to_s
270
- version_attr = input.root && @doc.root.attribute("version").to_s
269
+ doc_type_string = input.doctype.to_s
270
+ version_attr = input.root && input.root.attribute("version").to_s
271
271
  root_element = input.root.name.downcase
272
272
  root_namespace = input.root.namespace.to_s
273
273
  root_attrs = input.root.attributes
@@ -624,7 +624,7 @@ module RDF::RDFa
624
624
 
625
625
  # Pull out the attributes needed for the skip test.
626
626
  property = attrs['property'].to_s.strip if attrs['property']
627
- typeof = attrs['typeof'].to_s.strip if attrs['typeof']
627
+ typeof = attrs['typeof'].to_s.strip if attrs.has_key?('typeof')
628
628
  datatype = attrs['datatype'].to_s if attrs['datatype']
629
629
  content = attrs['content'].to_s if attrs['content']
630
630
  rel = attrs['rel'].to_s.strip if attrs['rel']
@@ -763,13 +763,13 @@ module RDF::RDFa
763
763
  # otherwise,
764
764
  # if parent object is present, new subject is set to the value of parent object.
765
765
  # Additionally, if @property is not present then the skip element flag is set to 'true';
766
- new_subject ||= if element == @doc.root && base
767
- uri(base)
768
- elsif [:xhtml1, :xhtml5, :html4, :html5].include?(@host_language) && element.name =~ /^(head|body)$/
766
+ new_subject ||= if [:xhtml1, :xhtml5, :html4, :html5].include?(@host_language) && element.name =~ /^(head|body)$/
769
767
  # From XHTML+RDFa 1.1:
770
768
  # if no URI is provided, then first check to see if the element is the head or body element.
771
769
  # If it is, then act as if there is an empty @about present, and process it according to the rule for @about.
772
770
  uri(base)
771
+ elsif element == @doc.root && base
772
+ uri(base)
773
773
  elsif typeof
774
774
  RDF::Node.new
775
775
  else
@@ -426,7 +426,7 @@ module RDF::RDFa
426
426
  # The block should only return a string for recursive object definitions.
427
427
  # @return String
428
428
  # The rendered document is returned as a string
429
- def render_property(predicate, objects, property, rel, options = {})
429
+ def render_property(predicate, objects, property, rel, options = {}, &block)
430
430
  # If there are multiple objects, and no :properti_values is defined, call recursively with
431
431
  # each object
432
432
 
@@ -434,7 +434,7 @@ module RDF::RDFa
434
434
  template ||= objects.length > 1 ? haml_template[:property_values] : haml_template[:property_value]
435
435
  if objects.length > 1 && template.nil?
436
436
  objects.map do |object|
437
- render_property(predicate, [object], property, rel, options)
437
+ render_property(predicate, [object], property, rel, options, &block)
438
438
  end.join(" ")
439
439
  else
440
440
  raise RDF::WriterError, "Missing property template" if template.nil?
@@ -503,7 +503,7 @@ module RDF::RDFa
503
503
  # Add distinguished classes
504
504
  top_classes.
505
505
  select {|s| !seen.include?(s)}.
506
- each do |class_uri|
506
+ each do |class_uri|
507
507
  graph.query(:predicate => RDF.type, :object => class_uri).map {|st| st.subject}.sort.uniq.each do |subject|
508
508
  #add_debug "order_subjects: #{subject.inspect}"
509
509
  subjects << subject
@@ -517,6 +517,8 @@ module RDF::RDFa
517
517
  map {|r| [r.is_a?(RDF::Node) ? 1 : 0, ref_count(r), r]}.
518
518
  sort
519
519
 
520
+ add_debug "order_subjects: #{recursable.inspect}"
521
+
520
522
  subjects += recursable.map{|r| r.last}
521
523
  end
522
524
 
@@ -615,13 +617,10 @@ module RDF::RDFa
615
617
  get_curie(subject)
616
618
  end
617
619
 
618
- # See if there's a template for any of the types associated with this subject
619
- tmpl = (properties[RDF.type.to_s] || []).
620
- map do |type|
621
- haml_template[type] || (@options[:haml] && @options[:haml][type])
622
- end.
623
- compact.first
624
-
620
+ # See if there's a template based on the sorted concatenation of all types of this subject
621
+ # or any type of this subject
622
+ tmpl = find_template(subject)
623
+
625
624
  typeof = [properties.delete(RDF.type.to_s)].flatten.compact.map {|r| get_curie(r)}.join(" ")
626
625
  typeof = nil if typeof.empty?
627
626
 
@@ -629,7 +628,7 @@ module RDF::RDFa
629
628
  typeof ||= "" unless curie
630
629
  prop_list -= [RDF.type.to_s]
631
630
 
632
- add_debug "subject: found template in #{haml_template.keys.inspect}? #{(!tmpl.nil?).inspect}"
631
+ add_debug "subject: found template #{tmpl[:identifier] || tmpl.inspect}" if tmpl
633
632
  add_debug "subject: #{curie.inspect}, typeof: #{typeof.inspect}, props: #{prop_list.inspect}"
634
633
 
635
634
  # Render this subject
@@ -721,6 +720,8 @@ module RDF::RDFa
721
720
  else
722
721
  literal.to_s
723
722
  end
723
+ rescue
724
+ literal.to_s # When all else fails ...
724
725
  end
725
726
 
726
727
  # Haml rendering helper. Return an appropriate label for a resource.
@@ -808,7 +809,14 @@ module RDF::RDFa
808
809
 
809
810
  # Set the template to use within block
810
811
  def with_template(templ)
811
- old_template, @haml_template = @haml_template, templ
812
+ if templ
813
+ new_template = @options[:haml].
814
+ reject {|k,v| ![:subject, :property_value, :property_values, :rel].include?(k)}.
815
+ merge(templ || {})
816
+ old_template, @haml_template = @haml_template, new_template
817
+ else
818
+ old_template = @haml_template
819
+ end
812
820
 
813
821
  res = yield
814
822
  # Restore template
@@ -825,10 +833,10 @@ module RDF::RDFa
825
833
  # @return [String]
826
834
  # @raise [RDF::WriterError]
827
835
  def hamlify(template, locals = {})
836
+ add_debug "hamlify template: #{template}"
828
837
  template = haml_template[template] if template.is_a?(Symbol)
829
838
 
830
839
  template = template.align_left
831
- add_debug "hamlify template: #{template}"
832
840
  add_debug "hamlify locals: #{locals.inspect}"
833
841
 
834
842
  Haml::Engine.new(template, @options[:haml_options] || HAML_OPTIONS).render(self, locals) do |*args|
@@ -841,6 +849,14 @@ module RDF::RDFa
841
849
  "and locals #{locals.inspect}"
842
850
  end
843
851
 
852
+ ##
853
+ # Find a template appropriate for the subject.
854
+ # Override this method to provide templates based on attributes of a given subject
855
+ #
856
+ # @param [RDF::URI] subject
857
+ # @return [Hash] # return matched matched template
858
+ def find_template(subject); end
859
+
844
860
  # Mark a subject as done.
845
861
  def subject_done(subject)
846
862
  @serialized[subject] = true
@@ -3,6 +3,7 @@ module RDF::RDFa
3
3
  class Writer
4
4
  # The default set of HAML templates used for RDFa code generation
5
5
  BASE_HAML = {
6
+ :identifier => "base",
6
7
  # Document
7
8
  # Locals: language, title, profile, prefix, base, subjects
8
9
  # Yield: subjects.each
@@ -109,6 +110,7 @@ module RDF::RDFa
109
110
  # This version does not perform recursive object generation and does not attempt
110
111
  # to create human readable output.
111
112
  MIN_HAML = {
113
+ :identifier => "min",
112
114
  # Document
113
115
  # Locals: language, title, profile, prefix, base, subjects
114
116
  # Yield: subjects.each
@@ -167,6 +169,7 @@ module RDF::RDFa
167
169
  }
168
170
 
169
171
  DISTILLER_HAML = {
172
+ :identifier => "distiller",
170
173
  # Document
171
174
  # Locals: language, title, profile, prefix, base, subjects
172
175
  # Yield: subjects.each
metadata CHANGED
@@ -1,351 +1,214 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf-rdfa
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 65
4
5
  prerelease:
5
- version: 0.3.4.2
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 5
10
+ - 1
11
+ version: 0.3.5.1
6
12
  platform: ruby
7
13
  authors:
8
- - Gregg Kellogg
14
+ - Gregg
15
+ - Kellogg
9
16
  autorequire:
10
17
  bindir: bin
11
18
  cert_chain: []
12
19
 
13
- date: 2011-07-12 00:00:00 -07:00
14
- default_executable:
20
+ date: 2011-08-22 00:00:00 Z
15
21
  dependencies:
16
22
  - !ruby/object:Gem::Dependency
17
- name: addressable
23
+ name: rdf
24
+ prerelease: false
18
25
  requirement: &id001 !ruby/object:Gem::Requirement
19
26
  none: false
20
27
  requirements:
21
- - - "="
28
+ - - ">="
22
29
  - !ruby/object:Gem::Version
23
- version: 2.2.4
30
+ hash: 21
31
+ segments:
32
+ - 0
33
+ - 3
34
+ - 3
35
+ version: 0.3.3
24
36
  type: :runtime
25
- prerelease: false
26
37
  version_requirements: *id001
27
38
  - !ruby/object:Gem::Dependency
28
- name: rdf
39
+ name: haml
40
+ prerelease: false
29
41
  requirement: &id002 !ruby/object:Gem::Requirement
30
42
  none: false
31
43
  requirements:
32
44
  - - ">="
33
45
  - !ruby/object:Gem::Version
34
- version: "0"
46
+ hash: 7
47
+ segments:
48
+ - 3
49
+ - 0
50
+ - 0
51
+ version: 3.0.0
35
52
  type: :runtime
36
- prerelease: false
37
53
  version_requirements: *id002
38
54
  - !ruby/object:Gem::Dependency
39
- name: haml
55
+ name: nokogiri
56
+ prerelease: false
40
57
  requirement: &id003 !ruby/object:Gem::Requirement
41
58
  none: false
42
59
  requirements:
43
60
  - - ">="
44
61
  - !ruby/object:Gem::Version
45
- version: 3.0.0
62
+ hash: 15
63
+ segments:
64
+ - 1
65
+ - 4
66
+ - 4
67
+ version: 1.4.4
46
68
  type: :runtime
47
- prerelease: false
48
69
  version_requirements: *id003
49
70
  - !ruby/object:Gem::Dependency
50
- name: nokogiri
71
+ name: facets
72
+ prerelease: false
51
73
  requirement: &id004 !ruby/object:Gem::Requirement
52
74
  none: false
53
75
  requirements:
54
76
  - - ">="
55
77
  - !ruby/object:Gem::Version
56
- version: 1.3.3
78
+ hash: 41
79
+ segments:
80
+ - 2
81
+ - 9
82
+ - 1
83
+ version: 2.9.1
57
84
  type: :runtime
58
- prerelease: false
59
85
  version_requirements: *id004
60
86
  - !ruby/object:Gem::Dependency
61
- name: facets
87
+ name: spira
88
+ prerelease: false
62
89
  requirement: &id005 !ruby/object:Gem::Requirement
63
90
  none: false
64
91
  requirements:
65
92
  - - ">="
66
93
  - !ruby/object:Gem::Version
67
- version: 2.9.1
68
- type: :runtime
69
- prerelease: false
94
+ hash: 7
95
+ segments:
96
+ - 0
97
+ - 0
98
+ - 12
99
+ version: 0.0.12
100
+ type: :development
70
101
  version_requirements: *id005
71
102
  - !ruby/object:Gem::Dependency
72
- name: open-uri-cached
103
+ name: rspec
104
+ prerelease: false
73
105
  requirement: &id006 !ruby/object:Gem::Requirement
74
106
  none: false
75
107
  requirements:
76
108
  - - ">="
77
109
  - !ruby/object:Gem::Version
78
- version: 0.0.3
110
+ hash: 27
111
+ segments:
112
+ - 2
113
+ - 5
114
+ - 0
115
+ version: 2.5.0
79
116
  type: :development
80
- prerelease: false
81
117
  version_requirements: *id006
82
118
  - !ruby/object:Gem::Dependency
83
119
  name: rdf-spec
120
+ prerelease: false
84
121
  requirement: &id007 !ruby/object:Gem::Requirement
85
122
  none: false
86
123
  requirements:
87
124
  - - ">="
88
125
  - !ruby/object:Gem::Version
89
- version: "0"
126
+ hash: 23
127
+ segments:
128
+ - 0
129
+ - 3
130
+ - 2
131
+ version: 0.3.2
90
132
  type: :development
91
- prerelease: false
92
133
  version_requirements: *id007
93
- - !ruby/object:Gem::Dependency
94
- name: rdf-isomorphic
95
- requirement: &id008 !ruby/object:Gem::Requirement
96
- none: false
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- version: 0.3.4
101
- type: :development
102
- prerelease: false
103
- version_requirements: *id008
104
134
  - !ruby/object:Gem::Dependency
105
135
  name: rdf-n3
106
- requirement: &id009 !ruby/object:Gem::Requirement
107
- none: false
108
- requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
111
- version: 0.3.1
112
- type: :development
113
- prerelease: false
114
- version_requirements: *id009
115
- - !ruby/object:Gem::Dependency
116
- name: rspec
117
- requirement: &id010 !ruby/object:Gem::Requirement
118
- none: false
119
- requirements:
120
- - - ">="
121
- - !ruby/object:Gem::Version
122
- version: 2.1.0
123
- type: :development
124
- prerelease: false
125
- version_requirements: *id010
126
- - !ruby/object:Gem::Dependency
127
- name: sxp
128
- requirement: &id011 !ruby/object:Gem::Requirement
129
- none: false
130
- requirements:
131
- - - ">="
132
- - !ruby/object:Gem::Version
133
- version: "0"
134
- type: :development
135
- prerelease: false
136
- version_requirements: *id011
137
- - !ruby/object:Gem::Dependency
138
- name: sparql-algebra
139
- requirement: &id012 !ruby/object:Gem::Requirement
140
- none: false
141
- requirements:
142
- - - ">="
143
- - !ruby/object:Gem::Version
144
- version: "0"
145
- type: :development
146
- prerelease: false
147
- version_requirements: *id012
148
- - !ruby/object:Gem::Dependency
149
- name: sparql-grammar
150
- requirement: &id013 !ruby/object:Gem::Requirement
151
- none: false
152
- requirements:
153
- - - ">="
154
- - !ruby/object:Gem::Version
155
- version: "0"
156
- type: :development
157
- prerelease: false
158
- version_requirements: *id013
159
- - !ruby/object:Gem::Dependency
160
- name: spira
161
- requirement: &id014 !ruby/object:Gem::Requirement
162
- none: false
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: 0.0.12
167
- type: :development
168
- prerelease: false
169
- version_requirements: *id014
170
- - !ruby/object:Gem::Dependency
171
- name: yard
172
- requirement: &id015 !ruby/object:Gem::Requirement
173
- none: false
174
- requirements:
175
- - - ">="
176
- - !ruby/object:Gem::Version
177
- version: 0.6.4
178
- type: :development
179
136
  prerelease: false
180
- version_requirements: *id015
181
- - !ruby/object:Gem::Dependency
182
- name: rdf
183
- requirement: &id016 !ruby/object:Gem::Requirement
184
- none: false
185
- requirements:
186
- - - ">="
187
- - !ruby/object:Gem::Version
188
- version: 0.3.3
189
- type: :runtime
190
- prerelease: false
191
- version_requirements: *id016
192
- - !ruby/object:Gem::Dependency
193
- name: haml
194
- requirement: &id017 !ruby/object:Gem::Requirement
195
- none: false
196
- requirements:
197
- - - ">="
198
- - !ruby/object:Gem::Version
199
- version: 3.0.0
200
- type: :runtime
201
- prerelease: false
202
- version_requirements: *id017
203
- - !ruby/object:Gem::Dependency
204
- name: nokogiri
205
- requirement: &id018 !ruby/object:Gem::Requirement
206
- none: false
207
- requirements:
208
- - - ">="
209
- - !ruby/object:Gem::Version
210
- version: 1.4.4
211
- type: :runtime
212
- prerelease: false
213
- version_requirements: *id018
214
- - !ruby/object:Gem::Dependency
215
- name: facets
216
- requirement: &id019 !ruby/object:Gem::Requirement
217
- none: false
218
- requirements:
219
- - - ">="
220
- - !ruby/object:Gem::Version
221
- version: 2.9.1
222
- type: :runtime
223
- prerelease: false
224
- version_requirements: *id019
225
- - !ruby/object:Gem::Dependency
226
- name: spira
227
- requirement: &id020 !ruby/object:Gem::Requirement
228
- none: false
229
- requirements:
230
- - - ">="
231
- - !ruby/object:Gem::Version
232
- version: 0.0.12
233
- type: :development
234
- prerelease: false
235
- version_requirements: *id020
236
- - !ruby/object:Gem::Dependency
237
- name: rspec
238
- requirement: &id021 !ruby/object:Gem::Requirement
239
- none: false
240
- requirements:
241
- - - ">="
242
- - !ruby/object:Gem::Version
243
- version: 2.5.0
244
- type: :development
245
- prerelease: false
246
- version_requirements: *id021
247
- - !ruby/object:Gem::Dependency
248
- name: rdf-spec
249
- requirement: &id022 !ruby/object:Gem::Requirement
137
+ requirement: &id008 !ruby/object:Gem::Requirement
250
138
  none: false
251
139
  requirements:
252
140
  - - ">="
253
141
  - !ruby/object:Gem::Version
142
+ hash: 21
143
+ segments:
144
+ - 0
145
+ - 3
146
+ - 3
254
147
  version: 0.3.3
255
148
  type: :development
256
- prerelease: false
257
- version_requirements: *id022
149
+ version_requirements: *id008
258
150
  - !ruby/object:Gem::Dependency
259
151
  name: rdf-isomorphic
260
- requirement: &id023 !ruby/object:Gem::Requirement
152
+ prerelease: false
153
+ requirement: &id009 !ruby/object:Gem::Requirement
261
154
  none: false
262
155
  requirements:
263
156
  - - ">="
264
157
  - !ruby/object:Gem::Version
158
+ hash: 27
159
+ segments:
160
+ - 0
161
+ - 3
162
+ - 4
265
163
  version: 0.3.4
266
164
  type: :development
267
- prerelease: false
268
- version_requirements: *id023
165
+ version_requirements: *id009
269
166
  - !ruby/object:Gem::Dependency
270
167
  name: yard
271
- requirement: &id024 !ruby/object:Gem::Requirement
168
+ prerelease: false
169
+ requirement: &id010 !ruby/object:Gem::Requirement
272
170
  none: false
273
171
  requirements:
274
172
  - - ">="
275
173
  - !ruby/object:Gem::Version
276
- version: "0"
174
+ hash: 7
175
+ segments:
176
+ - 0
177
+ - 6
178
+ - 0
179
+ version: 0.6.0
277
180
  type: :development
278
- prerelease: false
279
- version_requirements: *id024
280
- description: " RDF::RDFa is an RDFa reader/writer for Ruby using the RDF.rb library suite.\n"
281
- email: gregg@kellogg-assoc.com
181
+ version_requirements: *id010
182
+ description: RDF::RDFa is an RDFa reader/writer for Ruby using the RDF.rb library suite.
183
+ email: public-rdf-ruby@w3.org
282
184
  executables: []
283
185
 
284
186
  extensions: []
285
187
 
286
- extra_rdoc_files:
287
- - AUTHORS
288
- - CONTRIBUTORS
289
- - History.md
290
- - README.md
188
+ extra_rdoc_files: []
189
+
291
190
  files:
292
- - .yardopts
293
191
  - AUTHORS
294
- - CONTRIBUTORS
295
- - Gemfile
296
- - History.md
297
192
  - README
298
- - README.md
299
- - Rakefile
300
193
  - UNLICENSE
301
194
  - VERSION
302
- - etc/basic.html
303
- - etc/foaf.html
304
- - etc/profile.html
305
- - etc/xhv.html
306
- - example-files/bb-test.rb
307
- - example-files/best-buy.html
308
- - example-files/data-view.xhtml
309
- - example-files/erdf_profile.html
310
- - example-files/gk-foaf.html
311
- - example-files/payswarm.html
312
- - example-files/payswarm.n3
313
- - example.rb
314
- - lib/rdf/.gitignore
315
- - lib/rdf/rdfa.rb
316
195
  - lib/rdf/rdfa/format.rb
317
196
  - lib/rdf/rdfa/patches/graph_properties.rb
318
197
  - lib/rdf/rdfa/patches/literal_hacks.rb
319
198
  - lib/rdf/rdfa/patches/nokogiri_hacks.rb
320
199
  - lib/rdf/rdfa/patches/string_hacks.rb
321
- - lib/rdf/rdfa/profile.rb
322
200
  - lib/rdf/rdfa/profile/xhtml.rb
323
201
  - lib/rdf/rdfa/profile/xml.rb
202
+ - lib/rdf/rdfa/profile.rb
324
203
  - lib/rdf/rdfa/reader.rb
325
204
  - lib/rdf/rdfa/version.rb
326
205
  - lib/rdf/rdfa/vocab.rb
327
- - lib/rdf/rdfa/writer.rb
328
206
  - lib/rdf/rdfa/writer/haml_templates.rb
329
- - pkg/.gitignore
330
- - rdf-rdfa.gemspec
331
- - script/console
332
- - script/intern_vocabulary
333
- - script/parse
334
- - script/tc
335
- - script/yard-to-rubyforge
336
- - spec/.gitignore
337
- - spec/literal_spec.rb
338
- - spec/matchers.rb
339
- - spec/profile_spec.rb
340
- - spec/reader_spec.rb
341
- - spec/spec.opts
342
- - spec/spec_helper.rb
343
- - spec/test_helper.rb
344
- - spec/writer_spec.rb
345
- has_rdoc: true
207
+ - lib/rdf/rdfa/writer.rb
208
+ - lib/rdf/rdfa.rb
346
209
  homepage: http://github.com/gkellogg/rdf-rdfa
347
- licenses: []
348
-
210
+ licenses:
211
+ - Public Domain
349
212
  post_install_message:
350
213
  rdoc_options: []
351
214
 
@@ -356,17 +219,25 @@ required_ruby_version: !ruby/object:Gem::Requirement
356
219
  requirements:
357
220
  - - ">="
358
221
  - !ruby/object:Gem::Version
359
- version: "0"
222
+ hash: 53
223
+ segments:
224
+ - 1
225
+ - 8
226
+ - 1
227
+ version: 1.8.1
360
228
  required_rubygems_version: !ruby/object:Gem::Requirement
361
229
  none: false
362
230
  requirements:
363
231
  - - ">="
364
232
  - !ruby/object:Gem::Version
233
+ hash: 3
234
+ segments:
235
+ - 0
365
236
  version: "0"
366
237
  requirements: []
367
238
 
368
- rubyforge_project:
369
- rubygems_version: 1.6.2
239
+ rubyforge_project: rdf-rdfa
240
+ rubygems_version: 1.8.6
370
241
  signing_key:
371
242
  specification_version: 3
372
243
  summary: RDFa reader/writer for RDF.rb.