ld4l-ore_rdf 0.0.7 → 0.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1314057adc8534d80d0ce5eb7916deec18a98afa
4
- data.tar.gz: 466427737650c339d24ab57cbb3245f5056a836c
3
+ metadata.gz: 8e31d9fd5075fcc5d9ca073e2edc850521ff7c2c
4
+ data.tar.gz: 54e5d4ff97cb4440f19134f7aac22531985ab5c9
5
5
  SHA512:
6
- metadata.gz: 5ad2757c009676508fb003cc30eb1b7aca2af85bdcf18c49df2578c41ab5b622df02db02c3b11123b2d09dafc59de290e70e57f3e7cd9ca0c756032524ca49bd
7
- data.tar.gz: 5b4ed442b085221dee72b7228b5f226a77ebc4c03cbc01fd3150b73a73249b0eb6b3de272aeaea8bb888030aadc20b291e2856001b6aa950a2ae3cbb3d9d1b92
6
+ metadata.gz: 7afdc0e5c94bc9f31e9ad2129eeb65be6d81fbf1ad8d0441c84169960017eff94f4d3296cd7a5797671318c8412d306145a88cb389eff04d81f1635524cf7b93
7
+ data.tar.gz: 0f2f08759d02ce86969a0c3b98438f007ee1d343986b5417e9931450a32049f8934cac981142906450b68a7bc5952a6852d9e11ae6bb4a92c11830183a896806
data/CHANGES.md ADDED
@@ -0,0 +1,15 @@
1
+ 0.1.0
2
+ -----
3
+ * Updated to work with ActiveTriples 0.5, 0.6, and 0.8.2
4
+
5
+ 0.0.7 (pre-release)
6
+ -----
7
+ * set first_proxy, last_proxy, next_proxy, and prev_proxy
8
+
9
+ 0.0.6 (pre-release)
10
+ -----
11
+ * Fix persist aggregation throws exception when title is blank
12
+
13
+ 0.0.4 (pre-release)
14
+ -----
15
+ * Initial release of gem
data/README.md CHANGED
@@ -45,7 +45,8 @@ ActiveTriples::Repositories.add_repository :default, RDF::Repository.new
45
45
  p = LD4L::FoafRDF::Person.new('p4')
46
46
  ```
47
47
 
48
- #### Example: Aggregation with items individually
48
+ *Example creating an aggregation with items individually.*
49
+
49
50
  ```
50
51
  agg10 = LD4L::OreRDF::CreateAggregation.call( :id=>'agg10', :title=>'My Resources', :description=>'Resources that I like', :owner=>p )
51
52
 
@@ -55,13 +56,51 @@ LD4L::OreRDF::AddAggregatedResource.call( agg10,'http://exmple.org/resource_3')
55
56
 
56
57
  LD4L::OreRDF::PersistAggregation.call(agg10)
57
58
 
58
- puts agg10.dump :ttl
59
-
60
59
  # To resume the aggregation at a later time, use...
61
60
  agg = LD4L::OreRDF::ResumeAggregation.call( 'agg10' )
