amee-data-abstraction 1.3.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -1
- data/CHANGELOG.txt +0 -3
- data/Gemfile +5 -7
- data/Gemfile.lock +20 -14
- data/README.txt +15 -28
- data/Rakefile +17 -16
- data/VERSION +1 -1
- data/amee-data-abstraction.gemspec +21 -24
- data/lib/amee-data-abstraction.rb +6 -0
- data/lib/amee-data-abstraction/calculation.rb +1 -1
- data/lib/amee-data-abstraction/calculation_set.rb +10 -152
- data/lib/amee-data-abstraction/drill.rb +6 -23
- data/lib/amee-data-abstraction/input.rb +0 -24
- data/lib/amee-data-abstraction/ongoing_calculation.rb +9 -13
- data/lib/amee-data-abstraction/term.rb +13 -31
- data/spec/amee-data-abstraction/calculation_set_spec.rb +11 -245
- data/spec/amee-data-abstraction/calculation_spec.rb +18 -23
- data/spec/amee-data-abstraction/drill_spec.rb +7 -34
- data/spec/amee-data-abstraction/input_spec.rb +73 -113
- data/spec/amee-data-abstraction/metadatum_spec.rb +1 -1
- data/spec/amee-data-abstraction/ongoing_calculation_spec.rb +29 -45
- data/spec/amee-data-abstraction/profile_spec.rb +2 -2
- data/spec/amee-data-abstraction/prototype_calculation_spec.rb +11 -18
- data/spec/amee-data-abstraction/term_spec.rb +8 -50
- data/spec/amee-data-abstraction/terms_list_spec.rb +12 -16
- data/spec/config/amee_units_spec.rb +2 -1
- data/spec/core-extensions/class_spec.rb +18 -18
- data/spec/core-extensions/hash_spec.rb +2 -1
- data/spec/core-extensions/ordered_hash_spec.rb +2 -1
- data/spec/core-extensions/proc_spec.rb +1 -1
- data/spec/fixtures/{config/electricity.rb → electricity.rb} +2 -2
- data/spec/fixtures/electricity_and_transport.rb +55 -0
- data/spec/fixtures/{config/calculations/transport.rb → transport.rb} +2 -2
- data/spec/spec_helper.rb +7 -43
- metadata +56 -61
- data/init.rb +0 -4
- data/rails/init.rb +0 -32
- data/spec/fixtures/config/calculations/electricity.rb +0 -35
- data/spec/fixtures/config/calculations/electricity_and_transport.rb +0 -53
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amee-data-abstraction
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
|
-
-
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version:
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 2.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- James Hetherington
|
@@ -18,26 +18,28 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date: 2011-
|
21
|
+
date: 2011-09-28 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
|
27
|
+
type: :runtime
|
26
28
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
27
29
|
none: false
|
28
30
|
requirements:
|
29
31
|
- - ~>
|
30
32
|
- !ruby/object:Gem::Version
|
31
|
-
hash:
|
33
|
+
hash: 27
|
32
34
|
segments:
|
33
|
-
-
|
34
|
-
-
|
35
|
-
version: "
|
36
|
-
prerelease: false
|
37
|
-
type: :runtime
|
35
|
+
- 4
|
36
|
+
- 0
|
37
|
+
version: "4.0"
|
38
38
|
requirement: *id001
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
|
+
prerelease: false
|
40
41
|
name: uuidtools
|
42
|
+
type: :runtime
|
41
43
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
42
44
|
none: false
|
43
45
|
requirements:
|
@@ -49,27 +51,27 @@ dependencies:
|
|
49
51
|
- 1
|
50
52
|
- 2
|
51
53
|
version: 2.1.2
|
52
|
-
prerelease: false
|
53
|
-
type: :runtime
|
54
54
|
requirement: *id002
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
+
prerelease: false
|
56
57
|
name: quantify
|
58
|
+
type: :runtime
|
57
59
|
version_requirements: &id003 !ruby/object:Gem::Requirement
|
58
60
|
none: false
|
59
61
|
requirements:
|
60
|
-
- -
|
62
|
+
- - ~>
|
61
63
|
- !ruby/object:Gem::Version
|
62
|
-
hash:
|
64
|
+
hash: 15
|
63
65
|
segments:
|
64
|
-
- 1
|
65
|
-
- 2
|
66
66
|
- 2
|
67
|
-
|
68
|
-
|
69
|
-
|
67
|
+
- 0
|
68
|
+
- 0
|
69
|
+
version: 2.0.0
|
70
70
|
requirement: *id003
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
|
+
prerelease: false
|
72
73
|
name: bundler
|
74
|
+
type: :development
|
73
75
|
version_requirements: &id004 !ruby/object:Gem::Requirement
|
74
76
|
none: false
|
75
77
|
requirements:
|
@@ -81,11 +83,11 @@ dependencies:
|
|
81
83
|
- 0
|
82
84
|
- 0
|
83
85
|
version: 1.0.0
|
84
|
-
prerelease: false
|
85
|
-
type: :development
|
86
86
|
requirement: *id004
|
87
87
|
- !ruby/object:Gem::Dependency
|
88
|
+
prerelease: false
|
88
89
|
name: jeweler
|
90
|
+
type: :development
|
89
91
|
version_requirements: &id005 !ruby/object:Gem::Requirement
|
90
92
|
none: false
|
91
93
|
requirements:
|
@@ -97,70 +99,66 @@ dependencies:
|
|
97
99
|
- 6
|
98
100
|
- 4
|
99
101
|
version: 1.6.4
|
100
|
-
prerelease: false
|
101
|
-
type: :development
|
102
102
|
requirement: *id005
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
|
+
prerelease: false
|
104
105
|
name: rspec
|
106
|
+
type: :development
|
105
107
|
version_requirements: &id006 !ruby/object:Gem::Requirement
|
106
108
|
none: false
|
107
109
|
requirements:
|
108
110
|
- - "="
|
109
111
|
- !ruby/object:Gem::Version
|
110
|
-
hash:
|
112
|
+
hash: 23
|
111
113
|
segments:
|
112
|
-
-
|
113
|
-
-
|
114
|
+
- 2
|
115
|
+
- 6
|
114
116
|
- 0
|
115
|
-
version:
|
116
|
-
prerelease: false
|
117
|
-
type: :development
|
117
|
+
version: 2.6.0
|
118
118
|
requirement: *id006
|
119
119
|
- !ruby/object:Gem::Dependency
|
120
|
-
|
120
|
+
prerelease: false
|
121
|
+
name: flexmock
|
122
|
+
type: :development
|
121
123
|
version_requirements: &id007 !ruby/object:Gem::Requirement
|
122
124
|
none: false
|
123
125
|
requirements:
|
124
|
-
- - "
|
126
|
+
- - ">"
|
125
127
|
- !ruby/object:Gem::Version
|
126
|
-
hash:
|
128
|
+
hash: 51
|
127
129
|
segments:
|
128
130
|
- 0
|
129
|
-
|
130
|
-
|
131
|
-
|
131
|
+
- 8
|
132
|
+
- 6
|
133
|
+
version: 0.8.6
|
132
134
|
requirement: *id007
|
133
135
|
- !ruby/object:Gem::Dependency
|
134
|
-
|
136
|
+
prerelease: false
|
137
|
+
name: rcov
|
138
|
+
type: :development
|
135
139
|
version_requirements: &id008 !ruby/object:Gem::Requirement
|
136
140
|
none: false
|
137
141
|
requirements:
|
138
|
-
- - "
|
142
|
+
- - ">="
|
139
143
|
- !ruby/object:Gem::Version
|
140
|
-
hash:
|
144
|
+
hash: 3
|
141
145
|
segments:
|
142
|
-
-
|
143
|
-
|
144
|
-
- 3
|
145
|
-
version: 1.1.3
|
146
|
-
prerelease: false
|
147
|
-
type: :development
|
146
|
+
- 0
|
147
|
+
version: "0"
|
148
148
|
requirement: *id008
|
149
149
|
- !ruby/object:Gem::Dependency
|
150
|
-
|
150
|
+
prerelease: false
|
151
|
+
name: rdoc
|
152
|
+
type: :development
|
151
153
|
version_requirements: &id009 !ruby/object:Gem::Requirement
|
152
154
|
none: false
|
153
155
|
requirements:
|
154
|
-
- - "
|
156
|
+
- - ">="
|
155
157
|
- !ruby/object:Gem::Version
|
156
|
-
hash:
|
158
|
+
hash: 3
|
157
159
|
segments:
|
158
160
|
- 0
|
159
|
-
|
160
|
-
- 6
|
161
|
-
version: 0.8.6
|
162
|
-
prerelease: false
|
163
|
-
type: :development
|
161
|
+
version: "0"
|
164
162
|
requirement: *id009
|
165
163
|
description: Part of the AMEEappkit this gem provides a data abstraction layer, decreasing the amount and detail of development required
|
166
164
|
email: help@amee.com
|
@@ -183,7 +181,6 @@ files:
|
|
183
181
|
- amee-data-abstraction.gemspec
|
184
182
|
- examples/_calculator_form.erb
|
185
183
|
- examples/calculation_controller.rb
|
186
|
-
- init.rb
|
187
184
|
- lib/amee-data-abstraction.rb
|
188
185
|
- lib/amee-data-abstraction/calculation.rb
|
189
186
|
- lib/amee-data-abstraction/calculation_set.rb
|
@@ -203,7 +200,6 @@ files:
|
|
203
200
|
- lib/core-extensions/hash.rb
|
204
201
|
- lib/core-extensions/ordered_hash.rb
|
205
202
|
- lib/core-extensions/proc.rb
|
206
|
-
- rails/init.rb
|
207
203
|
- spec/amee-data-abstraction/calculation_set_spec.rb
|
208
204
|
- spec/amee-data-abstraction/calculation_spec.rb
|
209
205
|
- spec/amee-data-abstraction/drill_spec.rb
|
@@ -219,10 +215,9 @@ files:
|
|
219
215
|
- spec/core-extensions/hash_spec.rb
|
220
216
|
- spec/core-extensions/ordered_hash_spec.rb
|
221
217
|
- spec/core-extensions/proc_spec.rb
|
222
|
-
- spec/fixtures/
|
223
|
-
- spec/fixtures/
|
224
|
-
- spec/fixtures/
|
225
|
-
- spec/fixtures/config/electricity.rb
|
218
|
+
- spec/fixtures/electricity.rb
|
219
|
+
- spec/fixtures/electricity_and_transport.rb
|
220
|
+
- spec/fixtures/transport.rb
|
226
221
|
- spec/spec.opts
|
227
222
|
- spec/spec_helper.rb
|
228
223
|
has_rdoc: true
|
@@ -255,7 +250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
255
250
|
requirements: []
|
256
251
|
|
257
252
|
rubyforge_project:
|
258
|
-
rubygems_version: 1.
|
253
|
+
rubygems_version: 1.4.2
|
259
254
|
signing_key:
|
260
255
|
specification_version: 3
|
261
256
|
summary: Calculation and form building tool hiding details of AMEEconnect
|
data/init.rb
DELETED
data/rails/init.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
|
2
|
-
# Authors:: James Hetherington, James Smith, Andrew Berkeley, George Palmer
|
3
|
-
# Copyright:: Copyright (c) 2011 AMEE UK Ltd
|
4
|
-
# License:: Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# "Software"), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject
|
10
|
-
# to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included
|
13
|
-
# in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
18
|
-
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
19
|
-
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
20
|
-
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
21
|
-
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
|
23
|
-
require 'amee-data-abstraction.rb'
|
24
|
-
|
25
|
-
module AMEE::DataAbstraction
|
26
|
-
|
27
|
-
# Override the connection accessor to provide the global connection in rails apps
|
28
|
-
def self.connection
|
29
|
-
AMEE::Rails.connection
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
calculation { # The application has support for an electricity calculation. :electricity is the internal label used to refer to it
|
2
|
-
label :electricity
|
3
|
-
name "Electricity Consumption"
|
4
|
-
path '/business/energy/electricity/grid'
|
5
|
-
|
6
|
-
drill {
|
7
|
-
fixed 'argentina' #Not to be unset, value pre-given
|
8
|
-
label :country #Name will default to label.humanize if not given
|
9
|
-
path 'country' #Some of the fields on the form are drill-downs, but the application doesn't need to display these differently
|
10
|
-
#type :autocompleting_text_box #default for a drill with entries is probably a dropdown
|
11
|
-
}
|
12
|
-
|
13
|
-
profile {
|
14
|
-
label :energy_used
|
15
|
-
# Symbol provided here is used in generating html ids for elements etc
|
16
|
-
path 'energyPerTime' #The amee profile item value corresponding to the field
|
17
|
-
name "Energy Used" #The display name used on the form
|
18
|
-
unit "kWh" #Default unit choice
|
19
|
-
interface :text_box #Probably not needed, as likely to be the default for profile item value unsets
|
20
|
-
validation lambda{|x|x.is_a? Float} #Probably not needed, as default can be deduced from PIV TYPE in API. Here as illustrative.
|
21
|
-
alternative_units :MWh, :MBTU, :BTU # If these are explcitly specified then the alternatives are limited to only these units. Otherwise all dimensionally equivalent units are available as alternatives by default
|
22
|
-
}
|
23
|
-
|
24
|
-
# Alternatively, the drill might be fixed
|
25
|
-
#permanent :country {
|
26
|
-
# drill_path 'country'
|
27
|
-
# value 'Argentina'
|
28
|
-
|
29
|
-
output { #A marv output value
|
30
|
-
label :co2
|
31
|
-
path 'default' #It's not a marv, use the default output
|
32
|
-
name "Carbon Dioxide"
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
@@ -1,53 +0,0 @@
|
|
1
|
-
all_calculations {
|
2
|
-
metadatum {
|
3
|
-
label :department
|
4
|
-
choices %w{stuff things more_stuff meta_things}
|
5
|
-
}
|
6
|
-
}
|
7
|
-
|
8
|
-
calculation{
|
9
|
-
name 'electricity'
|
10
|
-
label :electricity
|
11
|
-
path '/business/energy/electricity/grid'
|
12
|
-
profile {
|
13
|
-
label :usage
|
14
|
-
name 'Electricity Used'
|
15
|
-
path 'energyPerTime'
|
16
|
-
}
|
17
|
-
drill {
|
18
|
-
label :country
|
19
|
-
path 'country'
|
20
|
-
fixed 'Argentina'
|
21
|
-
}
|
22
|
-
output {
|
23
|
-
label :co2
|
24
|
-
path 'default'
|
25
|
-
}
|
26
|
-
}
|
27
|
-
|
28
|
-
calculation {
|
29
|
-
name 'transport'
|
30
|
-
label :transport
|
31
|
-
path '/transport/car/generic'
|
32
|
-
|
33
|
-
drill {
|
34
|
-
path 'fuel'
|
35
|
-
label :fuel
|
36
|
-
name 'Fuel Type'
|
37
|
-
}
|
38
|
-
drill {
|
39
|
-
path 'size'
|
40
|
-
label :size
|
41
|
-
name 'Vehicle Size'
|
42
|
-
}
|
43
|
-
profile {
|
44
|
-
path 'distance'
|
45
|
-
label :distance
|
46
|
-
name 'Distance Driven'
|
47
|
-
}
|
48
|
-
output {
|
49
|
-
label :co2
|
50
|
-
path 'default'
|
51
|
-
name 'Carbon Dioxide'
|
52
|
-
}
|
53
|
-
}
|