rubydora 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.8
1
+ 0.1.9
@@ -123,14 +123,14 @@ module Rubydora
123
123
  # @return [Array<Rubydora::Datastream>]
124
124
  def datastreams
125
125
  @datastreams ||= begin
126
- h = Hash.new { |h,k| h[k] = Datastream.new self, k }
126
+ h = Hash.new { |h,k| h[k] = datastream_object_for(k) }
127
127
 
128
128
  begin
129
129
  datastreams_xml = repository.datastreams(:pid => pid)
130
130
  datastreams_xml.gsub! '<objectDatastreams', '<objectDatastreams xmlns="http://www.fedora.info/definitions/1/0/access/"' unless datastreams_xml =~ /xmlns=/
131
131
  doc = Nokogiri::XML(datastreams_xml)
132
132
  doc.xpath('//access:datastream', {'access' => "http://www.fedora.info/definitions/1/0/access/"}).each do |ds|
133
- h[ds['dsid']] = Datastream.new self, ds['dsid']
133
+ h[ds['dsid']] = datastream_object_for ds['dsid']
134
134
  end
135
135
  rescue RestClient::ResourceNotFound
136
136
  end
@@ -224,5 +224,11 @@ module Rubydora
224
224
  self
225
225
  end
226
226
 
227
+ # instantiate a datastream object for a dsid
228
+ # @param [String] dsid
229
+ # @return [Datastream]
230
+ def datastream_object_for dsid
231
+ Datastream.new self, dsid
232
+ end
227
233
  end
228
234
  end
@@ -73,12 +73,14 @@ describe Rubydora::DigitalObject do
73
73
  describe "retreive" do
74
74
  before(:each) do
75
75
  @mock_repository = mock(Rubydora::Repository)
76
+ @mock_repository.stub :datastreams do |hash|
77
+ "<objectDatastreams><datastream dsid='a'></datastream>><datastream dsid='b'></datastream>><datastream dsid='c'></datastream></objectDatastreams>"
78
+ end
76
79
  @object = Rubydora::DigitalObject.new 'pid', @mock_repository
77
80
  end
78
81
 
79
82
  describe "datastreams" do
80
83
  it "should provide a hash populated by the existing datastreams" do
81
- @mock_repository.should_receive(:datastreams).with(:pid => 'pid').and_return("<objectDatastreams><datastream dsid='a'></datastream>><datastream dsid='b'></datastream>><datastream dsid='c'></datastream></objectDatastreams>")
82
84
 
83
85
  @object.datastreams.should have_key("a")
84
86
  @object.datastreams.should have_key("b")
@@ -86,7 +88,6 @@ describe Rubydora::DigitalObject do
86
88
  end
87
89
 
88
90
  it "should allow other datastreams to be added" do
89
- @mock_repository.should_receive(:datastreams).with(:pid => 'pid').and_return("<objectDatastreams><datastream dsid='a'></datastream>><datastream dsid='b'></datastream>><datastream dsid='c'></datastream></objectDatastreams>")
90
91
  @mock_repository.should_receive(:datastream).with(:pid => 'pid', :dsid => 'z').and_raise(RestClient::ResourceNotFound)
91
92
 
92
93
  @object.datastreams.length.should == 3
@@ -99,11 +100,20 @@ describe Rubydora::DigitalObject do
99
100
  end
100
101
 
101
102
  it "should let datastreams be accessed via hash notation" do
102
- @mock_repository.should_receive(:datastreams).with(:pid => 'pid').and_return("<objectDatastreams><datastream dsid='a'></datastream>><datastream dsid='b'></datastream>><datastream dsid='c'></datastream></objectDatastreams>")
103
103
 
104
104
  @object['a'].should be_a_kind_of(Rubydora::Datastream)
105
105
  @object['a'].should == @object.datastreams['a']
106
106
  end
107
+
108
+ it "should provide a way to override the type of datastream object to use" do
109
+ class MyCustomDatastreamClass < Rubydora::Datastream; end
110
+ object = Rubydora::DigitalObject.new 'pid', @mock_repository
111
+ object.stub(:datastream_object_for) do |dsid|
112
+ MyCustomDatastreamClass.new(self, dsid)
113
+ end
114
+
115
+ object.datastreams['asdf'].should be_a_kind_of(MyCustomDatastreamClass)
116
+ end
107
117
 
108
118
  end
