rubydora 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.3
1
+ 0.2.4
@@ -4,6 +4,7 @@ module Rubydora
4
4
  module RestApiClient
5
5
  # Fedora API documentation available at {https://wiki.duraspace.org/display/FCR30/REST+API}
6
6
  API_DOCUMENTATION = 'https://wiki.duraspace.org/display/FCR30/REST+API'
7
+ VALID_CLIENT_OPTIONS = [:user, :password, :timeout, :open_timeout, :ssl_client_cert, :ssl_client_key]
7
8
  # Create an authorized HTTP client for the Fedora REST API
8
9
  # @param [Hash] config
9
10
  # @option config [String] :url
@@ -11,8 +12,16 @@ module Rubydora
11
12
  # @option config [String] :password
12
13
  # @return [RestClient::Resource]
13
14
  def client config = {}
14
- config = self.config.merge(config)
15
- @client ||= RestClient::Resource.new(config[:url], :user => config[:user], :password => config[:password], :timeout => config[:timeout], :open_timeout => config[:timeout])
15
+ client_config = self.config.merge(config)
16
+ if config.empty? or @config_hash.nil? or (client_config.hash == @config_hash)
17
+ @config_hash = client_config.hash
18
+ url = client_config[:url]
19
+ client_config.delete_if { |k,v| not VALID_CLIENT_OPTIONS.include?(k) }
20
+ client_config[:open_timeout] ||= client_config[:timeout]
21
+ @client ||= RestClient::Resource.new(url, client_config)
22
+ else
23
+ raise ArgumentError, "Attemping to re-initialize #{self.class}#client with different configuration parameters"
24
+ end
16
25
  end
17
26
 
18
27
  # {include:RestApiClient::API_DOCUMENTATION}
data/rubydora.gemspec CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
26
26
 
27
27
  s.add_development_dependency("rake")
28
28
  s.add_development_dependency("shoulda")
29
- s.add_development_dependency("bundler")
29
+ s.add_development_dependency("bundler", ">= 1.0.14")
30
30
  s.add_development_dependency("rspec")
31
31
  s.add_development_dependency("yard")
32
32
  s.add_development_dependency("jettywrapper")
@@ -42,21 +42,10 @@ describe "Integration testing against a live Fedora repository" do
42
42
  obj.new?.should == false
43
43
  end
44
44
 
45
- it "should create parts" do
46
- obj = @repository.find('test:1')
47
- obj2 = @repository.find('test:2')
48
- obj.parts << obj2
49
- end
50
-
51
45
  it "should persist parts" do
52
46
  obj = @repository.find('test:1')
53
47
  end
54
48
 
55
- it "should have a RELS-EXT datastream" do
56
- obj = @repository.find('test:1')
57
- obj.datastreams.keys.should include("RELS-EXT")
58
- end
59
-
60
49
  it "should create a managed datastream" do
61
50
  obj = @repository.find('test:1')
62
51
  obj.save
@@ -7,29 +7,28 @@ describe Rubydora::Repository do
7
7
 
8
8
  describe "client" do
9
9
  it "should return a RestClient resource" do
10
- client = @repository.client :url => 'http://example.org', :user => 'fedoraAdmin', :password => 'fedoraAdmin'
10
+ client = @repository.client
11
11
 
12
12
  client.should be_a_kind_of(RestClient::Resource)
13
13
  end
14
14
  end
15
15
 
16
16
  describe "find" do
17
+ it "should load objects by pid" do
18
+ @mock_object = mock(Rubydora::DigitalObject)
19
+ Rubydora::DigitalObject.should_receive(:find).with("pid", instance_of(Rubydora::Repository)).and_return @mock_object
17
20
 
18
- it "should load objects by pid" do
19
- @mock_object = mock(Rubydora::DigitalObject)
20
- Rubydora::DigitalObject.should_receive(:find).with("pid", instance_of(Rubydora::Repository)).and_return @mock_object
21
-
22
- @repository.find('pid')
23
- end
24
-
21
+ @repository.find('pid')
22
+ end
25
23
  end
26
24
 
27
25
  describe "sparql" do
28
- it "should return csv results for sparql queries" do
29
- resource_index_query = ""
30
- @repository.should_receive(:risearch).with(resource_index_query).and_return("pid\na\nb\nc\n")
26
+ it "should return csv results for sparql queries" do
27
+ resource_index_query = ""
28
+ @repository.should_receive(:risearch).with(resource_index_query).and_return("pid\na\nb\nc\n")
31
29
 