62
61
  ```
62
+ *Example triples created for an aggregation.*
63
+
64
+ ```
65
+ puts agg.dump :ttl
66
+
67
+ <http://localhost/agg10> a <http://www.openarchives.org/ore/terms/Aggregation>;
68
+ <http://purl.org/dc/terms/title> "My Resources";
69
+ <http://purl.org/dc/terms/creator> <http://localhost/p4>;
70
+ <http://purl.org/dc/terms/description> "Resources that I like";
71
+ <http://www.iana.org/assignments/relation/first> <http://localhost/pxeff9a617-ab30-4d7e-971f-825032a597b0>;
72
+ <http://www.iana.org/assignments/relation/last> <http://localhost/pxd6577d16-7565-46c7-8b0f-31e7816b0e57>;
73
+ <http://www.openarchives.org/ore/terms/aggregates> "http://exmple.org/resource_1",
74
+ "http://exmple.org/resource_2",
75
+ "http://exmple.org/resource_3" .
76
+ ```
77
+
78
+ *Example triples created for each proxy in the list.*
79
+ ```
80
+ puts agg.first_proxy.first.dump :ttl
81
+
82
+ <http://localhost/pxeff9a617-ab30-4d7e-971f-825032a597b0> a <http://www.openarchives.org/ore/terms/Proxy>;
83
+ <http://www.iana.org/assignments/relation/next> <http://localhost/px0f16c9de-7d97-406d-a81a-a501bc209f79>;
84
+ <http://www.openarchives.org/ore/terms/proxyFor> "http://exmple.org/resource_1";
85
+ <http://www.openarchives.org/ore/terms/proxyIn> <http://localhost/agg10> .
86
+
87
+ puts agg.first_proxy.first.next_proxy.first.dump :ttl
88
+
89
+ <http://localhost/px0f16c9de-7d97-406d-a81a-a501bc209f79> a <http://www.openarchives.org/ore/terms/Proxy>;
90
+ <http://www.iana.org/assignments/relation/next> <http://localhost/pxd6577d16-7565-46c7-8b0f-31e7816b0e57>;
91
+ <http://www.iana.org/assignments/relation/prev> <http://localhost/pxeff9a617-ab30-4d7e-971f-825032a597b0>;
92
+ <http://www.openarchives.org/ore/terms/proxyFor> "http://exmple.org/resource_2";
93
+ <http://www.openarchives.org/ore/terms/proxyIn> <http://localhost/agg10> .
94
+
95
+ puts agg.last_proxy.first.dump :ttl
96
+
97
+ <http://localhost/pxd6577d16-7565-46c7-8b0f-31e7816b0e57> a <http://www.openarchives.org/ore/terms/Proxy>;
98
+ <http://www.iana.org/assignments/relation/prev> <http://localhost/px0f16c9de-7d97-406d-a81a-a501bc209f79>;
99
+ <http://www.openarchives.org/ore/terms/proxyFor> "http://exmple.org/resource_3";
100
+ <http://www.openarchives.org/ore/terms/proxyIn> <http://localhost/agg10> .
101
+ ```
63
102
 
64
- #### Example: Aggregation with items as array
103
+ *Example creating an aggregation with items in an array.*
65
104
  ```
66
105
  agg11 = LD4L::OreRDF::CreateAggregation.call( :id=>'agg11', :title=>'More Resources', :description=>'More resources that I like', :owner=>p )
67
106
 
@@ -70,10 +109,49 @@ LD4L::OreRDF::AddAggregatedResources.call( agg11,resources)
70
109
 
71
110
  LD4L::OreRDF::PersistAggregation.call(agg11)
72
111
 
73
- puts agg11.dump :ttl
74
-
75
112
  # To resume the aggregation at a later time, use...