109
119
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubydora
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
5
- prerelease:
4
+ prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 1
9
- - 8
10
- version: 0.1.8
8
+ - 9
9
+ segments_generated: true
10
+ version: 0.1.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Chris Beer
@@ -19,173 +19,173 @@ date: 2011-10-17 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ name: fastercsv
23
+ requirement: &id001 !ruby/object:Gem::Requirement
23
24
  none: false
24
25
  requirements:
25
26
  - - ">="
26
27
  - !ruby/object:Gem::Version
27
- hash: 3
28
28
  segments:
29
29
  - 0
30
+ segments_generated: true
30
31
  version: "0"
31
- name: fastercsv
32
32
  type: :runtime
33
33
  prerelease: false
34
- requirement: *id001
34
+ version_requirements: *id001
35
35
  - !ruby/object:Gem::Dependency
36
- version_requirements: &id002 !ruby/object:Gem::Requirement
36
+ name: rest-client
37
+ requirement: &id002 !ruby/object:Gem::Requirement
37
38
  none: false
38
39
  requirements:
39
40
  - - ">="
40
41
  - !ruby/object:Gem::Version
41
- hash: 3
42
42
  segments:
43
43
  - 0
44
+ segments_generated: true
44
45
  version: "0"
45
- name: rest-client
46
46
  type: :runtime
47
47
  prerelease: false
48
- requirement: *id002
48
+ version_requirements: *id002
49
49
  - !ruby/object:Gem::Dependency
50
- version_requirements: &id003 !ruby/object:Gem::Requirement
50
+ name: nokogiri
51
+ requirement: &id003 !ruby/object:Gem::Requirement
51
52
  none: false
52
53
  requirements:
53
54
  - - ">="
54
55
  - !ruby/object:Gem::Version
55
- hash: 3
56
56
  segments:
57
57
  - 0
58
+ segments_generated: true
58
59
  version: "0"
59
- name: nokogiri
60
60
  type: :runtime
61
61
  prerelease: false
62
- requirement: *id003
62
+ version_requirements: *id003
63
63
  - !ruby/object:Gem::Dependency
64
- version_requirements: &id004 !ruby/object:Gem::Requirement
64
+ name: mime-types
65
+ requirement: &id004 !ruby/object:Gem::Requirement
65
66
  none: false
66
67
  requirements:
67
68
  - - ">="
68
69
  - !ruby/object:Gem::Version
69
- hash: 3
70
70
  segments:
71
71
  - 0
72
+ segments_generated: true
72
73
  version: "0"
73
- name: mime-types
74
74
  type: :runtime
75
75
  prerelease: false
76
- requirement: *id004
76
+ version_requirements: *id004
77
77
  - !ruby/object:Gem::Dependency
78
- version_requirements: &id005 !ruby/object:Gem::Requirement
78
+ name: activesupport
79
+ requirement: &id005 !ruby/object:Gem::Requirement
79
80
  none: false
80
81
  requirements:
81
82
  - - ">="
82
83
  - !ruby/object:Gem::Version
83
- hash: 3
84
84
  segments:
85
85
  - 0
86
+ segments_generated: true
86
87
  version: "0"
87
- name: activesupport
88
88
  type: :runtime
89
89
  prerelease: false
90
- requirement: *id005
90
+ version_requirements: *id005
91
91
  - !ruby/object:Gem::Dependency
92
- version_requirements: &id006 !ruby/object:Gem::Requirement
92
+ name: activemodel
93
+ requirement: &id006 !ruby/object:Gem::Requirement
93
94
  none: false
94
95
  requirements:
95
96
  - - ">="
96
97
  - !ruby/object:Gem::Version
97
- hash: 3
98
98
  segments:
99
99
  - 0
100
+ segments_generated: true
100
101
  version: "0"
101
- name: activemodel
102
102
  type: :runtime
103
103
  prerelease: false
104
- requirement: *id006
104
+ version_requirements: *id006
105
105
  - !ruby/object:Gem::Dependency
106
- version_requirements: &id007 !ruby/object:Gem::Requirement
106
+ name: savon
107
+ requirement: &id007 !ruby/object:Gem::Requirement
107
108
  none: false
108
109
  requirements:
109
110
  - - ">="
110
111
  - !ruby/object:Gem::Version
111
- hash: 3
112
112
  segments:
113
113
  - 0
114
+ segments_generated: true
114
115
  version: "0"
