rdf-microdata 2.0.1 → 2.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1d1b0be6be75b9604495e5571840eae3d760b5c
4
- data.tar.gz: 72ea12e35779e10447eabd3965238533e892816b
3
+ metadata.gz: e67c356f5d9c16989fec6fdbffc268aaac86580b
4
+ data.tar.gz: ad36ebdb564304d87628944c0a68e2047c8f1b83
5
5
  SHA512:
6
- metadata.gz: 1bb225e865fe2e48b4606d67ccb04f5bce62b4dfa30c5a29d99217e4007ab290f273725eedf1682cb9d8e3e3a9facc2df4de6c1b8f22014d0bab951214a97967
7
- data.tar.gz: 0f8cad8716484382a1b0286d66245698c37d8e4e81456d2cc3a0018be1e23fe13ff4875e0bf598a9df94359a3ae24547db14913571c69011fc0964cd40f94071
6
+ metadata.gz: 12aac445519aeca33f567dcde2d0f94dbfa7302601802e50dd8294e2d41739d9525ec5bd4e7b0ca86e5779cdad2a3630bb4d96b058c98cbc42ddc811a39a686d
7
+ data.tar.gz: a4136789520f57273e147f1b01e934f99efc129d242766ca4005478448d64955af0b2af6718766d932ee49cddf10684992f4db25ebe6b261c9d97eb5cd38005d
data/README CHANGED
@@ -30,12 +30,12 @@ The parser uses a build-in version of the [Microdata RDF][] registry.
30
30
  ### Reading RDF data in the Microdata format
31
31
 
32
32
  require 'rdf/microdata'
33
- graph = RDF::Graph.load("etc/doap.html", :format => :microdata)
33
+ graph = RDF::Graph.load("etc/doap.html", format: :microdata)
34
34
 
35
35
  ### Reading using content-negotation
36
36
 
37
37
  require 'rdf/microdata'
38
- graph = RDF::Graph.load("etc/doap.html", :content_type => "text/html")
38
+ graph = RDF::Graph.load("etc/doap.html", content_type: "text/html")
39
39
 
40
40
  ## Note
41
41
  This spec is based on the W3C HTML Data Task Force specification and does not support
@@ -97,7 +97,7 @@ see <http://unlicense.org/> or the accompanying {file:UNLICENSE} file.
97
97
  * <http://github.com/ruby-rdf/rdf-microdata>
98
98
  * <http://lists.w3.org/Archives/Public/public-rdf-ruby/>
99
99
 
100
- [RDF.rb]: http://rdf.rubyforge.org/
100
+ [RDF.rb]: https://github.com/ruby-rdf/rdf
101
101
  [YARD]: http://yardoc.org/
102
102
  [YARD-GS]: http://rubydoc.info/docs/yard/file/docs/GettingStarted.md
103
103
  [PDD]: http://lists.w3.org/Archives/Public/public-rdf-ruby/2010May/0013.html
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.1
1
+ 2.0.2
@@ -31,9 +31,9 @@ module RDF::Microdata
31
31
 
32
32
  repo = owl_entailment(repo)
33
33
 
34
- # Return graph with default context
34
+ # Return graph with default graph
35
35
  graph = RDF::Graph.new
36
- repo.statements.each {|st| graph << st if st.context.nil?}
36
+ repo.statements.each {|st| graph << st}
37
37
  graph
38
38
  end
39
39
 
@@ -83,12 +83,12 @@ module RDF::Microdata
83
83
  end
84
84
  end
85
85
 
86
- def antecedent(subject, prediate, object, context = nil)
87
- antecedents << RDF::Query::Pattern.new(subject, prediate, object, :context => context)
86
+ def antecedent(subject, prediate, object)
87
+ antecedents << RDF::Query::Pattern.new(subject, prediate, object)
88
88
  end
89
89
 
90
- def consequent(subject, prediate, object, context = nil)
91
- consequents << RDF::Query::Pattern.new(subject, prediate, object, :context => context)
90
+ def consequent(subject, prediate, object)
91
+ consequents << RDF::Query::Pattern.new(subject, prediate, object)
92
92
  end
93
93
 
94
94
  ##
@@ -102,7 +102,7 @@ module RDF::Microdata
102
102
  nodes = {}
103
103
  consequents.each do |consequent|
104
104
  terms = {}
105
- [:subject, :predicate, :object, :context].each do |r|
105
+ [:subject, :predicate, :object].each do |r|
106
106
  terms[r] = case o = consequent.send(r)
107
107
  when RDF::Node then nodes[o] ||= RDF::Node.new
108
108
  when RDF::Query::Variable then solution[o]
@@ -13,7 +13,7 @@ module RDF::Microdata
13
13
  # RDF::Format.for(:microdata) #=> RDF::Microdata::Format
14
14
  # RDF::Format.for("etc/foaf.html")
15
15
  # RDF::Format.for(:file_name => "etc/foaf.html")
16
- # RDF::Format.for(:file_extension => "html")
16
+ # RDF::Format.for(file_extension: "html")
17
17
  # RDF::Format.for(:content_type => "text/html")
18
18
  #
19
19
  # @example Obtaining serialization format MIME types
@@ -26,7 +26,7 @@ module RDF::Microdata
26
26
  # Only define content type if RDFa is not available.
27
27
  # The Microdata processor will be launched from there
28
28
  # otherwise.
29
- content_type 'text/html', :extension => :html unless RDF::Format.for(:rdfa)
29
+ content_type 'text/html', extension: :html unless RDF::Format.for(:rdfa)
30
30
  reader { RDF::Microdata::Reader }
31
31
 
32
32
  ##