76
- agg = LD4L::OreRDF::ResumeAggregation.call( 'agg10' )
113
+ agg = LD4L::OreRDF::ResumeAggregation.call( 'agg11' )
114
+ ```
115
+
116
+ *Example triples created for an aggregation.*
117
+ ```
118
+ puts agg.dump :ttl
119
+
120
+ <http://localhost/agg11> a <http://www.openarchives.org/ore/terms/Aggregation>;
121
+ <http://purl.org/dc/terms/title> "More Resources";
122
+ <http://purl.org/dc/terms/creator> <http://localhost/p4>;
123
+ <http://purl.org/dc/terms/description> "More resources that I like";
124
+ <http://www.iana.org/assignments/relation/first> <http://localhost/pxcff53ec2-f406-422b-92e6-f603612c9856>;
125
+ <http://www.iana.org/assignments/relation/last> <http://localhost/px4788758e-640b-455c-91f8-10f3c255a72d>;
126
+ <http://www.openarchives.org/ore/terms/aggregates>
127
+ "http://exmple.org/resource_5",
128
+ "http://exmple.org/resource_6",
129
+ "http://exmple.org/resource_7" .
130
+ ```
131
+
132
+ *Example triples created for each proxy in the list.*
133
+ ```
134
+ puts agg.first_proxy.first.dump :ttl
135
+
136
+ <http://localhost/pxcff53ec2-f406-422b-92e6-f603612c9856> a <http://www.openarchives.org/ore/terms/Proxy>;
137
+ <http://www.iana.org/assignments/relation/next> <http://localhost/pxf7cd384a-2727-4201-8ebe-22c35302b6c0>;
138
+ <http://www.openarchives.org/ore/terms/proxyFor> "http://exmple.org/resource_5";
139
+ <http://www.openarchives.org/ore/terms/proxyIn> <http://localhost/agg11> .
140
+
141
+ puts agg.first_proxy.first.next_proxy.first.dump :ttl
142
+
143
+ <http://localhost/pxf7cd384a-2727-4201-8ebe-22c35302b6c0> a <http://www.openarchives.org/ore/terms/Proxy>;
144
+ <http://www.iana.org/assignments/relation/next> <http://localhost/px4788758e-640b-455c-91f8-10f3c255a72d>;
145
+ <http://www.iana.org/assignments/relation/prev> <http://localhost/pxcff53ec2-f406-422b-92e6-f603612c9856>;
146
+ <http://www.openarchives.org/ore/terms/proxyFor> "http://exmple.org/resource_6";
147
+ <http://www.openarchives.org/ore/terms/proxyIn> <http://localhost/agg11> .
148
+
149
+ puts agg.last_proxy.first.dump :ttl
150
+
151
+ <http://localhost/px4788758e-640b-455c-91f8-10f3c255a72d> a <http://www.openarchives.org/ore/terms/Proxy>;
152
+ <http://www.iana.org/assignments/relation/prev> <http://localhost/pxf7cd384a-2727-4201-8ebe-22c35302b6c0>;
153
+ <http://www.openarchives.org/ore/terms/proxyFor> "http://exmple.org/resource_7";
154
+ <http://www.openarchives.org/ore/terms/proxyIn> <http://localhost/agg11> .
77
155
  ```
78
156
 
79
157
  #### Example: Find all aggregations
data/ld4l-ore_rdf.gemspec CHANGED
@@ -17,20 +17,16 @@ Gem::Specification.new do |spec|
17
17
 
18
18
  spec.files = `git ls-files -z`.split("\x0")
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
- # spec.test_files = `git ls-files -- {spec}/*`.split("\n") # FROM ActiveTriples gemspec file
21
- # spec.require_paths = ["lib"] # NOT IN ActiveTriples gemspec file
22
20
 
23
- # spec.add_dependency('ffi', '~> 1.9.5')
24
- spec.add_dependency('rdf', '~> 1.1')
21
+ spec.add_dependency('rdf', '= 1.99.0')
25
22
 
26
- spec.add_dependency('active-triples', '~> 0.5')
23
+ spec.add_dependency('active-triples', '~> 0.5', '~> 0.6', '~>0.8.2')
27
24
  spec.add_dependency('active_triples-local_name', '~> 0.1')
28
25
  spec.add_dependency('ld4l-foaf_rdf', '~> 0.0')
29
26
  spec.add_dependency('doubly_linked_list', '~> 0.0')
30
27
 
31
28
  spec.add_development_dependency('pry')
32
- # spec.add_development_dependency('pry-byebug') # Works with ruby > 2
33
- # spec.add_development_dependency('pry-debugger') # Works with ruby < 2
29
+ spec.add_development_dependency('pry-byebug')
34
30
  spec.add_development_dependency('rdoc')
35
31
  spec.add_development_dependency('rspec')
36
32
  spec.add_development_dependency('coveralls')
@@ -74,12 +74,24 @@ module LD4L
74
74
 
75
75
  def title
76
76
  titles = list_info.title
77
- titles.kind_of?(Array) && titles.size > 0 ? titles[0] : ""
77
+ title = ""
78
+ if list_info.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
79
+ title = titles.first if titles.kind_of?(ActiveTriples::Relation) && titles.size > 0
80
+ else # < ActiveTriples 0.8
81
+ title = titles.first if titles.kind_of?(Array) && titles.size > 0
82
+ end
83
+ title
78
84
  end
79
85
 
80
86
  def description
81
87
  descriptions = list_info.description
82
- descriptions.kind_of?(Array) && descriptions.size > 0 ? descriptions[0] : ""
88
+ description = ""
89
+ if list_info.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
90
+ description = descriptions.first if descriptions.kind_of?(ActiveTriples::Relation) && descriptions.size > 0
91
+ else # < ActiveTriples 0.8
92
+ description = descriptions.first if descriptions.kind_of?(Array) && descriptions.size > 0
93
+ end
94
+ description
83
95
  end
84
96
 
85
97
  def aggregation_resource
@@ -44,7 +44,11 @@ module LD4L
44
44
  results = query.execute(graph)
45
45
  results.each do |r|
46
46
  proxy_uri = r.to_hash[:proxy]
47
- proxy = LD4L::OreRDF::ProxyResource.new(proxy_uri)
47
+ if aggregation.list_info.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
48
+ proxy = LD4L::OreRDF::ProxyResource.new(proxy_uri,aggregation.list_info)
49
+ else # < ActiveTriples 0.8
50
+ proxy = LD4L::OreRDF::ProxyResource.new(proxy_uri)
51
+ end
48
52
  proxies << proxy
49
53
  end
50
54
  proxies
@@ -18,8 +18,7 @@ module LD4L
18
18
 
19
19
  # TODO Probably shouldn't be ArgumentError
20
20
  raise ArgumentError, "title is required" unless
21
- aggregation.title && aggregation.title && aggregation.title.kind_of?(String) &&
22
- aggregation.title.size > 0
21
+ aggregation.title && aggregation.title.kind_of?(String) && aggregation.title.size > 0
23
22
 
24
23
  count = 0
25
24
  agg_persisted = aggregation.aggregation_resource.persist!
@@ -36,4 +35,3 @@ module LD4L
36
35
  end
37
36
  end
38
37
  end
39
-
@@ -39,7 +39,11 @@ module LD4L
39
39
  LD4L::OreRDF.configuration.localname_minter )
40
40
 
41
41
  # create the proxy and set properties
42
- proxy = LD4L::OreRDF::ProxyResource.new(id)
42
+ if aggregation.list_info.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
43
+ proxy = LD4L::OreRDF::ProxyResource.new(id,aggregation.list_info)
44
+ else # < ActiveTriples 0.8
45
+ proxy = LD4L::OreRDF::ProxyResource.new(id)
46
+ end
43
47
  proxy.proxy_for = resource
44
48
  proxy.proxy_in = aggregation.aggregation_resource
45
49
  proxy.contributor = options[:contributor] || [] # TODO default to aggregation.owner
@@ -72,7 +72,11 @@ module LD4L
72
72
  uri = h[:proxy]
73
73
  if resume
74
74
  # if resume, return Hash of proxy uri => resumed proxy for each found
75
- proxies[uri] = LD4L::OreRDF::ProxyResource.new(uri)
75
+ if aggregation.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
76
+ proxies[uri] = LD4L::OreRDF::ProxyResource.new(uri,aggregation.list_info)
77
+ else # < ActiveTriples 0.8
78
+ proxies[uri] = LD4L::OreRDF::ProxyResource.new(uri)
79
+ end
76
80
  elsif process_properties
77
81
  # if properties, return Hash of proxy uri => Hash of property => value for each found
78
82
  properties = h
@@ -1,5 +1,5 @@
1
1
  module LD4L
2
2
  module OreRDF
3
- VERSION = "0.0.7"
3
+ VERSION = "0.1.0"
4
4
  end
5
5
  end
@@ -3,6 +3,10 @@ require 'spec_helper'
3
3
  describe 'LD4L::OreRDF' do
4
4
 
5
5
  describe '#configuration' do
6
+ after(:all) do
7
+ ActiveTriples::RDFSource.type_registry.keys.each { |k| ActiveTriples::RDFSource.type_registry.delete(k) } if Object.const_defined?("ActiveTriples::RDFSource")
8
+ end
9
+
6
10
  describe "base_uri" do
7
11
  context "when base_uri is not configured" do
8
12
  before do
@@ -46,7 +46,7 @@ describe 'LD4L::OreRDF::AggregationResource' do
46
46
  end
47
47
 
48
48
  it 'should not be settable' do
49
- expect{ subject.set_subject! RDF::URI('http://example.org/moomin2') }.to raise_error
49
+ expect{ subject.set_subject! RDF::URI('http://example.org/moomin2') }.to raise_error(RuntimeError, 'Refusing update URI when one is already assigned!')
50
50
  end
51
51
  end
52
52
  end
@@ -158,23 +158,24 @@ describe 'LD4L::OreRDF::AggregationResource' do
158
158
  orig_bib3 = "http://example.org/individual/b3"
159
159
 
160
160
  new_bib1 = "http://example.org/individual/b1_NEW"
161
- new_bib2 = "http://example.org/individual/b2_NEW"
162
161
  new_bib3 = "http://example.org/individual/b3_NEW"
163
162
 
164
163
  subject.aggregates = orig_bib1
165
164
  subject.aggregates << orig_bib2
166
165
  subject.aggregates << orig_bib3
167
166
 
168
- aggregates = subject.aggregates.dup
167
+ if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
168
+ aggregates = subject.aggregates.to_a
169
+ else # < ActiveTriples 0.8
170
+ aggregates = subject.aggregates.dup
171
+ end
169
172
  aggregates[0] = new_bib1
170
- # aggregates[1] = new_bib2
171
173
  aggregates[2] = new_bib3
172
174
  subject.aggregates = aggregates
173
175
 
174
- expect(subject.aggregates[0]).to eq new_bib1
175
- # expect(subject.aggregates[1]).to eq new_bib2
176
- expect(subject.aggregates[1]).to eq orig_bib2
177
- expect(subject.aggregates[2]).to eq new_bib3
176
+ expect(subject.aggregates).to include new_bib1
177
+ expect(subject.aggregates).to include orig_bib2
178
+ expect(subject.aggregates).to include new_bib3
178
179
  end
179
180
 
180
181
  it "should be directly changeable for multiple values" do
@@ -183,21 +184,22 @@ describe 'LD4L::OreRDF::AggregationResource' do
183
184
  orig_bib3 = "http://example.org/individual/b3"
184
185
 
185
186
  new_bib1 = "http://example.org/individual/b1_NEW"
186
- new_bib2 = "http://example.org/individual/b2_NEW"
187
187
  new_bib3 = "http://example.org/individual/b3_NEW"
188
188
 
189
189
  subject.aggregates = orig_bib1
190
190
  subject.aggregates << orig_bib2
191
191
  subject.aggregates << orig_bib3
192
192
 
193
- subject.aggregates[0] = new_bib1
194
- # subject.aggregates[1] = new_bib2
195
- subject.aggregates[2] = new_bib3
196
-
197
- expect(subject.aggregates[0]).to eq new_bib1
198
- # expect(subject.aggregates[1]).to eq new_bib2
199
- expect(subject.aggregates[1]).to eq orig_bib2
200
- expect(subject.aggregates[2]).to eq new_bib3
193
+ if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
194
+ subject.aggregates.swap(orig_bib1, new_bib1)
195
+ subject.aggregates.swap(orig_bib3, new_bib3)
196
+ else # < ActiveTriples 0.8
197
+ subject.aggregates[0] = new_bib1
198
+ subject.aggregates[2] = new_bib3
199
+ end
200
+ expect(subject.aggregates).to include new_bib1
201
+ expect(subject.aggregates).to include orig_bib2
202
+ expect(subject.aggregates).to include new_bib3
201
203
  end
202
204
  end
203
205
 
@@ -501,14 +503,18 @@ describe 'LD4L::OreRDF::AggregationResource' do
501
503
  context "and the item is not a blank node" do
502
504
 
503
505
  subject {LD4L::OreRDF::AggregationResource.new("123")}
506
+ let(:result) { subject.persist! }
504
507
 
505
508
  before do
506
509
  # Create inmemory repository
507
510
  @repo = RDF::Repository.new
508
- allow(subject.class).to receive(:repository).and_return(nil)
509
- allow(subject).to receive(:repository).and_return(@repo)
511
+ ActiveTriples::Repositories.repositories[:default] = @repo
510
512
  subject.title = "bla"
511
- subject.persist!
513
+ result
514
+ end
515
+
516
+ it "should return true" do
517
+ expect(result).to eq true
512
518
  end
513
519
 
514
520
  it "should persist to the repository" do
@@ -534,7 +540,7 @@ describe 'LD4L::OreRDF::AggregationResource' do
534
540
  subject << RDF::Statement(RDF::DC.LicenseDocument, RDF::DC.title, 'LICENSE')
535
541
  end
536
542
 
537
- subject { LD4L::FoafRDF::Person.new('456')}
543
+ subject { LD4L::OreRDF::AggregationResource.new('123') }
538
544
 
539
545
  it 'should return true' do
540
546
  expect(subject.destroy!).to be true
@@ -548,22 +554,26 @@ describe 'LD4L::OreRDF::AggregationResource' do
548
554
 
549
555
  context 'with a parent' do
550
556
  before do
551
- parent.owner = subject
557
+ subject.owner = child
552
558
  end
553
559
 
554
- let(:parent) do
555
- LD4L::OreRDF::AggregationResource.new('123')
560
+ let(:child) do
561
+ if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
562
+ LD4L::FoafRDF::Person.new('456',subject)
563
+ else # < ActiveTriples 0.8
564
+ LD4L::FoafRDF::Person.new('456')
565
+ end
556
566
  end
557
567
 
558
568
  it 'should empty the graph and remove it from the parent' do
559
- subject.destroy
560
- expect(parent.owner).to be_empty
569
+ child.destroy
570
+ expect(subject.owner).to be_empty
561
571
  end
562
572
 
563
573
  it 'should remove its whole graph from the parent' do
564
- subject.destroy
565
- subject.each_statement do |s|
566
- expect(parent.statements).not_to include s
574
+ child.destroy
575
+ child.each_statement do |s|
576
+ expect(subject.statements).not_to include s
567
577
  end
568
578
  end
569
579
  end
@@ -667,7 +677,12 @@ describe 'LD4L::OreRDF::AggregationResource' do
667
677
  end
668
678
 
669
679
  it "raise an error if the value is not a URI, Node, Literal, RdfResource, or string" do
670
- expect{subject.set_value(RDF::DC.title, Object.new)}.to raise_error
680
+ if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
681
+ error_name = ActiveTriples::Relation::ValueError
682
+ else # < ActiveTriples 0.8
683
+ error_name = RuntimeError
684
+ end
685
+ expect{subject.set_value(RDF::DC.title, Object.new)}.to raise_error(error_name,/value must be an RDF URI, Node, Literal, or a valid datatype. See RDF::Literal.*/)
671
686
  end
