rdf 1.1.12 → 1.1.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 424861a5701eb72e91b109582c0fa5a822a55077
4
- data.tar.gz: 6e3bb83de003042827fc25fd5b77522fa957c6a8
3
+ metadata.gz: d8cc213b390113a8231b320a298d2aa83a2d9139
4
+ data.tar.gz: 9d073afff562399f2cb879d10cfafa0409d484b1
5
5
  SHA512:
6
- metadata.gz: cab68b2efe3db88ea4f11b71818c2966ccda4f41a3a41aeff008d41535bec2798c4e03e9db39219f767b3255974291243f14aeb5798b5733629e829a5a1bc74d
7
- data.tar.gz: e7edd05ebdeec991a7403d26debf884a98ff94dbf74985c77b092aafe61f53bdc7f937b6ac77266d6506cebc01f0de1bbf2b832811ef6a3e9afecd4a55247239
6
+ metadata.gz: 1b0dfaf09965c2bb8cde8472882efb2223b0f5126e11d71d5aefcd560102e0213539a963d6b23bba3261e6261272794efdf56a7f66fe047d81f40afa7aaca302
7
+ data.tar.gz: 4499c53c7c4bfa96f3377f6ea9344054e8dbe182f42479bba2f535d453a44fecbdbdaf8853d82ed93d612edd74fc0dbee39af864e4994f0785cf5c61c8ade8c5
data/CREDITS CHANGED
@@ -11,3 +11,4 @@
11
11
  * Pius Uzamere <pius@alum.mit.edu>
12
12
  * Judson Lester <nyarly@gmail.com>
13
13
  * Peter Vandenabeele <peter@vandenabeele.com>
14
+ * Tom Johnson <johnson.tom@gmail.com>
data/README CHANGED
@@ -419,6 +419,7 @@ follows:
419
419
  * [Pius Uzamere](http://github.com/pius) - <http://pius.me/>
420
420
  * [Judson Lester](https://github.com/nyarly) - <https://github.com/nyarly>
421
421
  * [Peter Vandenabeele](https://github.com/petervandenabeele) - <https://github.com/petervandenabeele>
422
+ * [Tom Johnson](https://github.com/no-reply) - <https://github.com/no-reply>
422
423
 
423
424
  ## Contributing
424
425
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.12
1
+ 1.1.13
@@ -103,11 +103,12 @@ module RDF
103
103
 
104
104
  ##
105
105
  # Default validate! implementation, overridden in concrete classes
106
- # @return [RDF::Literal] `self`
106
+ # @return [RDF::Enumerable] `self`
107
107
  # @raise [ArgumentError] if the value is invalid
108
108
  # @since 0.3.9
109
109
  def validate!
110
110
  raise ArgumentError if supports?(:validity) && invalid?
111
+ self
111
112
  end
112
113
  alias_method :validate, :validate!
113
114
 
@@ -146,9 +146,9 @@ module RDF
146
146
  when Literal
147
147
  # If other is a Literal, reverse test to consolodate complex type checking logic
148
148
  other == self
149
- else
149
+ else
150
150
  other.respond_to?(:node?) && other.node? &&
151
- self.hash == other.hash &&
151
+ self.hash == other.to_term.hash &&
152
152
  other.respond_to?(:id) && @id == other.id
153
153
  end
154
154
  end
@@ -150,11 +150,12 @@ module RDF
150
150
 
151
151
  ##
152
152
  # Default validate! implementation, overridden in concrete classes
153
- # @return [RDF::Literal] `self`
153
+ # @return [RDF::Value] `self`
154
154
  # @raise [ArgumentError] if the value is invalid
155
155
  # @since 0.3.9
156
156
  def validate!
157
157
  raise ArgumentError if invalid?
158
+ self
158
159
  end
159
160
  alias_method :validate, :validate!
160
161
 
data/lib/rdf/query.rb CHANGED
@@ -490,32 +490,36 @@ module RDF
490
490
  Query.new(*patterns)
491
491
  end
492
492
 
493
+ ##
494
+ # Determine if the URI is a valid according to RFC3987
495
+ #
496
+ # @return [Boolean] `true` or `false`
497
+ # @since 0.3.9
498
+ def valid?
499
+ !!validate!
500
+ rescue
501
+ false
502
+ end
503
+
493
504
  ##
494
505
  # Validate this query, making sure it can be executed by our query engine.
495
506
  # This method is public so that it may be called by implementations of
496
507
  # RDF::Queryable#query_execute that bypass our built-in query engine.
497
508
  #
498
- # @return [void]
509
+ # @return [RDF::Query] `self`
499
510
  # @raise [ArgumentError] This query cannot be executed.
500
511
  def validate!
501
- # Our first pattern, if it exists, cannot be an optional pattern.
502
- if @patterns.length > 0 && @patterns[0].optional?
503
- raise ArgumentError.new("Query must not begin with an optional pattern")
504
- end
512
+ # All patterns must be valid
513
+ @patterns.each(&:validate!)
505
514
 
506
- # All optional patterns must appear after the regular patterns. We
507
- # could test this more cleanly using Ruby 1.9-specific features, but
508
- # we want to run under Ruby 1.8, too.
509
- i = 0
510
- i += 1 while i < @patterns.length && !@patterns[i].optional?
511
- while i < @patterns.length
512
- unless @patterns[i].optional?
515
+ # All optional patterns must appear after the regular patterns.
516
+ if i = @patterns.find_index(&:optional?)
517
+ unless @patterns[i..-1].all?(&:optional?)
513
518
  raise ArgumentError.new("Optional patterns must appear at end of query")
514
519
  end
515
- i += 1
516
520
  end
517
521
 
518
- nil
522
+ self
519
523
  end
520
524
 
521
525
  protected
@@ -96,6 +96,19 @@ module RDF; class Query
96
96
  !!options[:optional]
97
97
  end
98
98
 
99
+ ##
100
+ # Is this pattern composed only of valid components?
101
+ #
102
+ # @return [Boolean] `true` or `false`
103
+ def valid?
104
+ (has_subject? ? (subject.resource? || subject.variable?) && subject.valid? : true) &&
105
+ (has_predicate? ? (predicate.uri? || predicate.variable?) && predicate.valid? : true) &&
106
+ (has_object? ? (object.term? || object.variable?) && object.valid? : true) &&
107
+ (has_context? ? (context.resource? || context.variable?) && context.valid? : true )
108
+ rescue NoMethodError
109
+ false
110
+ end
111
+
99
112
  ##
100
113
  # Executes this query pattern on the given `queryable` object.
101
114
  #
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.12
4
+ version: 1.1.13
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-05-03 00:00:00.000000000 Z
13
+ date: 2015-05-12 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: link_header
@@ -41,7 +41,7 @@ dependencies:
41
41
  version: '1.1'
42
42
  - - ">="
43
43
  - !ruby/object:Gem::Version
44
- version: 1.1.5
44
+ version: 1.1.13
45
45
  type: :development
46
46
  prerelease: false
47
47
  version_requirements: !ruby/object:Gem::Requirement
@@ -51,7 +51,7 @@ dependencies:
51
51
  version: '1.1'
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 1.1.5
54
+ version: 1.1.13
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rdf-rdfxml
57
57
  requirement: !ruby/object:Gem::Requirement