rdf 1.1.17.1 → 1.99.0

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.
@@ -12,45 +12,17 @@ module RDF
12
12
  # The following vocabularies are pre-defined for your convenience:
13
13
  #
14
14
  # * {RDF} - Resource Description Framework (RDF)
15
- # * {RDF::CC} - Creative Commons (CC)
16
- # * {RDF::CERT} - W3 Authentication Certificate (CERT)
17
- # * {RDF::DC} - Dublin Core (DC)
18
- # * {RDF::DC11} - Dublin Core 1.1 (DC11) _deprecated_
19
- # * {RDF::DOAP} - Description of a Project (DOAP)
20
- # * {RDF::EXIF} - Exchangeable Image File Format (EXIF)
21
- # * {RDF::FOAF} - Friend of a Friend (FOAF)
22
- # * {RDF::GEO} - WGS84 Geo Positioning (GEO)
23
- # * {RDF::GR} - Good Relations
24
- # * {RDF::HT} - Hypertext Transfer Protocol (HTTP)
25
- # * {RDF::ICAL} - iCal
26
- # * {RDF::MA} - W3C Meda Annotations
27
- # * {RDF::OG} - FaceBook OpenGraph
28
15
  # * {RDF::OWL} - Web Ontology Language (OWL)
29
- # * {RDF::PROV} - W3C Provenance Ontology
30
16
  # * {RDF::RDFS} - RDF Schema (RDFS)
31
- # * {RDF::RSA} - W3 RSA Keys (RSA)
32
- # * {RDF::RSS} - RDF Site Summary (RSS)
33
- # * {RDF::SCHEMA} - Schema.org
34
- # * {RDF::SIOC} - Semantically-Interlinked Online Communities (SIOC)
35
- # * {RDF::SKOS} - Simple Knowledge Organization System (SKOS)
36
- # * {RDF::SKOSXL} - SKOS Simple Knowledge Organization System eXtension for Labels (SKOS-XL)
37
- # * {RDF::V} - Data Vocabulary
38
- # * {RDF::VCARD} - vCard vocabulary
39
- # * {RDF::VOID} - Vocabulary of Interlinked Datasets (VoID)
40
- # * {RDF::WDRS} - Protocol for Web Description Resources (POWDER)
41
- # * {RDF::WOT} - Web of Trust (WOT)
42
- # * {RDF::XHTML} - Extensible HyperText Markup Language (XHTML)
43
- # * {RDF::XHV} - W3C XHTML Vocabulary
44
17
  # * {RDF::XSD} - XML Schema (XSD)
45
18
  #
19
+ # Other vocabularies are defined in the [rdf-vocab](http://rubygems.org/gems/rdf-vocab) gem
20
+ #
46
21
  # @example Using pre-defined RDF vocabularies
47
22
  # include RDF
48
23
  #
49
- # DC.title #=> RDF::URI("http://purl.org/dc/terms/title")
50
- # FOAF.knows #=> RDF::URI("http://xmlns.com/foaf/0.1/knows")
51
24
  # RDF.type #=> RDF::URI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type")
52
25
  # RDFS.seeAlso #=> RDF::URI("http://www.w3.org/2000/01/rdf-schema#seeAlso")
53
- # RSS.title #=> RDF::URI("http://purl.org/rss/1.0/title")
54
26
  # OWL.sameAs #=> RDF::URI("http://www.w3.org/2002/07/owl#sameAs")
55
27
  # XSD.dateTime #=> RDF::URI("http://www.w3.org/2001/XMLSchema#dateTime")
56
28
  #
@@ -143,7 +115,7 @@ module RDF
143
115
  Term.intern("#{self}property", attributes: {label: "property", vocab: self})
144
116
  else
145
117
  name, options = args
146
- options = {:label => name.to_s, vocab: self}.merge(options || {})
118
+ options = {label: name.to_s, vocab: self}.merge(options || {})
147
119
  uri_str = [to_s, name.to_s].join('')