672
687
 
673
688
  it "should be able to accept a subject" do
@@ -697,7 +712,8 @@ describe 'LD4L::OreRDF::AggregationResource' do
697
712
 
698
713
  describe '#type' do
699
714
  it 'should return the type configured on the parent class' do
700
- expect(subject.type).to eq [LD4L::OreRDF::AggregationResource.type]
715
+ expected_result = LD4L::OreRDF::AggregationResource.type.kind_of?(Array) ? LD4L::OreRDF::AggregationResource.type : [LD4L::OreRDF::AggregationResource.type]
716
+ expect(subject.type).to eq expected_result
701
717
  end
702
718
 
703
719
  it 'should set the type' do
@@ -731,17 +747,6 @@ describe 'LD4L::OreRDF::AggregationResource' do
731
747
  end
732
748
  end
733
749
 
734
- describe '#solrize' do
735
- it 'should return a label for bnodes' do
736
- expect(subject.solrize).to eq subject.rdf_label
737
- end
738
-
739
- it 'should return a string of the resource uri' do
740
- subject.set_subject! 'http://example.org/moomin'
741
- expect(subject.solrize).to eq 'http://example.org/moomin'
742
- end
743
- end
744
-
745
750
  describe 'editing the graph' do
746
751
  it 'should write properties when statements are added' do
