rdf-reasoner 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/rdf/reasoner/schema.rb +33 -1
  4. metadata +17 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: beba6739c5b868b8257113fbe7cbb61f2dd5888d
4
- data.tar.gz: 32ad2d774c51959bb48ed65f45543db13b671678
3
+ metadata.gz: f1980413b4fbf92e655601081fbc493d9a5dcb77
4
+ data.tar.gz: 545ce25a9e024691ee7b8d7e0166921bfa0f876a
5
5
  SHA512:
6
- metadata.gz: b212c36158e528f01379f54661c0bd6a3ff120daa7bf4a80cd9a6d3d08c2d8ed6b951221b8bae67d9f114852dd823e45773ce227ecdcc538c24b511f1d75923d
7
- data.tar.gz: f7bf9b01e3551ca0ed1a502821415098e9d5116c4dc34f82557db68761a6b253110835df41cf118cd4b5e3de978594d0e88a99c9aba345f2b8aada030420f825
6
+ metadata.gz: e4e95ad17224135fee1f801455eaa802a277efb82227f9d4837f3eccdeeb6b5a3c7c5a4f9686ca6dbed50afd3ea67dd625d30150b2299ff15ac56d45fef4f883
7
+ data.tar.gz: 19fb975b67c1e0aaff517e98f9513c42b6ca618272d8d862fbcc44b104ad62f33fc2442ae9d835ac70dc724bc24ba6d9ccd55ddc061e1d0e56798a781477ddd5
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -125,6 +125,21 @@ module RDF::Reasoner
125
125
  end
126
126
  elsif %w(True False).map {|v| RDF::SCHEMA[v]}.include?(resource) && ranges.include?(RDF::SCHEMA.Boolean)
127
127
  true # Special case for schema boolean resources
128
+ elsif ranges.include?(RDF::SCHEMA.URL) && resource.uri?
129
+ true # schema:URL matches URI resources
130
+ elsif ranges.include?(RDF::SCHEMA.Text) && resource.uri?
131
+ # Allowed if resource is untyped
132
+ # Fully entailed types of the resource
133
+ types = options.fetch(:types) do
134
+ queryable.query(:subject => resource, :predicate => RDF.type).
135
+ map {|s| (t = (RDF::Vocabulary.find_term(s.object) rescue nil)) && t.entail(:subClassOf)}.
136
+ flatten.
137
+ uniq.
138
+ compact
139
+ end
140
+ types.empty?
141
+ elsif literal_range?(ranges)
142
+ false # If resource isn't literal, this is a range violation
128
143
  else
129
144
  # Fully entailed types of the resource
130
145
  types = options.fetch(:types) do
@@ -156,7 +171,24 @@ module RDF::Reasoner
156
171
  true
157
172
  end
158
173
  end
159
-
174
+
175
+ # Are all ranges literal?
176
+ # @param [Array<RDF::UR>] ranges
177
+ # @return [Boolean]
178
+ def literal_range?(ranges)
179
+ ranges.all? do |range|
180
+ case range
181
+ when RDF::RDFS.Literal, RDF::SCHEMA.Text, RDF::SCHEMA.Boolean, RDF::SCHEMA.Date,
182
+ RDF::SCHEMA.DateTime, RDF::SCHEMA.Time, RDF::SCHEMA.URL,
183
+ RDF::SCHEMA.Number, RDF::SCHEMA.Float, RDF::SCHEMA.Integer
184
+ true
185
+ else
186
+ # If this is an XSD range, look for appropriate literal
187
+ range.start_with?(RDF::XSD.to_s)
188
+ end
189
+ end
190
+ end
191
+
160
192
  def self.included(mod)
161
193
  end
162
194
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdf-reasoner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregg Kellogg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-13 00:00:00.000000000 Z
11
+ date: 2015-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdf
@@ -58,6 +58,20 @@ dependencies:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '1.1'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rdf-vocab
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '0.8'
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '0.8'
61
75
  - !ruby/object:Gem::Dependency
62
76
  name: linkeddata
63
77
  requirement: !ruby/object:Gem::Requirement
@@ -153,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
167
  version: '0'
154
168
  requirements: []
155
169
  rubyforge_project:
156
- rubygems_version: 2.4.3
170
+ rubygems_version: 2.4.7
157
171
  signing_key:
158
172
  specification_version: 4
159
173
  summary: RDFS/OWL Reasoner for RDF.rb