amee-data-persistence 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.0
1
+ 2.2.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{amee-data-persistence}
8
- s.version = "2.1.0"
8
+ s.version = "2.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["James Hetherington", "Andrew Berkeley", "James Smith", "George Palmer"]
12
- s.date = %q{2011-10-18}
12
+ s.date = %q{2011-10-20}
13
13
  s.description = %q{Part of the AMEEappkit, this gem provides storage and retrival of data provided by the amee-data-abstraction gem}
14
14
  s.email = %q{help@amee.com}
15
15
  s.extra_rdoc_files = [
@@ -52,7 +52,7 @@ Gem::Specification.new do |s|
52
52
  s.homepage = %q{http://github.com/AMEE/amee-data-persistence}
53
53
  s.licenses = ["BSD 3-Clause"]
54
54
  s.require_paths = ["lib"]
55
- s.rubygems_version = %q{1.5.3}
55
+ s.rubygems_version = %q{1.4.2}
56
56
  s.summary = %q{Persistent storage of calculations performed against the AMEE API}
57
57
 
58
58
  if s.respond_to? :specification_version then
@@ -34,9 +34,13 @@ module AMEE
34
34
 
35
35
  # Same as <i>save</i> but raises an exception on error
36
36
  def save!
37
- validate!
38
- record = db_calculation || get_db_calculation
39
- record.update_calculation!(to_hash)
37
+ if dirty?
38
+ validate!
39
+ record = db_calculation || get_db_calculation
40
+ record.update_calculation!(to_hash)
41
+ else
42
+ true
43
+ end
40
44
  end
41
45
 
42
46
  # Saves a representation of <tt>self<tt> to the database. Returns
@@ -39,7 +39,7 @@ module AMEE
39
39
  private
40
40
 
41
41
  def load_storage_method
42
- m = YAML.load_file("#{::Rails.root}/config/persistence.yml")['method'].to_sym rescue nil
42
+ m = YAML.load_file("#{::Rails.root}/config/persistence.yml")['method'].to_sym
43
43
  raise "amee-data-persistence: Invalid storage method" unless [:metadata, :outputs, :everything].include? m
44
44
  m
45
45
  end
@@ -197,7 +197,14 @@ describe AMEE::DataAbstraction::OngoingCalculation do
197
197
  record.to_hash[:co2][:value].should == 1200
198
198
  record.to_hash[:usage][:value].should == 6000
199
199
  end
200
-
200
+
201
+ it "should only save if the calculation is dirty" do
202
+ @ongoing_calculation.save.should be_true
203
+ mock = flexmock(@ongoing_calculation)
204
+
205
+ mock.should_receive(:update_calculation!).times(0)
206
+ @ongoing_calculation.save.should be_true
207
+ end
201
208
  end
202
209
 
203
210
  describe "when storage method is :metadata" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amee-data-persistence
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 2.1.0
10
+ version: 2.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - James Hetherington
@@ -18,11 +18,13 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2011-10-18 00:00:00 +01:00
21
+ date: 2011-10-20 00:00:00 +01:00
22
22
  default_executable:
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
25
+ prerelease: false
25
26
  name: amee-data-abstraction
27
+ type: :runtime
26
28
  version_requirements: &id001 !ruby/object:Gem::Requirement
27
29
  none: false
28
30
  requirements:
@@ -34,11 +36,11 @@ dependencies:
34
36
  - 2
35
37
  - 0
36
38
  version: 2.2.0
37
- prerelease: false
38
- type: :runtime
39
39
  requirement: *id001
40
40
  - !ruby/object:Gem::Dependency
41
+ prerelease: false
41
42
  name: activerecord
43
+ type: :runtime
42
44
  version_requirements: &id002 !ruby/object:Gem::Requirement
43
45
  none: false
44
46
  requirements:
@@ -50,11 +52,11 @@ dependencies:
50
52
  - 0
51
53
  - 10
52
54
  version: 3.0.10
53
- prerelease: false
54
- type: :runtime
55
55
  requirement: *id002
56
56
  - !ruby/object:Gem::Dependency
57
+ prerelease: false
57
58
  name: bundler
59
+ type: :development
58
60
  version_requirements: &id003 !ruby/object:Gem::Requirement
59
61
  none: false
60
62
  requirements:
@@ -66,11 +68,11 @@ dependencies:
66
68
  - 0
67
69
  - 0
68
70
  version: 1.0.0
69
- prerelease: false
70
- type: :development
71
71
  requirement: *id003
72
72
  - !ruby/object:Gem::Dependency
73
+ prerelease: false
73
74
  name: jeweler
75
+ type: :development
74
76
  version_requirements: &id004 !ruby/object:Gem::Requirement
75
77
  none: false
76
78
  requirements:
@@ -82,11 +84,11 @@ dependencies:
82
84
  - 6
83
85
  - 4
84
86
  version: 1.6.4
85
- prerelease: false
86
- type: :development
87
87
  requirement: *id004
88
88
  - !ruby/object:Gem::Dependency
89
+ prerelease: false
89
90
  name: rspec
91
+ type: :development
90
92
  version_requirements: &id005 !ruby/object:Gem::Requirement
91
93
  none: false
92
94
  requirements:
@@ -98,11 +100,11 @@ dependencies:
98
100
  - 6
99
101
  - 0
100
102
  version: 2.6.0
101
- prerelease: false
102
- type: :development
103
103
  requirement: *id005
104
104
  - !ruby/object:Gem::Dependency
105
+ prerelease: false
105
106
  name: flexmock
107
+ type: :development
106
108
  version_requirements: &id006 !ruby/object:Gem::Requirement
107
109
  none: false
108
110
  requirements:
@@ -114,11 +116,11 @@ dependencies:
114
116
  - 8
115
117
  - 6
116
118
  version: 0.8.6
117
- prerelease: false
118
- type: :development
119
119
  requirement: *id006
120
120
  - !ruby/object:Gem::Dependency
121
+ prerelease: false
121
122
  name: rcov
123
+ type: :development
122
124
  version_requirements: &id007 !ruby/object:Gem::Requirement
123
125
  none: false
124
126
  requirements:
@@ -128,11 +130,11 @@ dependencies:
128
130
  segments:
129
131
  - 0
130
132
  version: "0"
131
- prerelease: false
132
- type: :development
133
133
  requirement: *id007
134
134
  - !ruby/object:Gem::Dependency
135
+ prerelease: false
135
136
  name: rdoc
137
+ type: :development
136
138
  version_requirements: &id008 !ruby/object:Gem::Requirement
137
139
  none: false
138
140
  requirements:
@@ -142,11 +144,11 @@ dependencies:
142
144
  segments:
143
145
  - 0
144
146
  version: "0"
145
- prerelease: false
146
- type: :development
147
147
  requirement: *id008
148
148
  - !ruby/object:Gem::Dependency
149
+ prerelease: false
149
150
  name: sqlite3
151
+ type: :development
150
152
  version_requirements: &id009 !ruby/object:Gem::Requirement
151
153
  none: false
152
154
  requirements:
@@ -156,8 +158,6 @@ dependencies:
156
158
  segments:
157
159
  - 0
158
160
  version: "0"
159
- prerelease: false
160
- type: :development
161
161
  requirement: *id009
162
162
  description: Part of the AMEEappkit, this gem provides storage and retrival of data provided by the amee-data-abstraction gem
163
163
  email: help@amee.com
@@ -230,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
230
230
  requirements: []
231
231
 
232
232
  rubyforge_project:
233
- rubygems_version: 1.5.3
233
+ rubygems_version: 1.4.2
234
234
  signing_key:
235
235
  specification_version: 3
236
236
  summary: Persistent storage of calculations performed against the AMEE API