148
120
  Term.cache.delete(uri_str) # Clear any previous entry
149
121
  prop = Term.intern(uri_str, attributes: options)
@@ -247,17 +219,17 @@ module RDF
247
219
 
248
220
  ##
249
221
  # @return [String] The label for the named property
250
- # @deprecated Use {RDF::Vocabulary::Term#label}
222
+ # @deprecated Use {RDF::Vocabulary::Term#label} instead.
251
223
  def label_for(name)
252
- warn "[DEPRECATION] `Vocabulary.label_for is deprecated. Please use Vocabulary::Term#label instead."
224
+ warn "[DEPRECATION] `Vocabulary.label_for is deprecated. Please use Vocabulary::Term#label instead. Called from #{Gem.location_of_caller.join(':')}"
253
225
  self[name].label || ''
254
226
  end
255
227
 
256
228
  ##
257
229
  # @return [String] The comment for the named property
258
- # @deprecated Use {RDF::Vocabulary::Term#comment}
230
+ # @deprecated Use {RDF::Vocabulary::Term#comment} instead.
259
231
  def comment_for(name)
260
- warn "[DEPRECATION] `Vocabulary.comment_for is deprecated. Please use Vocabulary::Term#comment instead."
232
+ warn "[DEPRECATION] `Vocabulary.comment_for is deprecated. Please use Vocabulary::Term#comment instead. Called from #{Gem.location_of_caller.join(':')}"
261
233
  self[name].comment || ''
262
234
  end
263
235
 
@@ -315,7 +287,7 @@ module RDF
315
287
  # @option options [URI, #to_s] :location
316
288
  # Location from which to load the vocabulary, if not from `uri`.
317
289
  # @option options [Array<Symbol>, Hash{Symbol => Hash}] :extra
318
- # Extra terms to add to the vocabulary. In the first form, it is an array of symbols, for which terms are created. In the second, it is a Hash mapping symbols to property attributes, as described in {#property}.
290
+ # Extra terms to add to the vocabulary. In the first form, it is an array of symbols, for which terms are created. In the second, it is a Hash mapping symbols to property attributes, as described in {RDF::Vocabulary.property}.
319
291
  # @return [RDF::Vocabulary] the loaded vocabulary
320
292
  def load(uri, options = {})
321
293
  source = options.fetch(:location, uri)
@@ -508,8 +480,39 @@ module RDF
508
480
 
509
481
  # A Vocabulary Term is a URI that can also act as an {Enumerable} to generate the RDF definition of vocabulary terms as defined within the vocabulary definition.
510
482
  class Term < RDF::URI
511
- # Attributes of this vocabulary term, used for finding `label` and `comment` and to serialize the term back to RDF.
512
- # @return [Hash{Symbol,Resource => Term, #to_s}]
483
+ # @!method comment
484
+ # `rdfs:comment` accessor
485
+ # @return [String]
486
+ # @!method label
487
+ # `rdfs:label` accessor
488
+ # @return [String]
489
+ # @!method type
490
+ # `rdf:type` accessor
491
+ # @return [RDF::URI]
492
+ # @!method subClassOf
493
+ # `rdfs:subClassOf` accessor
494
+ # @return [RDF::URI]
495
+ # @!method subPropertyOf
496
+ # `rdfs:subPropertyOf` accessor
497
+ # @return [RDF::URI]
498
+ # @!method domain
499
+ # `rdfs:domain` accessor
500
+ # @return [RDF::URI]
501
+ # @!method range
502
+ # `rdfs:range` accessor
503
+ # @return [RDF::URI]
504
+ # @!method inverseOf
505
+ # `owl:inverseOf` accessor
506
+ # @return [RDF::URI]
507
+ # @!method domainIncludes
508
+ # `schema:domainIncludes` accessor
509
+ # @return [RDF::URI]
510
+ # @!method rangeIncludes
511
+ # `schema:rangeIncludes` accoessor
512
+ # @return [RDF::URI]
513
+ # @!attribute [rw] attributes
514
+ # Attributes of this vocabulary term, used for finding `label` and `comment` and to serialize the term back to RDF.
515
+ # @return [Hash{Symbol,Resource => Term, #to_s}]
513
516
  attr_accessor :attributes
