rdf 1.1.1.1 → 1.1.2.1

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: 5448021019037400ca786a49c0b105907862992b
4
- data.tar.gz: ae25e3800b87b2462f0c869da53c138e75a2fe95
3
+ metadata.gz: b2620eff975a3e794371b52facc72c8c343b3a43
4
+ data.tar.gz: 21a6349cc1781e917feb435bb5ce3386e9a7749d
5
5
  SHA512:
6
- metadata.gz: ed70ec90b2d41a22fd70c688f6c665fa39450fc39b5803a9acc5383d126471d3232bcaa22350d07108c5559252e7b6f87f4325ed1067c303d6af53078efaaadd
7
- data.tar.gz: 98a7ee7cc084493f7bf8fae73d32a8b334dc620262d30e6d96668aaee6188919f39e071dc791a76d80ee4bcacdb340c4c81ee27a58ea771107bd454ddd6bdf28
6
+ metadata.gz: 98fa047d2310247ddd4b0f5f68a2555962091d9b5167ddd7186fe6e3b0600fdd014f276d1c93aa3b1813eb2a41776854b5b89ef1eae617323094bc6d99b59042
7
+ data.tar.gz: 23be85cc9a6c6e134d976899c0412be6b6f0381ec2d9d0db980456a64c13b6b516b4872e2ec57a0796430454ea54dc9beba1f8a4446c6172822e9d0d4e36ce6b
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.1.1
1
+ 1.1.2.1
@@ -33,16 +33,50 @@ module RDF
33
33
  ##
34
34
  # Initializes a newly-constructed list.
35
35
  #
36
- # @param [RDF::Resource] subject
37
- # @param [RDF::Graph] graph
38
- # @param [Array<RDF::Term>] values
39
- # @yield [list]
40
- # @yieldparam [RDF::List] list
36
+ # Instantiates a new list based at `subject`, which **should** be an RDF::Node. List may be initialized using passed `values`.
37
+ #
38
+ # If a `values` initializer is set with an empty list, `subject`
39
+ # will be used as the first element in the list. Otherwise,
40
+ # if the list is not empty, `subject` identifies the first element
41
+ # of the list to which `values` are prepended yielding a new `subject`.
42
+ # Otherwise, if there are no initial `values`, and `subject` does
43
+ # not identify an existing list in `graph`, the list remains
44
+ # identified by `subject`, but will be invalid.
45
+ #
46
+ # @overload initialize(subject = nil, graph = nil, values = nil, &block)
47
+ # @param [RDF::URI] subject
48
+ # @param [RDF::Graph] graph
49
+ # @param [Array<RDF::Term>] values
50
+ # Any values which are not terms are coerced to `RDF::Literal`.
51
+ # @yield [list]
52
+ # @yieldparam [RDF::List] list
53
+ # @deprecated Subject should be an {RDF::Node}, not a {RDF::URI}. A
54
+ # future release will remove support for URI subjects
55
+ # @overload initialize(subject = nil, graph = nil, values = nil, &block)
56
+ # @param [RDF::Node] subject (RDF.nil)
57
+ # @param [RDF::Graph] graph (RDF::Graph.new)
58
+ # @param [Array<RDF::Term>] values
59
+ # Any values which are not terms are coerced to `RDF::Literal`.
60
+ # @yield [list]
61
+ # @yieldparam [RDF::List] list
41
62
  def initialize(subject = nil, graph = nil, values = nil, &block)
42
63
  @subject = subject || RDF.nil
43
64
  @graph = graph || RDF::Graph.new
44
-
45
- unless Array(values).empty?
65
+ is_empty = @graph.query(:subject => subject, :predicate => RDF.first).empty?
66
+
67
+ if subject && is_empty
68
+ # An empty list with explicit subject and value initializers
69
+ @subject = RDF.nil
70
+ first, *values = Array(values)
71
+ if first
72
+ # Intantiate the list from values, and insert the first value using subject.
73
+ values.reverse_each {|value| self.unshift(value)}
74
+ graph.insert RDF::Statement(subject, RDF.first, first)
75
+ graph.insert RDF::Statement(subject, RDF.rest, @subject)
76
+ end
77
+ @subject = subject
78
+ else
79
+ # Otherwise, prepend any values, which resets @subject
46
80
  Array(values).reverse_each {|value| self.unshift(value)}
47
81
  end
48
82
 
@@ -211,14 +245,15 @@ module RDF
211
245
  # @example
212
246
  # RDF::List[].unshift(1).unshift(2).unshift(3) #=> RDF::List[3, 2, 1]
213
247
  #
214
- # @param [RDF::Term] value
248
+ # @param [RDF::Term, Array<RDF::Term>] value
249
+ # A non-RDF::Term is coerced to a Literal
215
250
  # @return [RDF::List]
216
251
  # @see http://www.ruby-doc.org/core-1.9.3/Array.html#method-i-unshift