747
752
  subject << RDF::Statement.new(subject.rdf_subject, RDF::DC.title, 'Comet in Moominland')
@@ -46,7 +46,7 @@ describe 'LD4L::OreRDF::ProxyResource' do
46
46
  end
47
47
 
48
48
  it 'should not be settable' do
49
- expect{ subject.set_subject! RDF::URI('http://example.org/moomin2') }.to raise_error
49
+ expect{ subject.set_subject! RDF::URI('http://example.org/moomin2') }.to raise_error(RuntimeError, 'Refusing update URI when one is already assigned!')
50
50
  end
51
51
  end
52
52
  end
@@ -381,17 +381,21 @@ describe 'LD4L::OreRDF::ProxyResource' do
381
381
  context "and the item is not a blank node" do
382
382
 
383
383
  subject {LD4L::OreRDF::ProxyResource.new("123")}
384
+ let(:result) { subject.persist! }
384
385
 
385
386
  before do
386
387
  # Create inmemory repository
387
388
  @repo = RDF::Repository.new
388
- allow(subject.class).to receive(:repository).and_return(nil)
389
- allow(subject).to receive(:repository).and_return(@repo)
389
+ ActiveTriples::Repositories.repositories[:default] = @repo
390
390
  subject.contributor = "John Smith"