514
517
 
515
518
  ##
@@ -680,38 +683,18 @@ module RDF
680
683
  @attributes.has_key?(method) || super
681
684
  end
682
685
 
683
- # Accessor for {#domainIncludes}
686
+ # Accessor for `domainIncludes`
684
687
  # @return [RDF::URI]
685
688
  def domain_includes
686
689
  Array(@attributes[:domainIncludes]).map {|v| RDF::Vocabulary.expand_pname(v)}
687
690
  end
688
691
 
689
- # Accessor for {#rangeIncludes}
692
+ # Accessor for `rangeIncludes`
690
693
  # @return [RDF::URI]
691
694
  def range_includes
692
695
  Array(@attributes[:rangeIncludes]).map {|v| RDF::Vocabulary.expand_pname(v)}
693
696
  end
694
697
 
695
- # @!method comment
696
- # @return [String]
697
- # @!method label
698
- # @return [String]
699
- # @!method type
700
- # @return [RDF::URI]
701
- # @!method subClassOf
702
- # @return [RDF::URI]
703
- # @!method subPropertyOf
704
- # @return [RDF::URI]
705
- # @!method domain
706
- # @return [RDF::URI]
707
- # @!method range
708
- # @return [RDF::URI]
709
- # @!method inverseOf
710
- # @return [RDF::URI]
711
- # @!method domainIncludes
712
- # @return [RDF::URI]
713
- # @!method rangeIncludes
714
- # @return [RDF::URI]
715
698
  protected
716
699
  # Implement accessor to symbol attributes
717
700
  def method_missing(method, *args, &block)
data/lib/rdf/writer.rb CHANGED
@@ -12,9 +12,9 @@ module RDF
12
12
  # @example Obtaining an RDF writer class
13
13
  # RDF::Writer.for(:ntriples) #=> RDF::NTriples::Writer
14
14
  # RDF::Writer.for("spec/data/output.nt")
15
- # RDF::Writer.for(:file_name => "spec/data/output.nt")
16
- # RDF::Writer.for(:file_extension => "nt")
17
- # RDF::Writer.for(:content_type => "text/plain")
15
+ # RDF::Writer.for(file_name: "spec/data/output.nt")
16
+ # RDF::Writer.for(file_extension: "nt")
17
+ # RDF::Writer.for(content_type: "application/n-triples")
18
18
  #
19
19
  # @example Instantiating an RDF writer class
20
20
  # RDF::Writer.for(:ntriples).new($stdout) { |writer| ... }
@@ -78,7 +78,7 @@ module RDF
78
78
  #
79
79
  # @return [Class]
80
80
  def self.for(options = {})
81
- options = options.merge(:has_writer => true) if options.is_a?(Hash)
81
+ options = options.merge(has_writer: true) if options.is_a?(Hash)
82
82
  if format = self.format || Format.for(options)
83
83
  format.writer
84
84
  end
@@ -115,7 +115,7 @@ module RDF
115
115
  if io.is_a?(String)
116
116
  io = File.open(io, 'w')
117
117
  elsif io.respond_to?(:external_encoding) && io.external_encoding
118
- options = {:encoding => io.external_encoding}.merge(options)
118
+ options = {encoding: io.external_encoding}.merge(options)
119
119
  end
120
120
  io.set_encoding(options[:encoding]) if io.respond_to?(:set_encoding) && options[:encoding]
121
121
  method = data.respond_to?(:each_statement) ? :each_statement : :each
@@ -206,7 +206,7 @@ module RDF
206
206
  # the base URI to use when constructing relative URIs (not supported
207
207
  # by all writers)
208
208
  # @option options [Boolean] :unique_bnodes (false)
