amee-data-persistence 2.0.3 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.txt CHANGED
@@ -1,4 +1,10 @@
1
1
  = Changelog
2
2
 
3
+ == 2.1.0
4
+ * Update for supporting the new handling of Calculation Sets in amee-data-abstraction
5
+
6
+ == 2.0.0
7
+ * Update for supporting Rails 3
8
+
3
9
  == 1.0.0
4
10
  * Initial public release
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "amee-data-abstraction", "~> 2.0"
3
+ gem "amee-data-abstraction", "~> 2.2.0"
4
4
  gem 'activerecord', '~> 3.0.10'
5
5
 
6
6
  group :development do
data/Gemfile.lock CHANGED
@@ -16,7 +16,7 @@ GEM
16
16
  json
17
17
  log4r
18
18
  nokogiri (~> 1.4.3.1)
19
- amee-data-abstraction (2.0.0)
19
+ amee-data-abstraction (2.2.0)
20
20
  amee (~> 4.0)
21
21
  quantify (~> 2.0.0)
22
22
  uuidtools (= 2.1.2)
@@ -56,7 +56,7 @@ PLATFORMS
56
56
 
57
57
  DEPENDENCIES
58
58
  activerecord (~> 3.0.10)
59
- amee-data-abstraction (~> 2.0)
59
+ amee-data-abstraction (~> 2.2.0)
60
60
  bundler (~> 1.0.0)
61
61
  flexmock (> 0.8.6)
62
62
  jeweler (~> 1.6.4)
data/README.txt CHANGED
@@ -86,4 +86,7 @@ where <storage_level> can be either 'everything', 'outputs' or 'metadata', e.g.,
86
86
 
87
87
  my_calculation.save #=> true
88
88
 