115
- name: savon
116
116
  type: :runtime
117
117
  prerelease: false
118
- requirement: *id007
118
+ version_requirements: *id007
119
119
  - !ruby/object:Gem::Dependency
120
- version_requirements: &id008 !ruby/object:Gem::Requirement
120
+ name: rake
121
+ requirement: &id008 !ruby/object:Gem::Requirement
121
122
  none: false
122
123
  requirements:
123
124
  - - ">="
124
125
  - !ruby/object:Gem::Version
125
- hash: 3
126
126
  segments:
127
127
  - 0
128
+ segments_generated: true
128
129
  version: "0"
129
- name: rake
130
130
  type: :development
131
131
  prerelease: false
132
- requirement: *id008
132
+ version_requirements: *id008
133
133
  - !ruby/object:Gem::Dependency
134
- version_requirements: &id009 !ruby/object:Gem::Requirement
134
+ name: shoulda
135
+ requirement: &id009 !ruby/object:Gem::Requirement
135
136
  none: false
136
137
  requirements:
137
138
  - - ">="
138
139
  - !ruby/object:Gem::Version
139
- hash: 3
140
140
  segments:
141
141
  - 0
142
+ segments_generated: true
142
143
  version: "0"
143
- name: shoulda
144
144
  type: :development
145
145
  prerelease: false
146
- requirement: *id009
146
+ version_requirements: *id009
147
147
  - !ruby/object:Gem::Dependency
148
- version_requirements: &id010 !ruby/object:Gem::Requirement
148
+ name: bundler
149
+ requirement: &id010 !ruby/object:Gem::Requirement
149
150
  none: false
150
151
  requirements:
151
152
  - - ">="
152
153
  - !ruby/object:Gem::Version
153
- hash: 3
154
154
  segments:
155
155
  - 0
156
+ segments_generated: true
156
157
  version: "0"
157
- name: bundler
158
158
  type: :development
159
159
  prerelease: false
160
- requirement: *id010
160
+ version_requirements: *id010
161
161
  - !ruby/object:Gem::Dependency
162
- version_requirements: &id011 !ruby/object:Gem::Requirement
162
+ name: rspec
163
+ requirement: &id011 !ruby/object:Gem::Requirement
163
164
  none: false
164
165
  requirements:
165
166
  - - ">="
166
167
  - !ruby/object:Gem::Version
167
- hash: 3
168
168
  segments:
169
169
  - 0
170
+ segments_generated: true
170
171
  version: "0"
171
- name: rspec
172
172
  type: :development
173
173
  prerelease: false
174
- requirement: *id011
174
+ version_requirements: *id011
175
175
  - !ruby/object:Gem::Dependency
176
- version_requirements: &id012 !ruby/object:Gem::Requirement
176
+ name: yard
177
+ requirement: &id012 !ruby/object:Gem::Requirement
177
178
  none: false
178
179
  requirements:
179
180
  - - ">="
180
181
  - !ruby/object:Gem::Version
181
- hash: 3
182
182
  segments:
183
183
  - 0
184
+ segments_generated: true
184
185
  version: "0"
185
- name: yard
186
186
  type: :development
187
187
  prerelease: false
188
- requirement: *id012
188
+ version_requirements: *id012
189
189
  description: "Fedora Commons REST API ruby library : REQUIRES FCREPO 3.4+"
190
190
  email:
191
191
  - chris@cbeer.info
@@ -245,23 +245,25 @@ required_ruby_version: !ruby/object:Gem::Requirement
245
245
  requirements:
246
246
  - - ">="
247
247
  - !ruby/object:Gem::Version
248
- hash: 3
248
+ hash: -2479278186315579295
249
249
  segments:
250
250
  - 0
251
+ segments_generated: true
251
252
  version: "0"
252
253
  required_rubygems_version: !ruby/object:Gem::Requirement
253
254
  none: false
254
255
  requirements:
255
256
  - - ">="
256
257
  - !ruby/object:Gem::Version
257
- hash: 3
258
+ hash: -2479278186315579295
258
259
  segments:
259
260
  - 0
261
+ segments_generated: true
260
262
  version: "0"
261
263
  requirements: []
262
264
 
263
265
  rubyforge_project:
264
- rubygems_version: 1.6.2
266
+ rubygems_version: 1.3.7
265
267
  signing_key:
266
268
  specification_version: 3
267
269
  summary: Fedora Commons REST API ruby library