32
- csv = @repository.sparql(resource_index_query)
30
+ csv = @repository.sparql(resource_index_query)
31
+ end
33
32
  end
34
33
 
35
34
  describe "profile" do
@@ -58,9 +57,6 @@ describe Rubydora::Repository do
58
57
  end
59
58
  end
60
59
 
61
-
62
- end
63
-
64
60
  describe "load_api_abstraction" do
65
61
  class ApiAbstractionTestClass < Rubydora::Repository
66
62
  def version; 3.3; end
@@ -76,20 +72,20 @@ end
76
72
  end
77
73
  end
78
74
 
79
- describe "find_by_sparql" do
80
- it "should attempt to load objects from the results of a sparql query" do
75
+ describe "find_by_sparql" do
76
+ it "should attempt to load objects from the results of a sparql query" do
81
77
 
82
- resource_index_query = ""
83
- @repository.should_receive(:risearch).with(resource_index_query).and_return("pid\na\nb\nc\n")
78
+ resource_index_query = ""
79
+ @repository.should_receive(:risearch).with(resource_index_query).and_return("pid\na\nb\nc\n")
84
80
 
85
- @repository.should_receive(:find).with('a').and_return(1)
86
- @repository.should_receive(:find).with('b').and_return(1)
87
- @repository.should_receive(:find).with('c').and_return(1)
81
+ @repository.should_receive(:find).with('a').and_return(1)
82
+ @repository.should_receive(:find).with('b').and_return(1)
83
+ @repository.should_receive(:find).with('c').and_return(1)
88
84
 
89
- objects = @repository.find_by_sparql(resource_index_query)
85
+ objects = @repository.find_by_sparql(resource_index_query)
90
86
 
91
- objects.length.should == 3
92
- end
87
+ objects.length.should == 3
88
+ end
93
89
  end
94
90
 
95
91
  end
@@ -15,6 +15,27 @@ describe Rubydora::RestApiClient do
15
15
  @mock_repository.config = { :url => 'http://example.org',:user => 'fedoraAdmin', :password => 'fedoraAdmin'}
16
16
  end
17
17
 
18
+ it "should create a REST client" do
19
+ client = @mock_repository.client
20
+
21
+ client.should be_a_kind_of(RestClient::Resource)
22
+ client.options[:user].should == 'fedoraAdmin'
23
+ end
24
+
25
+ it "should create a REST client with a client certificate" do
26
+ client = @mock_repository.client :ssl_client_cert => OpenSSL::X509::Certificate.new, :ssl_client_key => OpenSSL::PKey::RSA.new
27
+
28
+ client.options[:user].should == 'fedoraAdmin'
29
+ client.options[:ssl_client_cert].should be_a_kind_of(OpenSSL::X509::Certificate)
30
+ client.options[:ssl_client_key].should be_a_kind_of(OpenSSL::PKey::PKey)
31
+ end
32
+
33
+ it "should raise an exception if client is called twice with different options" do
34
+ client = @mock_repository.client
35
+ lambda { client.should == @mock_repository.client }.should_not raise_error
36
+ lambda { @mock_repository.client(:timeout => 120) }.should raise_error(ArgumentError)
37
+ end
38
+
18
39
  it "should call nextPID" do
19
40
  RestClient::Request.should_receive(:execute).with(hash_including(:url => "http://example.org/objects/nextPID?format=xml"))
20
41
  @mock_repository.next_pid
metadata CHANGED
@@ -1,215 +1,166 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rubydora
3
- version: !ruby/object:Gem::Version
4
- hash: 17
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.4
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 2
9
- - 3
10
- version: 0.2.3
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Chris Beer
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-11-02 00:00:00 -05:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2011-11-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: fastercsv
16
+ requirement: &2156043760 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
23
22
  type: :runtime
24
23
  prerelease: false
25
- version_requirements: &id001 !ruby/object:Gem::Requirement
26
- none: false
27
- requirements:
28
- - - ">="
29
- - !ruby/object:Gem::Version
30
- hash: 3
31
- segments:
32
- - 0
33
- version: "0"
34
- requirement: *id001
35
- - !ruby/object:Gem::Dependency
24
+ version_requirements: *2156043760
25
+ - !ruby/object:Gem::Dependency
36
26
  name: rest-client
27
+ requirement: &2156043100 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
37
33
  type: :runtime
38
34
  prerelease: false