89
- my_calculation.delete #=> nil
89
+ my_calculation.delete #=> nil
90
+
91
+ n order to use the persistence library, prototype calculations must be held within
92
+ instances of the AMEE::DataAbstraction::CalculationSet class
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.2
1
+ 2.1.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.0.3"
8
+ s.version = "2.1.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-13}
12
+ s.date = %q{2011-10-18}
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 = [
@@ -29,7 +29,7 @@ Gem::Specification.new do |s|
29
29
  "amee-data-persistence.tmproj",
30
30
  "lib/amee-data-persistence.rb",
31
31
  "lib/amee/data_abstraction/calculation_collection.rb",
32
- "lib/amee/data_abstraction/persistence_support.rb",
32
+ "lib/amee/data_abstraction/ongoing_calculation_persistence_support.rb",
33
33
  "lib/amee/db/calculation.rb",
34
34
  "lib/amee/db/config.rb",
35
35
  "lib/amee/db/term.rb",
@@ -41,8 +41,10 @@ Gem::Specification.new do |s|
41
41
  "lib/generators/persistence/templates/db/migrate/004_change_term_column_type.rb",
42
42
  "spec/amee/db/calculation_spec.rb",
43
43
  "spec/amee/db/config_spec.rb",
44
- "spec/amee/db/persistence_support_spec.rb",
44
+ "spec/amee/db/ongoing_calculation_persistence_support_spec.rb",
45
45
  "spec/amee/db/term_spec.rb",
46
+ "spec/amee/fixtures/config/calculations/electricity.lock.rb",
47
+ "spec/amee/fixtures/config/calculations/electricity.rb",
46
48
  "spec/database.yml",
47
49
  "spec/spec.opts",
48
50
  "spec/spec_helper.rb"
@@ -50,14 +52,14 @@ Gem::Specification.new do |s|
50
52
  s.homepage = %q{http://github.com/AMEE/amee-data-persistence}
51
53
  s.licenses = ["BSD 3-Clause"]
52
54
  s.require_paths = ["lib"]
53
- s.rubygems_version = %q{1.4.2}
55
+ s.rubygems_version = %q{1.5.3}
54
56
  s.summary = %q{Persistent storage of calculations performed against the AMEE API}
55
57
 
56
58
  if s.respond_to? :specification_version then
57
59
  s.specification_version = 3
58
60
 
59
61
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
60
- s.add_runtime_dependency(%q<amee-data-abstraction>, ["~> 2.0"])
62
+ s.add_runtime_dependency(%q<amee-data-abstraction>, ["~> 2.2.0"])
61
63
  s.add_runtime_dependency(%q<activerecord>, ["~> 3.0.10"])
62
64
  s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
63
65
  s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
@@ -67,7 +69,7 @@ Gem::Specification.new do |s|
67
69
  s.add_development_dependency(%q<rdoc>, [">= 0"])
68
70
  s.add_development_dependency(%q<sqlite3>, [">= 0"])
69
71
  else
70
- s.add_dependency(%q<amee-data-abstraction>, ["~> 2.0"])
72
+ s.add_dependency(%q<amee-data-abstraction>, ["~> 2.2.0"])
71
73
  s.add_dependency(%q<activerecord>, ["~> 3.0.10"])
72
74
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
73
75
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
@@ -78,7 +80,7 @@ Gem::Specification.new do |s|
78
80
  s.add_dependency(%q<sqlite3>, [">= 0"])
79
81
  end
80
82
  else
81
- s.add_dependency(%q<amee-data-abstraction>, ["~> 2.0"])
83
+ s.add_dependency(%q<amee-data-abstraction>, ["~> 2.2.0"])
82
84
  s.add_dependency(%q<activerecord>, ["~> 3.0.10"])
83
85
  s.add_dependency(%q<bundler>, ["~> 1.0.0"])
84
86
  s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
@@ -7,7 +7,7 @@ require 'quantify'
7
7
  require 'amee-data-abstraction'
8
8
 
9
9
  require 'amee/data_abstraction/calculation_collection'
10
- require 'amee/data_abstraction/persistence_support'
10
+ require 'amee/data_abstraction/ongoing_calculation_persistence_support'
11
11
  require 'amee/db/calculation'
12
12
  require 'amee/db/term'
13
13
  require 'amee/db/config'
@@ -223,7 +223,7 @@ module AMEE
223
223
  unless record.is_a? AMEE::Db::Calculation
224
224
  raise ArgumentError.new("Argument is not of class AMEE::Db::Calculation")
225
225
  end
226
- calc = Calculations.calculations[record.type].begin_calculation
226
+ calc = AMEE::DataAbstraction::CalculationSet.find_prototype_calculation(record.type).begin_calculation
227
227
  calc.db_calculation = record
228
228
  # Means that validation needs to occur before calcs are saved
229
229
  calc.choose_without_validation!(record.to_hash)
@@ -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 rescue nil
43
43
  raise "amee-data-persistence: Invalid storage method" unless [:metadata, :outputs, :everything].include? m
44
44
  m
45
45
  end
@@ -2,7 +2,7 @@ class ChangeTermColumnType < ActiveRecord::Migration
2
2
  def self.up
3
3
  remove_index :terms, :name => "label_name_calc_id_index"
4
4
  change_column :terms, :value, :text
5
- execute "CREATE INDEX `label_value_calc_id_index` ON `terms` (label, value(20), calculation_id)"
5
+ add_index :terms, [:label, :value, :calculation_id], :name => "label_value_calc_id_index", :length => { :value => 20 }
6
6
  end
7
7
 
8
8
  def self.down
@@ -4,7 +4,7 @@ describe AMEE::DataAbstraction::OngoingCalculation do
4
4
 
5
5
  before(:each) do
6
6
  populate_db
7
- initialize_calculation_set
7
+ AMEE::DataAbstraction::CalculationSet.find("electricity")
8
8
  end
9
9
 
10
10
  after(:each) do
@@ -133,8 +133,8 @@ describe AMEE::DataAbstraction::OngoingCalculation do
133
133
 
134
134
 
135
135
  it "should give nil id, if not saved" do
136
- Calculations[:electricity].begin_calculation.db_calculation.should be_nil
137
- Calculations[:electricity].begin_calculation.id.should be_nil
136
+ AMEE::DataAbstraction::CalculationSet.find("electricity")[:electricity].begin_calculation.db_calculation.should be_nil
137
+ AMEE::DataAbstraction::CalculationSet.find("electricity")[:electricity].begin_calculation.id.should be_nil
138
138
  end
139
139
  end
140
140
 
@@ -0,0 +1,30 @@
1
+ calculation {
2
+
3
+ name "Electricity"
4
+ label :electricity
5
+ path "/business/energy/electricity/grid"
6
+
7
+ drill {
8
+ name "Country"
9
+ label :country
10
+ path "country"
11
+ value "Argentina"
12
+ fixed "Argentina"
13
+ interface :drop_down
14
+ }
15
+
16
+ profile {
17
+ name "Electricity Used"
18
+ label :usage
19
+ path "energyPerTime"
20
+ interface :text_box
21
+ }
22
+
23
+ output {
24
+ name "Carbon Dioxide"
25
+ label :co2
26
+ path "default"
27
+ }
28
+
29
+ }
30
+
@@ -0,0 +1,25 @@
1
+ calculation {
2
+
3
+ name 'Electricity'
4
+ label :electricity
5
+ path '/business/energy/electricity/grid'
6
+
7
+ drill {
8
+ label :country
9
+ path 'country'
10
+ fixed 'Argentina'
11
+ }
12
+
13
+ profile {
14
+ label :usage
15
+ name 'Electricity Used'
16
+ path 'energyPerTime'
17
+ }
18
+
19
+ output {
20
+ label :co2
21
+ name 'Carbon Dioxide'
22
+ path 'default'
23
+ }
24
+
25
+ }
data/spec/spec_helper.rb CHANGED
@@ -8,7 +8,11 @@ RSpec.configure do |config|
8
8
  config.mock_with :flexmock
9
9
  end
10
10
 
11
- RAILS_ROOT = '.'
11
+ class Rails
12
+ def self.root
13
+ File.dirname(__FILE__) + '/amee/fixtures'
14
+ end
15
+ end
12
16
 
13
17
  DB_CONFIG = YAML.load_file(File.dirname(__FILE__) + '/database.yml')
14
18
  DB_MIGRATION = File.join(File.dirname(__FILE__), '..','lib','generators','persistence','templates','db','migrate')
@@ -57,29 +61,4 @@ def populate_db
57
61
  [ calculation_one, calculation_two, calculation_three ].each do |attr|
58
62
  AMEE::Db::Calculation.new { |calc| calc.update_calculation! attr }
59
63
  end
60
- end
61
-
62
- def initialize_calculation_set
63
- eval "Calculations = AMEE::DataAbstraction::CalculationSet.new {
64
- calculation{
65
- name 'Electricity'
66
- label :electricity
67
- path '/business/energy/electricity/grid'
68
- drill {
69
- label :country
70
- path 'country'
71
- fixed 'Argentina'
72
- }
73
- profile {
74
- label :usage
75
- name 'Electricity Used'
76
- path 'energyPerTime'
77
- }
78
- output {
79
- label :co2
80
- name 'Carbon Dioxide'
81
- path :default
82
- }
83
- }
84
- }"
85
- end
64
+ end
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: 9
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
+ - 1
8
9
  - 0
9
- - 3
10
- version: 2.0.3
10
+ version: 2.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - James Hetherington
@@ -18,28 +18,27 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2011-10-13 00:00:00 +01:00
21
+ date: 2011-10-18 00:00:00 +01:00
22
22
  default_executable:
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency
25
- prerelease: false
26
25
  name: amee-data-abstraction
27
- type: :runtime
28
26
  version_requirements: &id001 !ruby/object:Gem::Requirement
29
27
  none: false
30
28
  requirements:
31
29
  - - ~>
32
30
  - !ruby/object:Gem::Version
33
- hash: 3
31
+ hash: 7
34
32
  segments:
35
33
  - 2
34
+ - 2
36
35
  - 0
37
- version: "2.0"
36
+ version: 2.2.0
37
+ prerelease: false
38
+ type: :runtime
38
39
  requirement: *id001
39
40
  - !ruby/object:Gem::Dependency
40
- prerelease: false
41
41
  name: activerecord
42
- type: :runtime
43
42
  version_requirements: &id002 !ruby/object:Gem::Requirement
44
43
  none: false
45
44
  requirements:
@@ -51,11 +50,11 @@ dependencies:
51
50
  - 0
52
51
  - 10
53
52
  version: 3.0.10
53
+ prerelease: false
54
+ type: :runtime
54
55
  requirement: *id002
55
56
  - !ruby/object:Gem::Dependency
56
- prerelease: false
57
57
  name: bundler
58
- type: :development
59
58
  version_requirements: &id003 !ruby/object:Gem::Requirement
60
59
  none: false
61
60
  requirements:
@@ -67,11 +66,11 @@ dependencies:
67
66
  - 0
68
67
  - 0
69
68
  version: 1.0.0
69
+ prerelease: false
70
+ type: :development
70
71
  requirement: *id003
71
72
  - !ruby/object:Gem::Dependency
72
- prerelease: false
73
73
  name: jeweler
74
- type: :development
75
74
  version_requirements: &id004 !ruby/object:Gem::Requirement
76
75
  none: false
77
76
  requirements:
@@ -83,11 +82,11 @@ dependencies:
83
82
  - 6
84
83
  - 4
85
84
  version: 1.6.4
85
+ prerelease: false
86
+ type: :development
86
87
  requirement: *id004
87
88
  - !ruby/object:Gem::Dependency
88
- prerelease: false
89
89
  name: rspec
90
- type: :development
91
90
  version_requirements: &id005 !ruby/object:Gem::Requirement
92
91
  none: false
93
92
  requirements:
@@ -99,11 +98,11 @@ dependencies:
99
98
  - 6
100
99
  - 0
101
100
  version: 2.6.0
101
+ prerelease: false
102
+ type: :development
102
103
  requirement: *id005
103
104
  - !ruby/object:Gem::Dependency
104
- prerelease: false
105
105
  name: flexmock
106
- type: :development
107
106
  version_requirements: &id006 !ruby/object:Gem::Requirement
108
107
  none: false
109
108
  requirements:
@@ -115,11 +114,11 @@ dependencies:
115
114
  - 8
116
115
  - 6
117
116
  version: 0.8.6
117
+ prerelease: false
118
+ type: :development
118
119
  requirement: *id006
119
120
  - !ruby/object:Gem::Dependency
120
- prerelease: false
121
121
  name: rcov
122
- type: :development
123
122
  version_requirements: &id007 !ruby/object:Gem::Requirement
124
123
  none: false
125
124
  requirements:
@@ -129,11 +128,11 @@ dependencies:
129
128
  segments:
130
129
  - 0
131
130
  version: "0"
131
+ prerelease: false
132
+ type: :development
132
133
  requirement: *id007
133
134
  - !ruby/object:Gem::Dependency
134
- prerelease: false
135
135
  name: rdoc
136
- type: :development
137
136
  version_requirements: &id008 !ruby/object:Gem::Requirement
138
137
  none: false
139
138
  requirements:
@@ -143,11 +142,11 @@ dependencies:
143
142
  segments:
144
143
  - 0
145
144
  version: "0"
145
+ prerelease: false
146
+ type: :development
146
147
  requirement: *id008
147
148
  - !ruby/object:Gem::Dependency
148
- prerelease: false
149
149
  name: sqlite3
150
- type: :development
151
150
  version_requirements: &id009 !ruby/object:Gem::Requirement
152
151
  none: false
153
152
  requirements:
@@ -157,6 +156,8 @@ dependencies:
157
156
  segments:
158
157
  - 0
159
158
  version: "0"
159
+ prerelease: false
160
+ type: :development
160
161
  requirement: *id009
161
162
  description: Part of the AMEEappkit, this gem provides storage and retrival of data provided by the amee-data-abstraction gem
162
163
  email: help@amee.com
@@ -180,7 +181,7 @@ files:
180
181
  - amee-data-persistence.tmproj
181
182
  - lib/amee-data-persistence.rb
182
183
  - lib/amee/data_abstraction/calculation_collection.rb
183
- - lib/amee/data_abstraction/persistence_support.rb
184
+ - lib/amee/data_abstraction/ongoing_calculation_persistence_support.rb
184
185
  - lib/amee/db/calculation.rb
185
186
  - lib/amee/db/config.rb
186
187
  - lib/amee/db/term.rb
@@ -192,8 +193,10 @@ files:
192
193
  - lib/generators/persistence/templates/db/migrate/004_change_term_column_type.rb
193
194
  - spec/amee/db/calculation_spec.rb
194
195
  - spec/amee/db/config_spec.rb
195
- - spec/amee/db/persistence_support_spec.rb
196
+ - spec/amee/db/ongoing_calculation_persistence_support_spec.rb
196
197
  - spec/amee/db/term_spec.rb
198
+ - spec/amee/fixtures/config/calculations/electricity.lock.rb
199
+ - spec/amee/fixtures/config/calculations/electricity.rb
197
200
  - spec/database.yml
198
201
  - spec/spec.opts
199
202
  - spec/spec_helper.rb
@@ -227,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
227
230
  requirements: []
228
231
 
229
232
  rubyforge_project:
230
- rubygems_version: 1.4.2
233
+ rubygems_version: 1.5.3
231
234
  signing_key:
232
235
  specification_version: 3
233
236
  summary: Persistent storage of calculations performed against the AMEE API