active-triples 0.9.0 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/CHANGES.md +7 -0
- data/Gemfile +1 -0
- data/active-triples.gemspec +3 -3
- data/lib/active_triples/persistence_strategies/parent_strategy.rb +2 -0
- data/lib/active_triples/rdf_source.rb +1 -1
- data/lib/active_triples/relation.rb +18 -16
- data/lib/active_triples/version.rb +1 -1
- data/spec/active_triples/identifiable_spec.rb +10 -0
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 300932925b232989a4b093e73168d529344c5f11
|
4
|
+
data.tar.gz: 64fb356ca3c31691e28d27fd8e88a6a61bdef816
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d62f7ca7d2757f818d2a8b6be44d079312322b40a75d64ac020a14456145d21b6051372539bf5f18ed71f457f398fdc29722257139f5b4f28e35a3782c1716ab
|
7
|
+
data.tar.gz: 2054a0e5dbc1b4c9dd4eaa77757ddded8129648a6699f511514c2aa14b8ae12d97755a2db88263b3255ed4c297bca50ebd53a7e957eebdceacceb1f72b0ae3a2
|
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
data/Gemfile
CHANGED
data/active-triples.gemspec
CHANGED
@@ -12,12 +12,12 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.summary = %q{RDF graphs in ActiveModel wrappers.}
|
13
13
|
s.description = %q{ActiveTriples provides tools for modeling RDF as discrete resources.}
|
14
14
|
s.license = "APACHE2"
|
15
|
-
s.required_ruby_version
|
15
|
+
s.required_ruby_version = '>= 2.1.0'
|
16
16
|
|
17
|
-
s.add_dependency 'rdf', '~> 2.0'
|
17
|
+
s.add_dependency 'rdf', '~> 2.0', '>= 2.0.2'
|
18
18
|
s.add_dependency 'linkeddata', '~> 2.0'
|
19
19
|
s.add_dependency 'activemodel', '>= 3.0.0'
|
20
|
-
s.add_dependency 'deprecation', '~> 0
|
20
|
+
s.add_dependency 'deprecation', '~> 1.0'
|
21
21
|
s.add_dependency 'activesupport', '>= 3.0.0'
|
22
22
|
|
23
23
|
s.add_development_dependency 'rdoc'
|
@@ -95,6 +95,7 @@ module ActiveTriples
|
|
95
95
|
#
|
96
96
|
# @return [true] true if the save did not error
|
97
97
|
def persist!
|
98
|
+
return false if final_parent.frozen?
|
98
99
|
erase_old_resource
|
99
100
|
final_parent << source
|
100
101
|
@persisted = true
|
@@ -105,6 +106,7 @@ module ActiveTriples
|
|
105
106
|
#
|
106
107
|
# @return [Boolean]
|
107
108
|
def reload
|
109
|
+
return false if source.frozen?
|
108
110
|
if loaded? || !persisted?
|
109
111
|
source << final_parent.query(subject: source.rdf_subject)
|
110
112
|
else
|
@@ -91,6 +91,7 @@ module ActiveTriples
|
|
91
91
|
# @todo move this logic out to a Builder?
|
92
92
|
def initialize(*args, &block)
|
93
93
|
resource_uri = args.shift unless args.first.is_a?(Hash)
|
94
|
+
@rdf_subject = get_uri(resource_uri) if resource_uri
|
94
95
|
unless args.first.is_a?(Hash) || args.empty?
|
95
96
|
set_persistence_strategy(ParentStrategy)
|
96
97
|
persistence_strategy.parent = args.shift
|
@@ -98,7 +99,6 @@ module ActiveTriples
|
|
98
99
|
set_persistence_strategy(RepositoryStrategy)
|
99
100
|
end
|
100
101
|
@graph = RDF::Graph.new(*args, &block)
|
101
|
-
set_subject!(resource_uri) if resource_uri
|
102
102
|
|
103
103
|
reload
|
104
104
|
|
@@ -34,7 +34,7 @@ module ActiveTriples
|
|
34
34
|
attr_reader :reflections
|
35
35
|
|
36
36
|
delegate :<=>, :==, :===, :[], :each, :empty?, :equal, :inspect, :last,
|
37
|
-
:to_a, :to_ary, :size, :join, :length, :to => :result
|
37
|
+
:to_a, :to_ary, :size, :join, :length, :+, :to => :result
|
38
38
|
|
39
39
|
##
|
40
40
|
# @param [ActiveTriples::RDFSource] parent_source
|
@@ -354,15 +354,15 @@ module ActiveTriples
|
|
354
354
|
end
|
355
355
|
|
356
356
|
def set_value(val)
|
357
|
-
|
358
|
-
if
|
359
|
-
node_cache[
|
360
|
-
add_child_node(val)
|
357
|
+
resource = value_to_node(val.respond_to?(:resource) ? val.resource : val)
|
358
|
+
if resource.kind_of? RDFSource
|
359
|
+
node_cache[resource.rdf_subject] = nil
|
360
|
+
add_child_node(val, resource)
|
361
361
|
return
|
362
362
|
end
|
363
|
-
|
364
|
-
raise ValueError,
|
365
|
-
parent.insert [rdf_subject, predicate,
|
363
|
+
resource = resource.to_uri if resource.respond_to? :to_uri
|
364
|
+
raise ValueError, resource unless resource.kind_of? RDF::Term
|
365
|
+
parent.insert [rdf_subject, predicate, resource]
|
366
366
|
end
|
367
367
|
|
368
368
|
def type_property
|
@@ -373,19 +373,21 @@ module ActiveTriples
|
|
373
373
|
valid_datatype?(val) ? RDF::Literal(val) : val
|
374
374
|
end
|
375
375
|
|
376
|
-
def add_child_node(resource)
|
376
|
+
def add_child_node(object, resource)
|
377
377
|
parent.insert [rdf_subject, predicate, resource.rdf_subject]
|
378
|
+
resource = resource.respond_to?(:resource) ? resource.resource : resource
|
378
379
|
|
379
|
-
|
380
|
-
|
380
|
+
new_resource = resource.dup unless object.respond_to?(:resource) && object.resource == resource
|
381
|
+
new_resource ||= resource
|
382
|
+
unless new_resource == parent ||
|
381
383
|
(parent.persistence_strategy.is_a?(ParentStrategy) &&
|
382
|
-
parent.persistence_strategy.ancestors.find { |a| a ==
|
383
|
-
|
384
|
-
|
384
|
+
parent.persistence_strategy.ancestors.find { |a| a == new_resource })
|
385
|
+
new_resource.set_persistence_strategy(ParentStrategy)
|
386
|
+
new_resource.parent = parent
|
385
387
|
end
|
386
388
|
|
387
|
-
self.node_cache[resource.rdf_subject] = resource
|
388
|
-
|
389
|
+
self.node_cache[resource.rdf_subject] = (resource == object ? new_resource : object)
|
390
|
+
new_resource.persist! if new_resource.persistence_strategy.is_a? ParentStrategy
|
389
391
|
end
|
390
392
|
|
391
393
|
def valid_datatype?(val)
|
@@ -155,5 +155,15 @@ describe ActiveTriples::Identifiable do
|
|
155
155
|
expect(subject.rdf_subject).to eq 'http://example.org/ns/123'
|
156
156
|
end
|
157
157
|
end
|
158
|
+
|
159
|
+
describe "adding it as a property for an AT Resource" do
|
160
|
+
include_context 'with data'
|
161
|
+
it "returns the same in-memory object added" do
|
162
|
+
resource = MyResource.new
|
163
|
+
resource.relation = subject
|
164
|
+
|
165
|
+
expect(resource.relation).to eq [subject]
|
166
|
+
end
|
167
|
+
end
|
158
168
|
end
|
159
169
|
end
|
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.
|
4
|
+
version: 0.10.0
|
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: 2016-
|
12
|
+
date: 2016-07-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rdf
|
@@ -18,6 +18,9 @@ dependencies:
|
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '2.0'
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.0.2
|
21
24
|
type: :runtime
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -25,6 +28,9 @@ dependencies:
|
|
25
28
|
- - "~>"
|
26
29
|
- !ruby/object:Gem::Version
|
27
30
|
version: '2.0'
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.0.2
|
28
34
|
- !ruby/object:Gem::Dependency
|
29
35
|
name: linkeddata
|
30
36
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,14 +65,14 @@ dependencies:
|
|
59
65
|
requirements:
|
60
66
|
- - "~>"
|
61
67
|
- !ruby/object:Gem::Version
|
62
|
-
version: '0
|
68
|
+
version: '1.0'
|
63
69
|
type: :runtime
|
64
70
|
prerelease: false
|
65
71
|
version_requirements: !ruby/object:Gem::Requirement
|
66
72
|
requirements:
|
67
73
|
- - "~>"
|
68
74
|
- !ruby/object:Gem::Version
|
69
|
-
version: '0
|
75
|
+
version: '1.0'
|
70
76
|
- !ruby/object:Gem::Dependency
|
71
77
|
name: activesupport
|
72
78
|
requirement: !ruby/object:Gem::Requirement
|
@@ -267,7 +273,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
267
273
|
requirements:
|
268
274
|
- - ">="
|
269
275
|
- !ruby/object:Gem::Version
|
270
|
-
version: 2.
|
276
|
+
version: 2.1.0
|
271
277
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
272
278
|
requirements:
|
273
279
|
- - ">="
|