39
- version_requirements: &id002 !ruby/object:Gem::Requirement
40
- none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 3
45
- segments:
46
- - 0
47
- version: "0"
48
- requirement: *id002
49
- - !ruby/object:Gem::Dependency
35
+ version_requirements: *2156043100
36
+ - !ruby/object:Gem::Dependency
50
37
  name: nokogiri
38
+ requirement: &2156042500 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
51
44
  type: :runtime
52
45
  prerelease: false
53
- version_requirements: &id003 !ruby/object:Gem::Requirement
54
- none: false
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- hash: 3
59
- segments:
60
- - 0
61
- version: "0"
62
- requirement: *id003
63
- - !ruby/object:Gem::Dependency
46
+ version_requirements: *2156042500
47
+ - !ruby/object:Gem::Dependency
64
48
  name: mime-types
49
+ requirement: &2156041960 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
65
55
  type: :runtime
66
56
  prerelease: false
67
- version_requirements: &id004 !ruby/object:Gem::Requirement
68
- none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- hash: 3
73
- segments:
74
- - 0
75
- version: "0"
76
- requirement: *id004
77
- - !ruby/object:Gem::Dependency
57
+ version_requirements: *2156041960
58
+ - !ruby/object:Gem::Dependency
78
59
  name: activesupport
60
+ requirement: &2156041220 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
79
66
  type: :runtime
80
67
  prerelease: false
81
- version_requirements: &id005 !ruby/object:Gem::Requirement
82
- none: false
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- hash: 3
87
- segments:
88
- - 0
89
- version: "0"
90
- requirement: *id005
91
- - !ruby/object:Gem::Dependency
68
+ version_requirements: *2156041220
69
+ - !ruby/object:Gem::Dependency
92
70
  name: activemodel
71
+ requirement: &2156040420 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
93
77
  type: :runtime
94
78
  prerelease: false
95
- version_requirements: &id006 !ruby/object:Gem::Requirement
96
- none: false
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- hash: 3
101
- segments:
102
- - 0
103
- version: "0"
104
- requirement: *id006
105
- - !ruby/object:Gem::Dependency
79
+ version_requirements: *2156040420
80
+ - !ruby/object:Gem::Dependency
106
81
  name: savon
82
+ requirement: &2156039900 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
107
88
  type: :runtime
108
89
  prerelease: false
109
- version_requirements: &id007 !ruby/object:Gem::Requirement
110
- none: false
111
- requirements:
112
- - - ">="
113
- - !ruby/object:Gem::Version
114
- hash: 3
115
- segments:
116
- - 0
117
- version: "0"
118
- requirement: *id007
119
- - !ruby/object:Gem::Dependency
90
+ version_requirements: *2156039900
91
+ - !ruby/object:Gem::Dependency
120
92
  name: rake
93
+ requirement: &2156039180 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
121
99
  type: :development
122
100
  prerelease: false
123
- version_requirements: &id008 !ruby/object:Gem::Requirement
124
- none: false
125
- requirements:
126
- - - ">="
127
- - !ruby/object:Gem::Version
128
- hash: 3
129
- segments:
130
- - 0
131
- version: "0"
132
- requirement: *id008
133
- - !ruby/object:Gem::Dependency
101
+ version_requirements: *2156039180
102
+ - !ruby/object:Gem::Dependency
134
103
  name: shoulda
104
+ requirement: &2156037700 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
135
110
  type: :development
136
111
  prerelease: false
137
- version_requirements: &id009 !ruby/object:Gem::Requirement
138
- none: false
139
- requirements:
140
- - - ">="
141
- - !ruby/object:Gem::Version
142
- hash: 3
143
- segments:
144
- - 0
145
- version: "0"
146
- requirement: *id009
147
- - !ruby/object:Gem::Dependency
112
+ version_requirements: *2156037700
113
+ - !ruby/object:Gem::Dependency
148
114
  name: bundler
115
+ requirement: &2156035980 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: 1.0.14
149
121
  type: :development
150
122
  prerelease: false
151
- version_requirements: &id010 !ruby/object:Gem::Requirement
152
- none: false
153
- requirements:
154
- - - ">="
155
- - !ruby/object:Gem::Version
156
- hash: 3
157
- segments:
158
- - 0
159
- version: "0"
160
- requirement: *id010
161
- - !ruby/object:Gem::Dependency
123
+ version_requirements: *2156035980
124
+ - !ruby/object:Gem::Dependency
162
125
  name: rspec