217
252
  #
218
253
  def unshift(value)
219
254
  value = case value
220
255
  when nil then RDF.nil
221
- when RDF::Value then value
256
+ when RDF::Term then value
222
257
  when Array then RDF::List.new(nil, graph, value)
223
258
  else value
224
259
  end
@@ -57,6 +57,7 @@ module RDF
57
57
  # @option options [RDF::Resource] :subject (nil)
58
58
  # @option options [RDF::URI] :predicate (nil)
59
59
  # @option options [RDF::Term] :object (nil)
60
+ # if not an `RDF::Term`, it is coerced to `RDF::Literal`.
60
61
  # @option options [RDF::Resource] :context (nil)
61
62
  # Note, in RDF 1.1, a context MUST be an IRI.
62
63
  # @return [RDF::Statement]
@@ -65,6 +66,7 @@ module RDF
65
66
  # @param [RDF::Resource] subject
66
67
  # @param [RDF::URI] predicate
67
68
  # @param [RDF::Term] object
69
+ # if not an `RDF::Term`, it is coerced to `RDF::Literal`.
68
70
  # @param [Hash{Symbol => Object}] options
69
71
  # @option options [RDF::Resource] :context (nil)
70
72
  # @return [RDF::Statement]
@@ -18,20 +18,21 @@ module RDF; class Query
18
18
  ##
19
19
  # @overload initialize(options = {})
20
20
  # @param [Hash{Symbol => Object}] options
21
- # @option options [Variable, Resource] :subject (nil)
22
- # @option options [Variable, URI] :predicate (nil)
23
- # @option options [Variable, Term] :object (nil)
24
- # @option options [Variable, Resource] :context (nil)
21
+ # @option options [Variable, Resource, nil] :subject (nil)
22
+ # @option options [Variable, URI, nil] :predicate (nil)
23
+ # @option options [Variable, Term, nil] :object (nil)
24
+ # @option options [Variable, Resource, nil, false] :context (nil)
25
25
  # A context of nil matches any context, a context of false, matches only the default context.
26
26
  # @option options [Boolean] :optional (false)
27
27
  #
28
28
  # @overload initialize(subject, predicate, object, options = {})
29
- # @param [Variable, Resource] subject
30
- # @param [Variable, URI] predicate
31
- # @param [Variable, Term] object
32
- # @param [Hash{Symbol => Object}] options
33
- # @option options [Variable, Resource] :context (nil)
34
- # @option options [Boolean] :optional (false)
29
+ # @param [Variable, Resource, nil] subject
30
+ # @param [Variable, URI, nil] predicate
31
+ # @param [Variable, Termm, nil] object
32
+ # @param [Hash{Symbol => Object}] options
33
+ # @option options [Variable, Resource, nil, false] :context (nil)
34
+ # A context of nil matches any context, a context of false, matches only the default context.
35
+ # @option options [Boolean] :optional (false)
35
36
  def initialize(subject = nil, predicate = nil, object = nil, options = {})
36
37
  super
37
38
  end
data/lib/rdf/vocab.rb CHANGED
@@ -87,7 +87,7 @@ module RDF
87
87
  # @overload property(name, options)
88
88
  # Defines a new property or class in the vocabulary.
89
89
  # Optional labels and comments are stripped of unnecessary whitespace.
90
- #
90
+ #
91
91
  # @param [String, #to_s] name
92
92
  # @param [Hash{Symbol => Object}] options
93
93
  # @option options [String, #to_s] :label
@@ -281,7 +281,7 @@ module RDF
281
281
  # @overload property(name, options)
282
282
  # Defines a new property or class in the vocabulary.
283
283
  # Optional labels and comments are stripped of unnecessary whitespace.
284
- #
284
+ #
285
285
  # @param [String, #to_s] name
286
286
  # @param [Hash{Symbol => Object}] options
287
287
  # @option options [String, #to_s] :label
@@ -301,6 +301,12 @@ module RDF
301
301
  end
302
302
  end
303
303
 
304
+ ##
305
+ # @return [Array<RDF::URI>] a list of properties in the current vocabulary
306
+ def properties
307
+ @@properties.keys
308
+ end
309
+
304
310
  def [](name)
305
311
  prop = RDF::URI.intern([to_s, name.to_s].join(''))
306
312
  @@properties.fetch(prop) #raises KeyError on missing value
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.1.1
4
+ version: 1.1.2.1
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: 2013-12-26 00:00:00.000000000 Z
13
+ date: 2014-01-15 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rdf-spec
@@ -244,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
244
244
  version: '0'
245
245
  requirements: []
246
246
  rubyforge_project: rdf
247
- rubygems_version: 2.1.11
247
+ rubygems_version: 2.0.14
248
248
  signing_key:
249
249
  specification_version: 4
250
250
  summary: A Ruby library for working with Resource Description Framework (RDF) data.