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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c39dcd5366189f7c48a5d0cb61ab3d8f21f358a
4
- data.tar.gz: 843c3a9739c899ef296822ddbdc37b152e5818d9
3
+ metadata.gz: 300932925b232989a4b093e73168d529344c5f11
4
+ data.tar.gz: 64fb356ca3c31691e28d27fd8e88a6a61bdef816
5
5
  SHA512:
6
- metadata.gz: 7bef92c1abd72a0d8accde6d2346c61c711d8a66be9c26b479537756ce88acf433d2e396af8a28cfce7f8240c4c5d325cc495484a3a3335c7f30a96f67af51bd
7
- data.tar.gz: 5bae48e5d3db44d1cd0318a2fab282b94de957421edabdab35082375d4db97319998369ccdb75b884c1c331ce02e5faab92a64e8509ddc53aa42690baf9a72df
6
+ metadata.gz: d62f7ca7d2757f818d2a8b6be44d079312322b40a75d64ac020a14456145d21b6051372539bf5f18ed71f457f398fdc29722257139f5b4f28e35a3782c1716ab
7
+ data.tar.gz: 2054a0e5dbc1b4c9dd4eaa77757ddded8129648a6699f511514c2aa14b8ae12d97755a2db88263b3255ed4c297bca50ebd53a7e957eebdceacceb1f72b0ae3a2
@@ -4,7 +4,6 @@ script: "bundle exec rspec spec"
4
4
  sudo: false
5
5
  cache: bundler
6
6
  rvm:
7
- - 2.0
8
7
  - 2.1
9
8
  - 2.2.4
10
9
  - 2.3.1
data/CHANGES.md CHANGED
@@ -1,3 +1,10 @@
1
+ 0.10.0
2
+ ----
3
+ - Fix Identifiable for ActiveFedora [Trey Pendragon]
4
+ - Upgrade to RDF.rb 2.0.2 [Tom Johnson]
5
+ - Avoid touching each_statement on initialization [Tom Johnson]
6
+ - Drop support for Ruby 2.0
7
+
1
8
  0.9.0
2
9
  -----
3
10
  - Upgrade to RDF.rb 2.0
data/Gemfile CHANGED
@@ -2,4 +2,5 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
+ gem 'activesupport', '< 5.0.0' if RUBY_VERSION =~ /2\.1\..*/
5
6
  gem 'pry-byebug' unless ENV["CI"]
@@ -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 = '>= 2.0.0'
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.1'
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
- val = value_to_node(val.respond_to?(:resource) ? val.resource : val)
358
- if val.kind_of? RDFSource
359
- node_cache[val.rdf_subject] = nil
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
- val = val.to_uri if val.respond_to? :to_uri
364
- raise ValueError, val unless val.kind_of? RDF::Term
365
- parent.insert [rdf_subject, predicate, val]
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
- resource = resource.dup
380
- unless resource == parent ||
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 == resource })
383
- resource.set_persistence_strategy(ParentStrategy)
384
- resource.parent = parent
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
- resource.persist! if resource.persistence_strategy.is_a? ParentStrategy
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)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ActiveTriples
3
- VERSION = '0.9.0'.freeze
3
+ VERSION = '0.10.0'.freeze
4
4
  end
@@ -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.9.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-05-23 00:00:00.000000000 Z
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.1'
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.1'
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.0.0
276
+ version: 2.1.0
271
277
  required_rubygems_version: !ruby/object:Gem::Requirement
272
278
  requirements:
273
279
  - - ">="