126
+ requirement: &2156033100 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
163
132
  type: :development
164
133
  prerelease: false
165
- version_requirements: &id011 !ruby/object:Gem::Requirement
166
- none: false
167
- requirements:
168
- - - ">="
169
- - !ruby/object:Gem::Version
170
- hash: 3
171
- segments:
172
- - 0
173
- version: "0"
174
- requirement: *id011
175
- - !ruby/object:Gem::Dependency
134
+ version_requirements: *2156033100
135
+ - !ruby/object:Gem::Dependency
176
136
  name: yard
137
+ requirement: &2156029880 !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
177
143
  type: :development
178
144
  prerelease: false
179
- version_requirements: &id012 !ruby/object:Gem::Requirement
180
- none: false
181
- requirements:
182
- - - ">="
183
- - !ruby/object:Gem::Version
184
- hash: 3
185
- segments:
186
- - 0
187
- version: "0"
188
- requirement: *id012
189
- - !ruby/object:Gem::Dependency
145
+ version_requirements: *2156029880
146
+ - !ruby/object:Gem::Dependency
190
147
  name: jettywrapper
148
+ requirement: &2156028560 !ruby/object:Gem::Requirement
149
+ none: false
150
+ requirements:
151
+ - - ! '>='
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
191
154
  type: :development
192
155
  prerelease: false
193
- version_requirements: &id013 !ruby/object:Gem::Requirement
194
- none: false
195
- requirements:
196
- - - ">="
197
- - !ruby/object:Gem::Version
198
- hash: 3
199
- segments:
200
- - 0
201
- version: "0"
202
- requirement: *id013
203
- description: "Fedora Commons REST API ruby library : REQUIRES FCREPO 3.4+"
204
- email:
156
+ version_requirements: *2156028560
157
+ description: ! 'Fedora Commons REST API ruby library : REQUIRES FCREPO 3.4+'
158
+ email:
205
159
  - chris@cbeer.info
206
160
  executables: []
207
-
208
161
  extensions: []
209
-
210
162
  extra_rdoc_files: []
211
-
212
- files:
163
+ files:
213
164
  - .gitignore
214
165
  - .gitmodules
215
166
  - Gemfile
@@ -246,41 +197,37 @@ files:
246
197
  - spec/lib/rest_api_client_spec.rb
247
198
  - spec/lib/soap_spec.rb
248
199
  - spec/spec_helper.rb
249
- has_rdoc: true
250
200
  homepage: http://github.com/cbeer/rubydora
251
201
  licenses: []
252
-
253
202
  post_install_message:
254
203
  rdoc_options: []
255
-
256
- require_paths:
204
+ require_paths:
257
205
  - lib
258
- required_ruby_version: !ruby/object:Gem::Requirement
206
+ required_ruby_version: !ruby/object:Gem::Requirement
259
207
  none: false
260
- requirements:
261
- - - ">="
262
- - !ruby/object:Gem::Version
263
- hash: 3
264
- segments:
208
+ requirements:
209
+ - - ! '>='
210
+ - !ruby/object:Gem::Version
211
+ version: '0'
212
+ segments:
265
213
  - 0
266
- version: "0"
267
- required_rubygems_version: !ruby/object:Gem::Requirement
214
+ hash: -2660556362758107972
215
+ required_rubygems_version: !ruby/object:Gem::Requirement
268
216
  none: false
269
- requirements:
270
- - - ">="
271
- - !ruby/object:Gem::Version
272
- hash: 3
273
- segments:
217
+ requirements:
218
+ - - ! '>='
219
+ - !ruby/object:Gem::Version
220
+ version: '0'
221
+ segments:
274
222
  - 0
275
- version: "0"
223
+ hash: -2660556362758107972
276
224
  requirements: []
277
-
278
225
  rubyforge_project:
279
- rubygems_version: 1.6.2
226
+ rubygems_version: 1.8.10
280
227
  signing_key:
281
228
  specification_version: 3
282
229
  summary: Fedora Commons REST API ruby library
283
- test_files:
230
+ test_files:
284
231
  - spec/lib/datastream_spec.rb
285
232
  - spec/lib/digital_object_spec.rb
286
233
  - spec/lib/ext_model_loader_spec.rb
@@ -292,3 +239,4 @@ test_files:
292
239
  - spec/lib/rest_api_client_spec.rb
293
240
  - spec/lib/soap_spec.rb
294
241
  - spec/spec_helper.rb
242
+ has_rdoc: