active-triples 0.7.2 → 0.7.3
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 +4 -4
- data/CHANGES.md +7 -1
- data/lib/active_triples/rdf_source.rb +1 -1
- data/lib/active_triples/relation.rb +23 -1
- data/lib/active_triples/repositories.rb +8 -1
- data/lib/active_triples/version.rb +1 -1
- data/spec/active_triples/relation_spec.rb +2 -2
- data/spec/active_triples/repositories_spec.rb +2 -1
- data/spec/active_triples/resource_spec.rb +11 -5
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2021791a9a343f59c6ae24159333c8897cebf86c
|
4
|
+
data.tar.gz: 81c56b132c4d53f6740d9c226f021e4b65b14cd8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 650d818e6a155bf3cf33fc78f68dd1507254ed2d0afd71c0b1b7cb3c60a7e88aa46370d88d10d0801cce7dc08938e83b4ce65fb20d1e52611ecd7f240161014c
|
7
|
+
data.tar.gz: 679cf912b7e71b6ca6b15f16a51dc4f846ee0d0694719781cd30a9b6aef95bf78746cf8442ca856422f36b03d7a05cef63033031d594d3e01250f7a4fe89f1d3
|
data/CHANGES.md
CHANGED
@@ -1,10 +1,16 @@
|
|
1
|
+
0.7.3
|
2
|
+
----
|
3
|
+
|
4
|
+
- Optimize querying by using Graph#query instead of Queryable#query
|
5
|
+
- Improved error handling
|
6
|
+
|
1
7
|
0.7.2
|
2
8
|
----
|
3
9
|
|
4
10
|
- Allows interoperability between `ActiveModel::Validations` and
|
5
11
|
`RDF::Graph#valid?`. This fixes a bug with validation callbacks. See:
|
6
12
|
[#167](https://github.com/ActiveTriples/ActiveTriples/pull/167).
|
7
|
-
|
13
|
+
|
8
14
|
0.7.1
|
9
15
|
----
|
10
16
|
|
@@ -133,7 +133,7 @@ module ActiveTriples
|
|
133
133
|
return
|
134
134
|
end
|
135
135
|
val = val.to_uri if val.respond_to? :to_uri
|
136
|
-
raise
|
136
|
+
raise ValueError, val unless
|
137
137
|
val.kind_of? RDF::Value or val.kind_of? RDF::Literal
|
138
138
|
parent.insert [rdf_subject, predicate, val]
|
139
139
|
end
|
@@ -235,6 +235,28 @@ module ActiveTriples
|
|
235
235
|
parent.rdf_subject
|
236
236
|
end
|
237
237
|
end
|
238
|
+
|
239
|
+
public
|
240
|
+
|
241
|
+
##
|
242
|
+
# An error class for unallowable values in relations.
|
243
|
+
class ValueError < ArgumentError
|
244
|
+
# @!attribute [r] value
|
245
|
+
attr_reader :value
|
246
|
+
|
247
|
+
##
|
248
|
+
# @param value [Object]
|
249
|
+
def initialize(value)
|
250
|
+
@value = value
|
251
|
+
end
|
252
|
+
|
253
|
+
##
|
254
|
+
# @return [String]
|
255
|
+
def message
|
256
|
+
'value must be an RDF URI, Node, Literal, or a valid datatype. '\
|
257
|
+
"See RDF::Literal.\n\tYou provided #{value.inspect}"
|
258
|
+
end
|
259
|
+
end
|
238
260
|
end
|
239
261
|
|
240
262
|
class Term < Relation
|
@@ -16,8 +16,15 @@ module ActiveTriples
|
|
16
16
|
# @see Configurable
|
17
17
|
module Repositories
|
18
18
|
|
19
|
+
##
|
20
|
+
# @param name [Symbol]
|
21
|
+
# @param repo [RDF::Repository]
|
22
|
+
#
|
23
|
+
# @return [RDF::Repository]
|
24
|
+
# @raise [ArgumentError] if a non-repository is passed
|
19
25
|
def add_repository(name, repo)
|
20
|
-
raise "Repositories must be an RDF::Repository" unless
|
26
|
+
raise ArgumentError, "Repositories must be an RDF::Repository" unless
|
27
|
+
repo.kind_of? RDF::Repository
|
21
28
|
repositories[name] = repo
|
22
29
|
end
|
23
30
|
module_function :add_repository
|
@@ -11,7 +11,7 @@ describe ActiveTriples::Relation do
|
|
11
11
|
context "when relation has 0 value arguments" do
|
12
12
|
before { subject.value_arguments = double(length: 0) }
|
13
13
|
it "should raise an error" do
|
14
|
-
expect { subject.send(:rdf_subject) }.to raise_error
|
14
|
+
expect { subject.send(:rdf_subject) }.to raise_error ArgumentError
|
15
15
|
end
|
16
16
|
end
|
17
17
|
context "when term has 1 value argument" do
|
@@ -35,7 +35,7 @@ describe ActiveTriples::Relation do
|
|
35
35
|
context "when relation has 3 value arguments" do
|
36
36
|
before { subject.value_arguments = double(length: 3) }
|
37
37
|
it "should raise an error" do
|
38
|
-
expect { subject.send(:rdf_subject) }.to raise_error
|
38
|
+
expect { subject.send(:rdf_subject) }.to raise_error ArgumentError
|
39
39
|
end
|
40
40
|
end
|
41
41
|
end
|
@@ -14,7 +14,8 @@ describe ActiveTriples::Repositories do
|
|
14
14
|
expect(subject.repositories).to include :name
|
15
15
|
end
|
16
16
|
it 'should throw an error if passed something that is not a repository' do
|
17
|
-
expect{subject.add_repository :name, :not_a_repo}
|
17
|
+
expect{subject.add_repository :name, :not_a_repo}
|
18
|
+
.to raise_error ArgumentError
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
@@ -22,7 +22,9 @@ describe ActiveTriples::Resource do
|
|
22
22
|
|
23
23
|
describe '#property' do
|
24
24
|
it 'raises error when set directly on Resource' do
|
25
|
-
expect { ActiveTriples::Resource.property :blah, :
|
25
|
+
expect { ActiveTriples::Resource.property :blah, predicate: RDF::DC.title }
|
26
|
+
.to raise_error 'Properties not definable directly on ' \
|
27
|
+
'ActiveTriples::Resource, use a subclass'
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
@@ -67,7 +69,8 @@ describe ActiveTriples::Resource do
|
|
67
69
|
end
|
68
70
|
|
69
71
|
it 'should not be settable' do
|
70
|
-
expect{ subject.set_subject! RDF::URI('http://example.org/moomin2') }
|
72
|
+
expect{ subject.set_subject! RDF::URI('http://example.org/moomin2') }
|
73
|
+
.to raise_error "Refusing update URI when one is already assigned!"
|
71
74
|
end
|
72
75
|
end
|
73
76
|
|
@@ -474,7 +477,8 @@ describe ActiveTriples::Resource do
|
|
474
477
|
end
|
475
478
|
|
476
479
|
it 'raises error when trying to set nil value' do
|
477
|
-
expect { subject.aggregates[1] = nil }
|
480
|
+
expect { subject.aggregates[1] = nil }
|
481
|
+
.to raise_error ActiveTriples::Relation::ValueError
|
478
482
|
end
|
479
483
|
|
480
484
|
it "should be changeable for multiple values" do
|
@@ -560,7 +564,8 @@ describe ActiveTriples::Resource do
|
|
560
564
|
end
|
561
565
|
|
562
566
|
it "raise an error if the value is not a URI, Node, Literal, RdfResource, or string" do
|
563
|
-
expect{subject.set_value(RDF::DC.title, Object.new)}
|
567
|
+
expect{subject.set_value(RDF::DC.title, Object.new)}
|
568
|
+
.to raise_error ActiveTriples::Relation::ValueError
|
564
569
|
end
|
565
570
|
|
566
571
|
it "should be able to accept a subject" do
|
@@ -583,7 +588,8 @@ describe ActiveTriples::Resource do
|
|
583
588
|
end
|
584
589
|
|
585
590
|
it "raise an error if the value is not a URI, Node, Literal, RdfResource, or string" do
|
586
|
-
expect { subject[RDF::DC.title] = Object.new }
|
591
|
+
expect { subject[RDF::DC.title] = Object.new }
|
592
|
+
.to raise_error ActiveTriples::Relation::ValueError
|
587
593
|
end
|
588
594
|
end
|
589
595
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active-triples
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Johnson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-01-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rdf
|
@@ -258,9 +258,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
258
258
|
version: '0'
|
259
259
|
requirements: []
|
260
260
|
rubyforge_project:
|
261
|
-
rubygems_version: 2.
|
261
|
+
rubygems_version: 2.4.5.1
|
262
262
|
signing_key:
|
263
263
|
specification_version: 4
|
264
264
|
summary: RDF graphs in ActiveModel wrappers.
|
265
265
|
test_files: []
|
266
|
-
has_rdoc:
|