209
- # Use unique {Node} identifiers, defaults to using the identifier which the node was originall initialized with (if any). Implementations should ensure that Nodes are serialized using a unique representation independent of any identifier used when creating the node. See {NTriples#format_node}
209
+ # Use unique {Node} identifiers, defaults to using the identifier which the node was originall initialized with (if any). Implementations should ensure that Nodes are serialized using a unique representation independent of any identifier used when creating the node. See {NTriples::Writer#format_node}
210
210
  # @yield [writer] `self`
211
211
  # @yieldparam [RDF::Writer] writer
212
212
  # @yieldreturn [void]
@@ -260,7 +260,7 @@ module RDF
260
260
  #
261
261
  # @example
262
262
  # writer.prefixes = {
263
- # :dc => RDF::URI('http://purl.org/dc/terms/'),
263
+ # dc: RDF::URI('http://purl.org/dc/terms/'),
264
264
  # }
265
265
  #
266
266
  # @param [Hash{Symbol => RDF::URI}] prefixes
@@ -361,9 +361,9 @@ module RDF
361
361
  ##
362
362
  # @param [RDF::Graph] graph
363
363
  # @return [void] `self`
364
- # @deprecated Please use {RDF::Writable#insert_graph} instead
364
+ # @deprecated Use {RDF::Writable#insert_graph} instead .
365
365
  def write_graph(graph)
366
- warn "[DEPRECATION] `Writer#graph_write is deprecated. Please use RDF::Writable#insert instead."
366
+ warn "[DEPRECATION] `Writer#graph_write is deprecated. Please use RDF::Writable#insert instead. Called from #{Gem.location_of_caller.join(':')}"
367
367
  graph.each_triple { |*triple| write_triple(*triple) }
368
368
  self
369
369
  end
@@ -371,9 +371,9 @@ module RDF
371
371
  ##
372
372
  # @param [Array<RDF::Statement>] statements
373
373
  # @return [void] `self`
374
- # @deprecated replace by `RDF::Writable#insert`
374
+ # @deprecated Use {RDF::Writable#insert} instead.
375
375
  def write_statements(*statements)
376
- warn "[DEPRECATION] `Writer#write_statements is deprecated. Please use RDF::Writable#insert instead."
376
+ warn "[DEPRECATION] `Writer#write_statements is deprecated. Please use RDF::Writable#insert instead. Called from #{Gem.location_of_caller.join(':')}"
377
377
  statements.each { |statement| write_statement(statement) }
378
378
  self
379
379
  end
@@ -384,6 +384,7 @@ module RDF
384
384
  # @raise [RDF::WriterError] if validating and attempting to write an invalid {RDF::Statement} or if canonicalizing a statement which cannot be canonicalized.
385
385
  def write_statement(statement)
386
386
  statement = statement.canonicalize! if canonicalize?
387
+ raise RDF::WriterError, "Statement #{statement.inspect} is incomplete" if statement.incomplete?
387
388
  raise RDF::WriterError, "Statement #{statement.inspect} is invalid" if validate? && statement.invalid?
388
389
  write_triple(*statement.to_triple)
389
390
  self
@@ -427,7 +428,16 @@ module RDF
427
428
  else nil
428
429
  end
429
430
  end
430
- alias_method :format_value, :format_term # @deprecated
431
+
432
+ ##
433
+ # @param [RDF::Term] term
434
+ # @return [String]
435
+ # @since 0.3.0
436
+ # @deprecated Use {#format_term} instead
437
+ def format_value(term, options = {})
438
+ warn "[DEPRECATION] Writer#format_value is being replaced with Writer#format_term in RDF.rb 2.0. Called from #{Gem.location_of_caller.join(':')}"
439
+ format_term(term, options)
440
+ end
431
441
 
432
442
  ##
433
443
  # @param [RDF::Node] value
data/lib/rdf.rb CHANGED
@@ -55,7 +55,20 @@ module RDF
55
55
  autoload :Vocabulary, 'rdf/vocabulary'