391
391
  an_aggregation = LD4L::OreRDF::AggregationResource.new('1')
392
392
  subject.proxy_in = an_aggregation
393
393
  subject.proxy_for = "http://example.org/b1"
394
- subject.persist!
394
+ result
395
+ end
396
+
397
+ it "should return true" do
398
+ expect(result).to eq true
395
399
  end
396
400
 
397
401
  it "should persist to the repository" do
@@ -408,7 +412,11 @@ describe 'LD4L::OreRDF::ProxyResource' do
408
412
  subject.persist!
409
413
  subject.reload
410
414
  expect(subject.contributor).to eq []
411
- expect(@repo.statements.to_a.length).to eq 1 # Only the type statement
415
+ if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
416
+ expect(@repo.statements.to_a.length).to eq 2 # Only the type statements for aggregation and proxy
417
+ else # < ActiveTriples 0.8
418
+ expect(@repo.statements.to_a.length).to eq 1 # Only the type statements for proxy
419
+ end
412
420
  end
413
421
  end
414
422
 
@@ -453,7 +461,7 @@ describe 'LD4L::OreRDF::ProxyResource' do
453
461
  subject << RDF::Statement(RDF::DC.LicenseDocument, RDF::DC.title, 'LICENSE')
454
462
  end
455
463
 
