rubydora 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.2
1
+ 0.5.3
@@ -22,11 +22,18 @@ module Rubydora
22
22
 
23
23
  # accessors for datastream attributes
24
24
  DS_ATTRIBUTES.each do |attribute, profile_name|
25
- class_eval %Q{
26
- def #{attribute.to_s}
27
- @#{attribute} || profile['#{profile_name.to_s}'] || DS_DEFAULT_ATTRIBUTES[:#{attribute}]
25
+ define_method attribute.to_s do
26
+ var = "@#{attribute.to_s}".to_sym
27
+ if instance_variable_defined?(var)
28
+ instance_variable_get var
29
+ elsif profile.has_key? profile_name.to_s
30
+ profile[profile_name.to_s]
31
+ else
32
+ DS_DEFAULT_ATTRIBUTES[attribute.to_sym]
33
+ end
28
34
  end
29
35
 
36
+ class_eval %Q{
30
37
  def #{attribute.to_s}= val
31
38
  #{attribute.to_s}_will_change! unless val == #{attribute.to_s}
32
39
  @#{attribute.to_s} = val
@@ -177,8 +184,7 @@ module Rubydora
177
184
  h['dsSize'] &&= h['dsSize'].to_i rescue h['dsSize']
178
185
  h['dsCreateDate'] &&= Time.parse(h['dsCreateDate']) rescue h['dsCreateDate']
179
186
  h['dsChecksumValid'] &&= h['dsChecksumValid'] == 'true'
180
-
181
-
187
+ h['dsVersionable'] &&= h['dsVersionable'] == 'true'
182
188
  h
183
189
  end
184
190
 
@@ -25,10 +25,20 @@ describe Rubydora::Datastream do
25
25
  it "should have default values" do
26
26
  @datastream.controlGroup == "M"
27
27
  @datastream.dsState.should == "A"
28
- @datastream.versionable.should == true
28
+ @datastream.versionable.should be_true
29
29
  @datastream.changed.should be_empty
30
30
  end
31
31
 
32
+ it "should allow versionable to be set to false" do
33
+ @datastream.versionable = false
34
+ @datastream.versionable.should be_false
35
+ end
36
+
37
+ # it "should cast versionable to boolean" do
38
+ # @datastream.profile['versionable'] = 'true'
39
+ # @datastream.versionable.should be_true
40
+ # end
41
+
32
42
 
33
43
  it "should call the appropriate api on save" do
34
44
  @mock_repository.should_receive(:add_datastream).with(hash_including(:pid => 'pid', :dsid => 'dsid', :controlGroup => 'M', :dsState => 'A'))
@@ -42,6 +52,37 @@ describe Rubydora::Datastream do
42
52
  end
43
53
  end
44
54
 
55
+ describe 'versionable' do
56
+ before(:each) do
57
+ @datastream = Rubydora::Datastream.new @mock_object, 'dsid'
58
+ end
59
+ it "should be nil when it hasn't been set" do
60
+ @mock_repository.should_receive(:datastream).and_return <<-XML
61
+ <datastreamProfile>
62
+ </datastreamProfile>
63
+ XML
64
+ @datastream.versionable.should be_true
65
+ end
66
+
67
+ it "should be true when it's returned as true" do
68
+ @mock_repository.should_receive(:datastream).and_return <<-XML
69
+ <datastreamProfile>
70
+ <dsVersionable>true</dsVersionable>
71
+ </datastreamProfile>
72
+ XML
73
+ @datastream.versionable.should be_true
74
+ end
75
+
76
+ it "should be false when it's returned as false" do
77
+ @mock_repository.should_receive(:datastream).and_return <<-XML
78
+ <datastreamProfile>
79
+ <dsVersionable>false</dsVersionable>
80
+ </datastreamProfile>
81
+ XML
82
+ @datastream.versionable.should be_false
83
+ end
84
+ end
85
+
45
86
  describe 'dsChecksumValid' do
46
87
  before(:each) do
47
88
  @datastream = Rubydora::Datastream.new @mock_object, 'dsid'
@@ -251,7 +292,7 @@ describe Rubydora::Datastream do
251
292
  end
252
293
 
253
294
  it "should look in the object profile" do
254
- subject.should_receive(:profile) { { Rubydora::Datastream::DS_ATTRIBUTES[method.to_sym].to_s => 'qwerty' } }
295
+ subject.should_receive(:profile) { { Rubydora::Datastream::DS_ATTRIBUTES[method.to_sym].to_s => 'qwerty' } }.twice
255
296
  subject.send(method).should == 'qwerty'
256
297
  end
257
298
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubydora
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-06 00:00:00.000000000 Z
12
+ date: 2012-02-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fastercsv
16
- requirement: &70365343748360 !ruby/object:Gem::Requirement
16
+ requirement: &70207867601020 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70365343748360
24
+ version_requirements: *70207867601020
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rest-client
27
- requirement: &70365343747580 !ruby/object:Gem::Requirement
27
+ requirement: &70207867611180 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70365343747580
35
+ version_requirements: *70207867611180
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: nokogiri
38
- requirement: &70365343746620 !ruby/object:Gem::Requirement
38
+ requirement: &70207867610600 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70365343746620
46
+ version_requirements: *70207867610600
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: mime-types
49
- requirement: &70365343776580 !ruby/object:Gem::Requirement
49
+ requirement: &70207867609920 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70365343776580
57
+ version_requirements: *70207867609920
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: activesupport
60
- requirement: &70365343776040 !ruby/object:Gem::Requirement
60
+ requirement: &70207867609280 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70365343776040
68
+ version_requirements: *70207867609280
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: activemodel
71
- requirement: &70365343775300 !ruby/object:Gem::Requirement
71
+ requirement: &70207867607060 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70365343775300
79
+ version_requirements: *70207867607060
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: savon
82
- requirement: &70365343774660 !ruby/object:Gem::Requirement
82
+ requirement: &70207867604800 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *70365343774660
90
+ version_requirements: *70207867604800
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rake
93
- requirement: &70365343774200 !ruby/object:Gem::Requirement
93
+ requirement: &70207867631520 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70365343774200
101
+ version_requirements: *70207867631520
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: shoulda
104
- requirement: &70365343773680 !ruby/object:Gem::Requirement
104
+ requirement: &70207867628840 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70365343773680
112
+ version_requirements: *70207867628840
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: bundler
115
- requirement: &70365343773080 !ruby/object:Gem::Requirement
115
+ requirement: &70207867644580 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: 1.0.14
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70365343773080
123
+ version_requirements: *70207867644580
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: rspec
126
- requirement: &70365343772660 !ruby/object:Gem::Requirement
126
+ requirement: &70207867643500 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *70365343772660
134
+ version_requirements: *70207867643500
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: yard
137
- requirement: &70365343772120 !ruby/object:Gem::Requirement
137
+ requirement: &70207867642360 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,10 +142,10 @@ dependencies:
142
142
  version: '0'
143
143
  type: :development
144
144
  prerelease: false
145
- version_requirements: *70365343772120
145
+ version_requirements: *70207867642360
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: jettywrapper
148
- requirement: &70365343771420 !ruby/object:Gem::Requirement
148
+ requirement: &70207867637120 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ! '>='
@@ -153,7 +153,7 @@ dependencies:
153
153
  version: '0'
154
154
  type: :development
155
155
  prerelease: false
156
- version_requirements: *70365343771420
156
+ version_requirements: *70207867637120
157
157
  description: ! 'Fedora Commons REST API ruby library : REQUIRES FCREPO 3.4+'
158
158
  email:
159
159
  - chris@cbeer.info
@@ -213,7 +213,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
213
213
  version: '0'
214
214
  segments:
215
215
  - 0
216
- hash: -1071574168413423455
216
+ hash: 4404235495484812155
217
217
  required_rubygems_version: !ruby/object:Gem::Requirement
218
218
  none: false
219
219
  requirements:
@@ -222,10 +222,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
222
222
  version: '0'
223
223
  segments:
224
224
  - 0
225
- hash: -1071574168413423455
225
+ hash: 4404235495484812155
226
226
  requirements: []
227
227
  rubyforge_project:
228
- rubygems_version: 1.8.10
228
+ rubygems_version: 1.8.15
229
229
  signing_key:
230
230
  specification_version: 3
231
231
  summary: Fedora Commons REST API ruby library