56
56
  autoload :StrictVocabulary, 'rdf/vocabulary'
57
57
  VOCABS = Dir.glob(File.join(File.dirname(__FILE__), 'rdf', 'vocab', '*.rb')).map { |f| File.basename(f)[0...-(File.extname(f).size)].to_sym } rescue []
58
- VOCABS.each { |v| autoload v.to_s.upcase.to_sym, "rdf/vocab/#{v}" unless v == :rdf }
58
+
59
+ # Use const_missing instead of autoload to load most vocabularies so we can provide deprecation messages
60
+ def self.const_missing(constant)
61
+ if VOCABS.include?(constant.to_s.downcase.to_sym)
62
+ warn %([DEPRECATION] the #{constant} vocabulary will be moved to the rdf-vocab gem
63
+ for the RDF.rb 2.0 release. Use as RDF::Vocab::#{constant}, or include RDF::Vocab in the RDF module.
64
+ Called from #{Gem.location_of_caller.join(':')}
65
+ ).gsub(/^\s+/, '') unless [:OWL, :RDFS, :RDFV, :XSD].include?(constant)
66
+ require "rdf/vocab/#{constant.to_s.downcase}"
67
+ const_get(constant)
68
+ else
69
+ super
70
+ end
71
+ end
59
72
 
60
73
  # Utilities
61
74
  autoload :Util, 'rdf/util'
@@ -152,7 +165,9 @@ module RDF
152
165
  # @option options [RDF::URI] :predicate (nil)
153
166
  # @option options [RDF::Term] :object (nil)
154
167
  # @option options [RDF::Resource] :context (nil)
155
- # Note, in RDF 1.1, a context MUST be an IRI.
168
+ # Alias for :graph_name, :context is deprecated in RDF.rb.
169
+ # @option options [RDF::Resource] :graph_name (nil)
170
+ # Note, a graph_name MUST be an IRI or BNode.
156
171
  # @return [RDF::Statement]
157
172
  #
158
173
  # @overload Statement(subject, predicate, object, options = {})
@@ -160,7 +175,7 @@ module RDF
160
175
  # @param [RDF::URI] predicate
161
176
  # @param [RDF::Term] object
162
177
  # @param [Hash{Symbol => Object}] options
163
- # @option options [RDF::Resource] :context (nil)
178
+ # @option options [RDF::Resource] :graph_name (nil)
164
179
  # @return [RDF::Statement]
165
180
  #
166
181
  def self.Statement(*args)
@@ -203,7 +218,7 @@ module RDF
203
218
  end
204
219
 
205
220
  ##
206
- # Delegate other methods to RDF::RDF
221
+ # Delegate other methods to RDF::RDFV
207
222
  def self.method_missing(property, *args, &block)
208
223
  if args.empty?
209
224
  # Special-case rdf:_n for all integers
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.17.1
4
+ version: 1.99.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arto Bendiken
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-10-09 00:00:00.000000000 Z
13
+ date: 2015-10-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: link_header
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.1'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rdf-vocab
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.8'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.8'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rdf-xsd
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -128,14 +142,14 @@ dependencies:
128
142
  requirements:
129
143
  - - "~>"
130
144
  - !ruby/object:Gem::Version
131
- version: 3.2.0
145
+ version: '3.0'
132
146
  type: :development
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
150
  - - "~>"
137
151
  - !ruby/object:Gem::Version
138
- version: 3.2.0
152
+ version: '3.0'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: rspec-its
141
155
  requirement: !ruby/object:Gem::Requirement
@@ -333,7 +347,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
333
347
  version: '0'
334
348
  requirements: []
335
349
  rubyforge_project: rdf
336
- rubygems_version: 2.4.7
350
+ rubygems_version: 2.4.5.1
337
351
  signing_key:
338
352
  specification_version: 4
339
353
  summary: A Ruby library for working with Resource Description Framework (RDF) data.
OSZAR »