456
- subject { LD4L::FoafRDF::Person.new('456')}
464
+ subject { LD4L::OreRDF::ProxyResource.new('123') }
457
465
 
458
466
  it 'should return true' do
459
467
  expect(subject.destroy!).to be true
@@ -467,22 +475,26 @@ describe 'LD4L::OreRDF::ProxyResource' do
467
475
 
468
476
  context 'with a parent' do
469
477
  before do
470
- parent.contributor = subject
478
+ subject.contributor = child
471
479
  end
472
480
 
473
- let(:parent) do
474
- LD4L::OreRDF::ProxyResource.new('123')
481
+ let(:child) do
482
+ if subject.respond_to? 'persistence_strategy' # >= ActiveTriples 0.8
483
+ LD4L::FoafRDF::Person.new('456',subject)
484
+ else # < ActiveTriples 0.8
485
+ LD4L::FoafRDF::Person.new('456')
486
+ end
475
487
  end
476
488
 
477
489
  it 'should empty the graph and remove it from the parent' do
478
- subject.destroy
479
- expect(parent.contributor).to be_empty
490
+ child.destroy
491
+ expect(subject.contributor).to be_empty
480
492
  end
481
493
 
482
494
  it 'should remove its whole graph from the parent' do
483
- subject.destroy
484
- subject.each_statement do |s|
485
- expect(parent.statements).not_to include s
495
+ child.destroy
496
+ child.each_statement do |s|
497
+ expect(subject.statements).not_to include s
486
498
  end