@@ -23,6 +23,11 @@ module RDF::Microdata
23
23
  # @return [Module] Returns the HTML implementation module for this reader instance.
24
24
  attr_reader :implementation
25
25
 
26
+ ##
27
+ # Accumulated errors found during processing
28
+ # @return [Array<String>]
29
+ attr_reader :errors
30
+
26
31
  ##
27
32
  # Returns the base URI determined by this reader.
28
33
  #
@@ -158,6 +163,8 @@ module RDF::Microdata
158
163
  # @option options [#to_s] :base_uri (nil)
159
164
  # the base URI to use when resolving relative URIs
160
165
  # @option options [#to_s] :registry
166
+ # @option options [Array] :errors
167
+ # array for placing errors found when parsing
161
168
  # @option options [Array] :debug
162
169
  # Array to place debug messages
163
170
  # @return [reader]
@@ -167,6 +174,8 @@ module RDF::Microdata
167
174
  # @raise [Error] Raises `RDF::ReaderError` when validating
168
175
  def initialize(input = $stdin, options = {}, &block)
169
176
  super do
177
+ @errors = @options[:errors]
178
+ @warnings = @options[:warnings]
170
179
  @debug = options[:debug]
171
180
 
172
181
  @library = :nokogiri
@@ -266,6 +275,7 @@ module RDF::Microdata
266
275
  end
267
276
 
268
277
  def add_error(node, message)
278
+ @errors << "#{node_path(node)}: #{message}" if @errors
269
279
  add_debug(node, message)
270
280
  raise RDF::ReaderError, message if validate?
271
281
  end
@@ -303,7 +313,7 @@ module RDF::Microdata
303
313
  ec = {
304
314
  :memory => {},
305
315
  :current_type => nil,
306
- :current_vocabulary => nil,
316
+ current_vocabulary: nil,
307
317
  :document_base => base,
308
318
  }
309
319
  # 1) For each element that is also a top-level item, Generate the triples for that item using the evaluation context.
@@ -371,7 +381,7 @@ module RDF::Microdata
371
381
  element.attribute('itemprop').to_s.split(' ').compact.each do |name|
372
382
  add_debug(item) {"gentrips(9.1): name=#{name.inspect}, type=#{type}"}
373
383
  # 9.1.1) Let context be a copy of evaluation context with current type set to type and current vocabulary set to vocab.
374
- ec_new = ec.merge({:current_type => type, :current_vocabulary => vocab})
384
+ ec_new = ec.merge({current_type: type, current_vocabulary: vocab})
375
385
 
376
386
  # 9.1.2) Let predicate be the result of generate predicate URI using context and name. Update context by setting current name to predicate.
377
387
  predicate = vocab.predicateURI(name, ec_new)
@@ -405,7 +415,7 @@ module RDF::Microdata
405
415
  element.attribute('itemprop-reverse').to_s.split(' ').compact.each do |name|
406
416
  add_debug(item) {"gentrips(10.1): name=#{name.inspect}"}
407
417
  # 10.1.1) Let context be a copy of evaluation context with current type set to type and current vocabulary set to vocab.
408
- ec_new = ec.merge({:current_type => type, :current_vocabulary => vocab})
418
+ ec_new = ec.merge({current_type: type, current_vocabulary: vocab})
409
419
 
410
420
  # 10.1.2) Let predicate be the result of generate predicate URI using context and name. Update context by setting current name to predicate.
411
421
  predicate = vocab.predicateURI(name, ec_new)
@@ -483,9 +493,9 @@ module RDF::Microdata
483
493
  # To collect all the elements in the item root, the user agent must run these steps. They return a list of elements.
484
494
  #
485
495
  # @param [Nokogiri::XML::Element] root
486
- # @return Array<Nokogiri::XML::Element>]
496
+ # @return [Array<Nokogiri::XML::Element>]
487
497
  # Resultant elements and error count
488
- # @raise CrawlFailure on element recursion
498
+ # @raise [CrawlFailure] on element recursion
489
499
  def elements_in_item(root)
490
500
  # Let results and pending be empty lists of elements.
491
501
  # Let errors be zero.
@@ -531,7 +541,7 @@ module RDF::Microdata
531
541
  when element.has_attribute?('itemscope')
532
542
  {}
533
543
  when element.name == 'meta'
534
- RDF::Literal.new(element.attribute('content').to_s, :language => element.language)
544
+ RDF::Literal.new(element.attribute('content').to_s, language: element.language)
535
545
  when %w(data meter).include?(element.name) && element.attribute('value')
536
546
  # Lexically scan value and assign appropriate type, otherwise, leave untyped
537
547
  v = element.attribute('value').to_s
@@ -552,9 +562,9 @@ module RDF::Microdata
552
562
  datatype = %w(Date Time DateTime Duration).map {|t| RDF::Literal.const_get(t)}.detect do |dt|
553
563
  v.match(dt::GRAMMAR)
554
564
  end || RDF::Literal
555
- datatype.new(v, :language => element.language)
565
+ datatype.new(v, language: element.language)
556
566
  else
557
- RDF::Literal.new(element.inner_text, :language => element.language)
567
+ RDF::Literal.new(element.inner_text, language: element.language)
558
568
  end
559
569
  add_debug(element) {" #{value.inspect}"}
560
570
  value
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf-microdata
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregg
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-04-02 00:00:00.000000000 Z
12
+ date: 2015-10-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rdf
@@ -276,7 +276,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
276
276
  version: '0'
277
277
  requirements: []
278
278
  rubyforge_project: rdf-microdata
279
- rubygems_version: 2.4.3
279
+ rubygems_version: 2.4.5.1
280
280
  signing_key:
281
281
  specification_version: 4
282
282
  summary: Microdata reader for Ruby.