487
499
  end
488
500
  end
@@ -591,17 +603,6 @@ describe 'LD4L::OreRDF::ProxyResource' do
591
603
  end
592
604
  end
593
605
 
594
- describe '#solrize' do
595
- it 'should return a label for bnodes' do
596
- expect(subject.solrize).to eq subject.rdf_label
597
- end
598
-
599
- it 'should return a string of the resource uri' do
600
- subject.set_subject! 'http://example.org/moomin'
601
- expect(subject.solrize).to eq 'http://example.org/moomin'
602
- end
603
- end
604
-
605
606
  describe 'editing the graph' do
606
607
  it 'should write properties when statements are added' do
607
608
  subject << RDF::Statement.new(subject.rdf_subject, RDFVocabularies::ORE.proxyFor, 'Comet in Moominland')
@@ -1,6 +1,10 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe "LD4L::OreRDF" do
4
+ after(:all) do
5
+ ActiveTriples::RDFSource.type_registry.keys.each { |k| ActiveTriples::RDFSource.type_registry.delete(k) } if Object.const_defined?("ActiveTriples::RDFSource")
6
+ end
7
+
4
8
  describe "#configure" do
5
9
 
6
10
  before do
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ld4l-ore_rdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - E. Lynette Rayle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-06 00:00:00.000000000 Z
11
+ date: 2016-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdf
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '1.1'
19
+ version: 1.99.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: '1.1'
26
+ version: 1.99.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: active-triples
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -31,6 +31,12 @@ dependencies:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0.5'
34
+ - - "~>"
35
+ - !ruby/object:Gem::Version
36
+ version: '0.6'
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 0.8.2
34
40
  type: :runtime
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
@@ -38,6 +44,12 @@ dependencies:
38
44
  - - "~>"
39
45
  - !ruby/object:Gem::Version
40
46
  version: '0.5'
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '0.6'
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: 0.8.2
41
53
  - !ruby/object:Gem::Dependency
42
54
  name: active_triples-local_name
43
55
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +106,20 @@ dependencies:
94
106
  - - ">="
95
107
  - !ruby/object:Gem::Version
96
108
  version: '0'
109
+ - !ruby/object:Gem::Dependency
110
+ name: pry-byebug
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ type: :development
117
+ prerelease: false
118
+ version_requirements: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
97
123
  - !ruby/object:Gem::Dependency
98
124
  name: rdoc
99
125
  requirement: !ruby/object:Gem::Requirement
@@ -177,6 +203,7 @@ files:
177
203
  - ".coveralls.yml"
178
204
  - ".gitignore"
179
205
  - ".travis.yml"
206
+ - CHANGES.md
180
207
  - Gemfile
181
208
  - LICENSE.txt
182
209
  - README.md
@@ -257,3 +284,4 @@ test_files:
257
284
  - spec/ld4l/ore_rdf/services/proxy/find_spec.rb
258
285
  - spec/ld4l/ore_rdf_spec.rb
259
286
  - spec/spec_helper.rb
287
+ has_rdoc: