amee-analytics 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +7 -8
- data/Gemfile.lock +117 -0
- data/Rakefile +15 -29
- data/VERSION +1 -1
- data/amee-analytics.gemspec +29 -28
- data/lib/amee-analytics.rb +8 -2
- data/lib/amee/{data_abstraction → analytics}/calculation_collection_analytics_support.rb +7 -7
- data/lib/amee/{data_abstraction → analytics}/result.rb +2 -2
- data/lib/amee/{data_abstraction → analytics}/term_analytics_support.rb +2 -2
- data/lib/amee/{data_abstraction → analytics}/terms_list_analytics_support.rb +13 -32
- data/spec/amee/analytics/calculation_collection_spec.rb +6 -5
- data/spec/amee/analytics/terms_list_spec.rb +7 -56
- data/spec/spec_helper.rb +63 -27
- metadata +80 -68
- data/init.rb +0 -4
- data/rails/init.rb +0 -9
- data/spec/fixtures/config/calculations/calcs.rb +0 -55
data/Gemfile
CHANGED
@@ -1,16 +1,15 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
3
|
# Dependencies
|
4
|
-
gem "amee-data-abstraction","~>
|
5
|
-
gem "amee-data-persistence","~>
|
4
|
+
gem "amee-data-abstraction","~> 2.0"
|
5
|
+
gem "amee-data-persistence","~> 2.0"
|
6
6
|
|
7
|
-
# Add dependencies to develop your gem here.
|
8
|
-
# Include everything needed to run rake, tests, features, etc.
|
9
7
|
group :development do
|
8
|
+
gem "bundler", "~> 1.0.0"
|
10
9
|
gem "jeweler", "~> 1.6.4"
|
11
|
-
gem
|
10
|
+
gem "rails", "~> 3.0.10"
|
11
|
+
gem 'rspec', '2.6.0'
|
12
|
+
gem 'flexmock', '~> 0.9.0'
|
12
13
|
gem 'rcov'
|
13
|
-
gem '
|
14
|
-
gem 'flexmock', '> 0.8.6'
|
15
|
-
gem 'activerecord', '~> 2.3.5'
|
14
|
+
gem 'rdoc'
|
16
15
|
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
abstract (1.0.0)
|
5
|
+
actionmailer (3.0.10)
|
6
|
+
actionpack (= 3.0.10)
|
7
|
+
mail (~> 2.2.19)
|
8
|
+
actionpack (3.0.10)
|
9
|
+
activemodel (= 3.0.10)
|
10
|
+
activesupport (= 3.0.10)
|
11
|
+
builder (~> 2.1.2)
|
12
|
+
erubis (~> 2.6.6)
|
13
|
+
i18n (~> 0.5.0)
|
14
|
+
rack (~> 1.2.1)
|
15
|
+
rack-mount (~> 0.6.14)
|
16
|
+
rack-test (~> 0.5.7)
|
17
|
+
tzinfo (~> 0.3.23)
|
18
|
+
activemodel (3.0.10)
|
19
|
+
activesupport (= 3.0.10)
|
20
|
+
builder (~> 2.1.2)
|
21
|
+
i18n (~> 0.5.0)
|
22
|
+
activerecord (3.0.10)
|
23
|
+
activemodel (= 3.0.10)
|
24
|
+
activesupport (= 3.0.10)
|
25
|
+
arel (~> 2.0.10)
|
26
|
+
tzinfo (~> 0.3.23)
|
27
|
+
activeresource (3.0.10)
|
28
|
+
activemodel (= 3.0.10)
|
29
|
+
activesupport (= 3.0.10)
|
30
|
+
activesupport (3.0.10)
|
31
|
+
amee (3.0.1)
|
32
|
+
activesupport (~> 3.0.10)
|
33
|
+
json
|
34
|
+
log4r
|
35
|
+
nokogiri (~> 1.4.3.1)
|
36
|
+
amee-data-abstraction (2.0.0)
|
37
|
+
amee (~> 3.0)
|
38
|
+
quantify (~> 2.0.0)
|
39
|
+
uuidtools (= 2.1.2)
|
40
|
+
amee-data-persistence (2.0.0)
|
41
|
+
activerecord (~> 3.0.10)
|
42
|
+
amee-data-abstraction (~> 2.0)
|
43
|
+
arel (2.0.10)
|
44
|
+
builder (2.1.2)
|
45
|
+
diff-lcs (1.1.3)
|
46
|
+
erubis (2.6.6)
|
47
|
+
abstract (>= 1.0.0)
|
48
|
+
flexmock (0.9.0)
|
49
|
+
git (1.2.5)
|
50
|
+
i18n (0.5.0)
|
51
|
+
jeweler (1.6.4)
|
52
|
+
bundler (~> 1.0)
|
53
|
+
git (>= 1.2.5)
|
54
|
+
rake
|
55
|
+
json (1.6.1)
|
56
|
+
log4r (1.1.9)
|
57
|
+
mail (2.2.19)
|
58
|
+
activesupport (>= 2.3.6)
|
59
|
+
i18n (>= 0.4.0)
|
60
|
+
mime-types (~> 1.16)
|
61
|
+
treetop (~> 1.4.8)
|
62
|
+
mime-types (1.16)
|
63
|
+
nokogiri (1.4.3.1)
|
64
|
+
polyglot (0.3.2)
|
65
|
+
quantify (2.0.0)
|
66
|
+
activesupport (~> 3.0.10)
|
67
|
+
i18n
|
68
|
+
rack (1.2.4)
|
69
|
+
rack-mount (0.6.14)
|
70
|
+
rack (>= 1.0.0)
|
71
|
+
rack-test (0.5.7)
|
72
|
+
rack (>= 1.0)
|
73
|
+
rails (3.0.10)
|
74
|
+
actionmailer (= 3.0.10)
|
75
|
+
actionpack (= 3.0.10)
|
76
|
+
activerecord (= 3.0.10)
|
77
|
+
activeresource (= 3.0.10)
|
78
|
+
activesupport (= 3.0.10)
|
79
|
+
bundler (~> 1.0)
|
80
|
+
railties (= 3.0.10)
|
81
|
+
railties (3.0.10)
|
82
|
+
actionpack (= 3.0.10)
|
83
|
+
activesupport (= 3.0.10)
|
84
|
+
rake (>= 0.8.7)
|
85
|
+
rdoc (~> 3.4)
|
86
|
+
thor (~> 0.14.4)
|
87
|
+
rake (0.9.2)
|
88
|
+
rcov (0.9.10)
|
89
|
+
rdoc (3.9.4)
|
90
|
+
rspec (2.6.0)
|
91
|
+
rspec-core (~> 2.6.0)
|
92
|
+
rspec-expectations (~> 2.6.0)
|
93
|
+
rspec-mocks (~> 2.6.0)
|
94
|
+
rspec-core (2.6.4)
|
95
|
+
rspec-expectations (2.6.0)
|
96
|
+
diff-lcs (~> 1.1.2)
|
97
|
+
rspec-mocks (2.6.0)
|
98
|
+
thor (0.14.6)
|
99
|
+
treetop (1.4.10)
|
100
|
+
polyglot
|
101
|
+
polyglot (>= 0.3.1)
|
102
|
+
tzinfo (0.3.29)
|
103
|
+
uuidtools (2.1.2)
|
104
|
+
|
105
|
+
PLATFORMS
|
106
|
+
ruby
|
107
|
+
|
108
|
+
DEPENDENCIES
|
109
|
+
amee-data-abstraction (~> 2.0)
|
110
|
+
amee-data-persistence (~> 2.0)
|
111
|
+
bundler (~> 1.0.0)
|
112
|
+
flexmock (~> 0.9.0)
|
113
|
+
jeweler (~> 1.6.4)
|
114
|
+
rails (~> 3.0.10)
|
115
|
+
rcov
|
116
|
+
rdoc
|
117
|
+
rspec (= 2.6.0)
|
data/Rakefile
CHANGED
@@ -10,16 +10,14 @@ rescue Bundler::BundlerError => e
|
|
10
10
|
exit e.status_code
|
11
11
|
end
|
12
12
|
require 'rake'
|
13
|
-
require '
|
14
|
-
require '
|
13
|
+
require 'rspec'
|
14
|
+
require 'rspec/core/rake_task'
|
15
15
|
|
16
16
|
task :default => [:spec]
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
t.rcov = true
|
22
|
-
t.rcov_opts = ['--exclude', 'spec,/*ruby*,/*gems*']
|
18
|
+
desc "Run specs"
|
19
|
+
RSpec::Core::RakeTask.new do |t|
|
20
|
+
# Put spec opts in a file named .rspec in root
|
23
21
|
end
|
24
22
|
|
25
23
|
require 'jeweler'
|
@@ -71,29 +69,17 @@ Jeweler::Tasks.new do |gem|
|
|
71
69
|
end
|
72
70
|
Jeweler::RubygemsDotOrgTasks.new
|
73
71
|
|
74
|
-
require 'rake/testtask'
|
75
|
-
Rake::TestTask.new(:test) do |test|
|
76
|
-
test.libs << 'lib' << 'test'
|
77
|
-
test.pattern = 'test/**/test_*.rb'
|
78
|
-
test.verbose = true
|
79
|
-
end
|
80
|
-
|
81
72
|
require 'rcov/rcovtask'
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
test.rcov_opts << '--exclude "gems/*"'
|
73
|
+
desc "Generate code coverage"
|
74
|
+
RSpec::Core::RakeTask.new(:coverage) do |t|
|
75
|
+
t.rcov = true
|
76
|
+
t.rcov_opts = ['--exclude', 'spec']
|
87
77
|
end
|
88
78
|
|
89
|
-
task
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
rdoc.rdoc_dir = 'rdoc'
|
96
|
-
rdoc.title = "amee-analytics #{version}"
|
97
|
-
rdoc.rdoc_files.include('README*')
|
98
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
79
|
+
require 'rdoc/task'
|
80
|
+
RDoc::Task.new do |rd|
|
81
|
+
rd.title = "AMEE Analytics"
|
82
|
+
rd.rdoc_dir = 'doc'
|
83
|
+
rd.main = "README"
|
84
|
+
rd.rdoc_files.include("README", "lib/**/*.rb")
|
99
85
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
data/amee-analytics.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{amee-analytics}
|
8
|
-
s.version = "
|
8
|
+
s.version = "2.0.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-
|
12
|
+
s.date = %q{2011-09-28}
|
13
13
|
s.description = %q{Part of the AMEE AppKit, this gem provides the ability to do mathmatical operations over a set of calculations}
|
14
14
|
s.email = %q{help@amee.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -20,62 +20,63 @@ Gem::Specification.new do |s|
|
|
20
20
|
".rvmrc",
|
21
21
|
"CHANGELOG.txt",
|
22
22
|
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
23
24
|
"LICENSE.txt",
|
24
25
|
"README.txt",
|
25
26
|
"Rakefile",
|
26
27
|
"VERSION",
|
27
28
|
"amee-analytics.gemspec",
|
28
|
-
"init.rb",
|
29
29
|
"lib/amee-analytics.rb",
|
30
|
-
"lib/amee/
|
31
|
-
"lib/amee/
|
32
|
-
"lib/amee/
|
33
|
-
"lib/amee/
|
34
|
-
"rails/init.rb",
|
30
|
+
"lib/amee/analytics/calculation_collection_analytics_support.rb",
|
31
|
+
"lib/amee/analytics/result.rb",
|
32
|
+
"lib/amee/analytics/term_analytics_support.rb",
|
33
|
+
"lib/amee/analytics/terms_list_analytics_support.rb",
|
35
34
|
"spec/amee/analytics/calculation_collection_spec.rb",
|
36
35
|
"spec/amee/analytics/term_spec.rb",
|
37
36
|
"spec/amee/analytics/terms_list_spec.rb",
|
38
|
-
"spec/fixtures/config/calculations/calcs.rb",
|
39
37
|
"spec/spec.opts",
|
40
38
|
"spec/spec_helper.rb"
|
41
39
|
]
|
42
40
|
s.homepage = %q{http://github.com/AMEE/amee-analytics}
|
43
41
|
s.licenses = ["MIT"]
|
44
42
|
s.require_paths = ["lib"]
|
45
|
-
s.rubygems_version = %q{1.
|
43
|
+
s.rubygems_version = %q{1.4.2}
|
46
44
|
s.summary = %q{Analytics module for use with AMEE AppKit}
|
47
45
|
|
48
46
|
if s.respond_to? :specification_version then
|
49
47
|
s.specification_version = 3
|
50
48
|
|
51
49
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
52
|
-
s.add_runtime_dependency(%q<amee-data-abstraction>, ["~>
|
53
|
-
s.add_runtime_dependency(%q<amee-data-persistence>, ["~>
|
50
|
+
s.add_runtime_dependency(%q<amee-data-abstraction>, ["~> 2.0"])
|
51
|
+
s.add_runtime_dependency(%q<amee-data-persistence>, ["~> 2.0"])
|
52
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
54
53
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
55
|
-
s.add_development_dependency(%q<
|
54
|
+
s.add_development_dependency(%q<rails>, ["~> 3.0.10"])
|
55
|
+
s.add_development_dependency(%q<rspec>, ["= 2.6.0"])
|
56
|
+
s.add_development_dependency(%q<flexmock>, ["~> 0.9.0"])
|
56
57
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
57
|
-
s.add_development_dependency(%q<
|
58
|
-
s.add_development_dependency(%q<flexmock>, ["> 0.8.6"])
|
59
|
-
s.add_development_dependency(%q<activerecord>, ["~> 2.3.5"])
|
58
|
+
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
60
59
|
else
|
61
|
-
s.add_dependency(%q<amee-data-abstraction>, ["~>
|
62
|
-
s.add_dependency(%q<amee-data-persistence>, ["~>
|
60
|
+
s.add_dependency(%q<amee-data-abstraction>, ["~> 2.0"])
|
61
|
+
s.add_dependency(%q<amee-data-persistence>, ["~> 2.0"])
|
62
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
63
63
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
64
|
-
s.add_dependency(%q<
|
64
|
+
s.add_dependency(%q<rails>, ["~> 3.0.10"])
|
65
|
+
s.add_dependency(%q<rspec>, ["= 2.6.0"])
|
66
|
+
s.add_dependency(%q<flexmock>, ["~> 0.9.0"])
|
65
67
|
s.add_dependency(%q<rcov>, [">= 0"])
|
66
|
-
s.add_dependency(%q<
|
67
|
-
s.add_dependency(%q<flexmock>, ["> 0.8.6"])
|
68
|
-
s.add_dependency(%q<activerecord>, ["~> 2.3.5"])
|
68
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
69
69
|
end
|
70
70
|
else
|
71
|
-
s.add_dependency(%q<amee-data-abstraction>, ["~>
|
72
|
-
s.add_dependency(%q<amee-data-persistence>, ["~>
|
71
|
+
s.add_dependency(%q<amee-data-abstraction>, ["~> 2.0"])
|
72
|
+
s.add_dependency(%q<amee-data-persistence>, ["~> 2.0"])
|
73
|
+
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
73
74
|
s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
|
74
|
-
s.add_dependency(%q<
|
75
|
+
s.add_dependency(%q<rails>, ["~> 3.0.10"])
|
76
|
+
s.add_dependency(%q<rspec>, ["= 2.6.0"])
|
77
|
+
s.add_dependency(%q<flexmock>, ["~> 0.9.0"])
|
75
78
|
s.add_dependency(%q<rcov>, [">= 0"])
|
76
|
-
s.add_dependency(%q<
|
77
|
-
s.add_dependency(%q<flexmock>, ["> 0.8.6"])
|
78
|
-
s.add_dependency(%q<activerecord>, ["~> 2.3.5"])
|
79
|
+
s.add_dependency(%q<rdoc>, [">= 0"])
|
79
80
|
end
|
80
81
|
end
|
81
82
|
|
data/lib/amee-analytics.rb
CHANGED
@@ -2,7 +2,13 @@
|
|
2
2
|
# Released as Open Source Software under the BSD 3-Clause license. See LICENSE.txt for details.
|
3
3
|
|
4
4
|
require 'rubygems'
|
5
|
-
gem 'amee-data-abstraction'
|
6
5
|
require 'amee-data-abstraction'
|
6
|
+
require 'amee-data-persistence'
|
7
|
+
require 'amee/analytics/result'
|
8
|
+
require 'amee/analytics/calculation_collection_analytics_support'
|
9
|
+
require 'amee/analytics/terms_list_analytics_support'
|
10
|
+
require 'amee/analytics/term_analytics_support'
|
7
11
|
|
8
|
-
|
12
|
+
::AMEE::DataAbstraction::CalculationCollection.send :include, AMEE::Analytics::CalculationCollectionAnalyticsSupport
|
13
|
+
::AMEE::DataAbstraction::TermsList.send :include, AMEE::Analytics::TermsListAnalyticsSupport
|
14
|
+
::AMEE::DataAbstraction::Term.send :include, AMEE::Analytics::TermAnalyticsSupport
|
@@ -4,7 +4,7 @@
|
|
4
4
|
# :title: Module: AMEE::DataAbstraction::CalculationCollectionAnalyticsSupport
|
5
5
|
|
6
6
|
module AMEE
|
7
|
-
module
|
7
|
+
module Analytics
|
8
8
|
|
9
9
|
# Mixin module for the <i>AMEE::DataAbstraction::CalculationCollection</i>
|
10
10
|
# class, providing methods for handling collections of calculations.
|
@@ -53,7 +53,7 @@ module AMEE
|
|
53
53
|
#
|
54
54
|
def sort_by(term)
|
55
55
|
term = term.to_sym unless term.is_a? Symbol
|
56
|
-
CalculationCollection.new(send(term).sort_by(:value).map(&:parent))
|
56
|
+
AMEE::DataAbstraction::CalculationCollection.new(send(term).sort_by(:value).map(&:parent))
|
57
57
|
end
|
58
58
|
|
59
59
|
# Sorts the calculation collection in place according to the values on the
|
@@ -107,7 +107,7 @@ module AMEE
|
|
107
107
|
calc.contents[term.label] = term
|
108
108
|
calc
|
109
109
|
end
|
110
|
-
CalculationCollection.new(new_calcs)
|
110
|
+
AMEE::DataAbstraction::CalculationCollection.new(new_calcs)
|
111
111
|
end
|
112
112
|
|
113
113
|
# Similar to <tt>#standardize_units</tt> but standardizes units in place,
|
@@ -122,14 +122,14 @@ module AMEE
|
|
122
122
|
# sums of all outputs represented within the collection
|
123
123
|
#
|
124
124
|
def sum_all_outputs
|
125
|
-
TermsList.new(terms.outputs.visible.labels.uniq.map { |o| send(o).sum })
|
125
|
+
AMEE::DataAbstraction::TermsList.new(terms.outputs.visible.labels.uniq.map { |o| send(o).sum })
|
126
126
|
end
|
127
127
|
|
128
128
|
# Returns a new instance of the class <tt>TermsList</tt> representing either
|
129
129
|
# CO2 or CO2e outputs from each calculation
|
130
130
|
#
|
131
131
|
def co2_or_co2e_outputs
|
132
|
-
terms = TermsList.new
|
132
|
+
terms = AMEE::DataAbstraction::TermsList.new
|
133
133
|
each do |calculation|
|
134
134
|
if calculation['co2e']
|
135
135
|
terms << calculation['co2e']
|
@@ -158,10 +158,10 @@ module AMEE
|
|
158
158
|
# <tt>self</tt>.
|
159
159
|
#
|
160
160
|
def terms
|
161
|
-
TermsList.new( (self.map { |calc| calc.terms.map { |term| term } }).flatten )
|
161
|
+
AMEE::DataAbstraction::TermsList.new( (self.map { |calc| calc.terms.map { |term| term } }).flatten )
|
162
162
|
end
|
163
163
|
|
164
|
-
TermsList::Selectors.each do |sel|
|
164
|
+
AMEE::DataAbstraction::TermsList::Selectors.each do |sel|
|
165
165
|
delegate sel,:to=>:terms
|
166
166
|
end
|
167
167
|
|
@@ -4,12 +4,12 @@
|
|
4
4
|
# :title: Class AMEE::DataAbstraction::Result
|
5
5
|
|
6
6
|
module AMEE
|
7
|
-
module
|
7
|
+
module Analytics
|
8
8
|
|
9
9
|
# Subclass of <tt>Term</tt> providing methods and attributes appropriate for
|
10
10
|
# representing the results of cross calculation operations specifically
|
11
11
|
#
|
12
|
-
class Result < Term
|
12
|
+
class Result < AMEE::DataAbstraction::Term
|
13
13
|
|
14
14
|
end
|
15
15
|
end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# :title: Module: AMEE::DataAbstraction::TermAnalyticsSupport
|
6
6
|
|
7
7
|
module AMEE
|
8
|
-
module
|
8
|
+
module Analytics
|
9
9
|
|
10
10
|
# Mixin module for the <i>AMEE::DataAbstraction::Term</i> class, providing
|
11
11
|
# methods for handling collections of calculations.
|
@@ -17,7 +17,7 @@ module AMEE
|
|
17
17
|
#
|
18
18
|
def to_result
|
19
19
|
result_term = Result.new
|
20
|
-
TermsList::TermProperties.each do |attr|
|
20
|
+
AMEE::DataAbstraction::TermsList::TermProperties.each do |attr|
|
21
21
|
result_term.send(attr, self.send(attr))
|
22
22
|
end
|
23
23
|
return result_term
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# :title: Module: AMEE::DataAbstraction::TermsListAnalyticsSupport
|
6
6
|
|
7
7
|
module AMEE
|
8
|
-
module
|
8
|
+
module Analytics
|
9
9
|
|
10
10
|
# Mixin module for the <i>AMEE::DataAbstraction::Term</i> class, providing
|
11
11
|
# methods for handling collections of calculations.
|
@@ -84,7 +84,7 @@ module AMEE
|
|
84
84
|
def first_of_each_type
|
85
85
|
labels = self.labels.uniq
|
86
86
|
terms = labels.map {|label| find { |term| term.label == label } }
|
87
|
-
TermsList.new(terms)
|
87
|
+
AMEE::DataAbstraction::TermsList.new(terms)
|
88
88
|
end
|
89
89
|
|
90
90
|
# Returns the label of the unit which is predominantly used across all terms
|
@@ -133,7 +133,7 @@ module AMEE
|
|
133
133
|
# operations on
|
134
134
|
#
|
135
135
|
def numeric_terms
|
136
|
-
TermsList.new select { |term| term.has_numeric_value? }
|
136
|
+
AMEE::DataAbstraction::TermsList.new select { |term| term.has_numeric_value? }
|
137
137
|
end
|
138
138
|
|
139
139
|
# Returns a new instance of <i>TermsList</i> with all units standardized and
|
@@ -159,7 +159,7 @@ module AMEE
|
|
159
159
|
unit = predominant_unit if unit.nil?
|
160
160
|
per_unit = predominant_per_unit if per_unit.nil?
|
161
161
|
new_terms = map { |term| term.convert_unit(:unit => unit, :per_unit => per_unit) }
|
162
|
-
TermsList.new new_terms
|
162
|
+
AMEE::DataAbstraction::TermsList.new new_terms
|
163
163
|
end
|
164
164
|
|
165
165
|
# Returns a new instance of <i>Result</i> which represents the sum of all
|
@@ -217,7 +217,7 @@ module AMEE
|
|
217
217
|
if max_groups.size == 1
|
218
218
|
max_groups.first.first.to_result
|
219
219
|
else
|
220
|
-
TermsList.new max_groups.map { |group| group.first.to_result }
|
220
|
+
AMEE::DataAbstraction::TermsList.new max_groups.map { |group| group.first.to_result }
|
221
221
|
end
|
222
222
|
end
|
223
223
|
|
@@ -250,31 +250,12 @@ module AMEE
|
|
250
250
|
Result.new { label label; value value; unit unit; per_unit per_unit }
|
251
251
|
end
|
252
252
|
|
253
|
-
#
|
254
|
-
# The specific term is selected on the basis of one of it's attributes values,
|
255
|
-
# with the attribute to use (e.g. :value, :unit) given by <tt>attr</attr>
|
256
|
-
# and value by <tt>value</tt>. The location within the list to move the term
|
257
|
-
# is given as an index integer value as the final argument.
|
258
|
-
#
|
259
|
-
def move_by(attr,value,index)
|
260
|
-
if attr == :unit || attr == :per_unit
|
261
|
-
value = Unit.for value
|
262
|
-
end
|
263
|
-
term = find {|t| t.send(attr) == value }
|
264
|
-
return if term.nil?
|
265
|
-
delete(term)
|
266
|
-
insert(index, term)
|
267
|
-
end
|
268
|
-
|
269
|
-
# Rotate the list terms by one element - shifts the first-placed term to the
|
270
|
-
# end of the list, advancing all terms forward by one place.
|
271
|
-
def rotate
|
272
|
-
push(self.shift)
|
273
|
-
end
|
274
|
-
|
275
|
-
# Sorts the terms list in place according to the term attribute indiated by
|
253
|
+
# Sorts the terms list in place according to the term attribute indicated by
|
276
254
|
# <tt>attr</tt>, returning <tt>self</tt>.
|
277
255
|
#
|
256
|
+
# If differences in units exist between terms, sorting occur based on the
|
257
|
+
# absolute quantities implied.
|
258
|
+
#
|
278
259
|
# my_terms_list.sort_by! :value
|
279
260
|
#
|
280
261
|
# #=> <AMEE::DataAbstraction::TermsList ... >
|
@@ -293,9 +274,9 @@ module AMEE
|
|
293
274
|
#
|
294
275
|
# E.g.
|
295
276
|
#
|
296
|
-
#
|
277
|
+
# my_terms_list.sort_by :value
|
297
278
|
#
|
298
|
-
#
|
279
|
+
# #=> <AMEE::DataAbstraction::TermsList ... >
|
299
280
|
#
|
300
281
|
def sort_by(attr)
|
301
282
|
# 1. Remove unset terms before sort and append at end
|
@@ -325,7 +306,7 @@ module AMEE
|
|
325
306
|
# dynamically retrieving a subset of terms according their labels.
|
326
307
|
#
|
327
308
|
def type
|
328
|
-
TermsList.new select{ |x| x.label == :type }
|
309
|
+
AMEE::DataAbstraction::TermsList.new select{ |x| x.label == :type }
|
329
310
|
end
|
330
311
|
|
331
312
|
def respond_to?(method)
|
@@ -372,7 +353,7 @@ module AMEE
|
|
372
353
|
#
|
373
354
|
def method_missing(method, *args, &block)
|
374
355
|
if labels.include? method
|
375
|
-
TermsList.new select{ |x| x.label == method }
|
356
|
+
AMEE::DataAbstraction::TermsList.new select{ |x| x.label == method }
|
376
357
|
elsif method.to_s =~ /sort_by_(.*)!/ and self.class::TermProperties.include? $1.to_sym
|
377
358
|
sort_by! $1.to_sym
|
378
359
|
elsif method.to_s =~ /sort_by_(.*)/ and self.class::TermProperties.include? $1.to_sym
|
@@ -5,6 +5,7 @@ include AMEE::DataAbstraction
|
|
5
5
|
describe CalculationCollection do
|
6
6
|
|
7
7
|
before(:each) do
|
8
|
+
initialize_calculation_set
|
8
9
|
@calcs = []
|
9
10
|
@calcs << add_elec_calc(500,240)
|
10
11
|
@calcs << add_elec_calc(1000,480)
|
@@ -144,7 +145,7 @@ describe CalculationCollection do
|
|
144
145
|
@coll.first['usage'].unit.label.should eql 'J'
|
145
146
|
@coll.standardize_units!(:usage,:kWh)
|
146
147
|
@coll.first['usage'].unit 'kWh'
|
147
|
-
@coll.first['usage'].value.should
|
148
|
+
@coll.first['usage'].value.should be_within(0.000001).of(0.000138888888888889)
|
148
149
|
end
|
149
150
|
|
150
151
|
it "should standardize units returning new collection" do
|
@@ -152,7 +153,7 @@ describe CalculationCollection do
|
|
152
153
|
@coll.first['co2'].unit.label.should eql 't'
|
153
154
|
coll = @coll.standardize_units(:co2,:lb)
|
154
155
|
coll.first['co2'].unit 'lb'
|
155
|
-
coll.first['co2'].value.should
|
156
|
+
coll.first['co2'].value.should be_within(0.01).of(529109.429243706)
|
156
157
|
end
|
157
158
|
|
158
159
|
it "should handle 'type' as a terms filter" do
|
@@ -201,11 +202,11 @@ describe CalculationCollection do
|
|
201
202
|
|
202
203
|
it "should add to calculation collection using += syntax" do
|
203
204
|
@coll = CalculationCollection.new
|
204
|
-
@coll += add_transport_calc(500,240)
|
205
|
+
@coll += [add_transport_calc(500,240)]
|
205
206
|
@coll.should be_a CalculationCollection
|
206
|
-
@coll += add_transport_calc(1000,480)
|
207
|
+
@coll += [add_transport_calc(1000,480)]
|
207
208
|
@coll.should be_a CalculationCollection
|
208
|
-
@coll += add_transport_calc(1234,600)
|
209
|
+
@coll += [add_transport_calc(1234,600)]
|
209
210
|
@coll.should be_a CalculationCollection
|
210
211
|
@coll.size.should eql 3
|
211
212
|
end
|
@@ -5,6 +5,7 @@ include AMEE::DataAbstraction
|
|
5
5
|
describe TermsList do
|
6
6
|
|
7
7
|
before(:each) do
|
8
|
+
initialize_calculation_set
|
8
9
|
calcs = []
|
9
10
|
calcs << add_elec_calc(500,240)
|
10
11
|
calcs << add_elec_calc(1000,480)
|
@@ -65,7 +66,7 @@ describe TermsList do
|
|
65
66
|
list.should be_homogeneous
|
66
67
|
list.should be_homogeneous_units
|
67
68
|
list.first.unit.label.should eql 't'
|
68
|
-
list.first.value.should
|
69
|
+
list.first.value.should be_within(0.001).of(0.1088621688)
|
69
70
|
end
|
70
71
|
|
71
72
|
it "should standardize term per units with predominant per units and convert values appropriately if no per unit specified" do
|
@@ -78,7 +79,7 @@ describe TermsList do
|
|
78
79
|
list.should be_homogeneous
|
79
80
|
list.should be_homogeneous_per_units
|
80
81
|
list.first.per_unit.label.should eql 'h'
|
81
|
-
list.first.value.should
|
82
|
+
list.first.value.should be_within(0.001).of(14400)
|
82
83
|
end
|
83
84
|
|
84
85
|
it "should standardize term units AND per units with predominant units and convert values appropriately if no units specified" do
|
@@ -95,7 +96,7 @@ describe TermsList do
|
|
95
96
|
list.should be_homogeneous_per_units
|
96
97
|
list.first.unit.label.should eql 't'
|
97
98
|
list.first.per_unit.label.should eql 'h'
|
98
|
-
list.first.value.should
|
99
|
+
list.first.value.should be_within(0.001).of(6.531730128)
|
99
100
|
end
|
100
101
|
|
101
102
|
it "should standardize term units with specfied units and convert values appropriately" do
|
@@ -110,7 +111,7 @@ describe TermsList do
|
|
110
111
|
list.first.unit.label.should eql 'lb'
|
111
112
|
list[1].unit.label.should eql 'lb'
|
112
113
|
list.first.value.should eql 240.0
|
113
|
-
list[1].value.should
|
114
|
+
list[1].value.should be_within(0.001).of(1058218.85848741)
|
114
115
|
end
|
115
116
|
|
116
117
|
it "should standardize term per units with specfied per units and convert values appropriately" do
|
@@ -126,7 +127,7 @@ describe TermsList do
|
|
126
127
|
list.first.per_unit.label.should eql 'min'
|
127
128
|
list[1].per_unit.label.should eql 'min'
|
128
129
|
list.first.value.should eql 240.0
|
129
|
-
list[1].value.should
|
130
|
+
list[1].value.should be_within(0.001).of(8)
|
130
131
|
end
|
131
132
|
|
132
133
|
it "should standardize term units AND per units with specfied units AND per units and convert values appropriately" do
|
@@ -147,7 +148,7 @@ describe TermsList do
|
|
147
148
|
list[1].unit.label.should eql 'lb'
|
148
149
|
list[1].per_unit.label.should eql 'min'
|
149
150
|
list.first.value.should eql 240.0
|
150
|
-
list[1].value.should
|
151
|
+
list[1].value.should be_within(0.001).of(17636.9809747902)
|
151
152
|
end
|
152
153
|
|
153
154
|
it "should sum terms" do
|
@@ -368,56 +369,6 @@ describe TermsList do
|
|
368
369
|
list.last.to_s.should eql'Zambia'
|
369
370
|
end
|
370
371
|
|
371
|
-
it "should move a term on the basis of value" do
|
372
|
-
@list=@list.co2
|
373
|
-
@list.first.to_s.should eql "240.0 t"
|
374
|
-
@list[1].to_s.should eql "480.0 t"
|
375
|
-
@list.last.to_s.should eql "600.0 t"
|
376
|
-
@list.move_by(:value, 600.0,0)
|
377
|
-
@list.first.to_s.should eql "600.0 t"
|
378
|
-
@list[1].to_s.should eql "240.0 t"
|
379
|
-
@list.last.to_s.should eql "480.0 t"
|
380
|
-
end
|
381
|
-
|
382
|
-
it "should move a term on the basis of unit object" do
|
383
|
-
@list=@list.co2
|
384
|
-
@list.first.unit 't'
|
385
|
-
@list[1].unit 'lb'
|
386
|
-
@list.last.unit 'kg'
|
387
|
-
@list.first.to_s.should eql "240.0 t"
|
388
|
-
@list[1].to_s.should eql "480.0 lb"
|
389
|
-
@list.last.to_s.should eql "600.0 kg"
|
390
|
-
@list.move_by(:unit, Unit.kg,1)
|
391
|
-
@list.first.to_s.should eql "240.0 t"
|
392
|
-
@list[1].to_s.should eql "600.0 kg"
|
393
|
-
@list.last.to_s.should eql "480.0 lb"
|
394
|
-
end
|
395
|
-
|
396
|
-
it "should move a term on the basis of unit label" do
|
397
|
-
@list=@list.co2
|
398
|
-
@list.first.unit 't'
|
399
|
-
@list[1].unit 'lb'
|
400
|
-
@list.last.unit 'kg'
|
401
|
-
@list.first.to_s.should eql "240.0 t"
|
402
|
-
@list[1].to_s.should eql "480.0 lb"
|
403
|
-
@list.last.to_s.should eql "600.0 kg"
|
404
|
-
@list.move_by(:unit, :t,-1)
|
405
|
-
@list.first.to_s.should eql "480.0 lb"
|
406
|
-
@list[1].to_s.should eql "600.0 kg"
|
407
|
-
@list.last.to_s.should eql "240.0 t"
|
408
|
-
end
|
409
|
-
|
410
|
-
it "should rotate terms" do
|
411
|
-
@list=@list.co2
|
412
|
-
@list.first.to_s.should eql "240.0 t"
|
413
|
-
@list[1].to_s.should eql "480.0 t"
|
414
|
-
@list.last.to_s.should eql "600.0 t"
|
415
|
-
@list.rotate
|
416
|
-
@list.first.to_s.should eql "480.0 t"
|
417
|
-
@list[1].to_s.should eql "600.0 t"
|
418
|
-
@list.last.to_s.should eql "240.0 t"
|
419
|
-
end
|
420
|
-
|
421
372
|
it "should return a new TermList for numeric only terms" do
|
422
373
|
@list=@list.co2.numeric_terms.should be_a TermsList
|
423
374
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,45 +1,81 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require '
|
3
|
-
|
2
|
+
require 'rspec'
|
4
3
|
require 'amee-analytics'
|
5
|
-
require 'amee-data-persistence'
|
6
|
-
require 'amee/data_abstraction/ongoing_calculation_persistence_support.rb'
|
7
|
-
require 'amee/data_abstraction/calculation_collection_analytics_support'
|
8
|
-
require 'amee/data_abstraction/terms_list_analytics_support'
|
9
|
-
require 'amee/data_abstraction/term_analytics_support'
|
10
4
|
|
11
|
-
|
12
|
-
include AMEE::DataAbstraction::PersistenceSupport
|
13
|
-
}
|
14
|
-
AMEE::DataAbstraction::CalculationCollection.class_eval { include AMEE::DataAbstraction::CalculationCollectionAnalyticsSupport }
|
15
|
-
AMEE::DataAbstraction::TermsList.class_eval { include AMEE::DataAbstraction::TermsListAnalyticsSupport }
|
16
|
-
AMEE::DataAbstraction::Term.class_eval { include AMEE::DataAbstraction::TermAnalyticsSupport }
|
5
|
+
RAILS_ROOT = '.'
|
17
6
|
|
18
|
-
|
19
|
-
|
20
|
-
File.dirname(__FILE__) + '/fixtures'
|
21
|
-
end
|
22
|
-
def self.logger
|
23
|
-
nil
|
24
|
-
end
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.mock_with :flexmock
|
25
9
|
end
|
26
10
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
11
|
+
def initialize_calculation_set
|
12
|
+
eval "Calculations = AMEE::DataAbstraction::CalculationSet.new {
|
13
|
+
calculation{
|
14
|
+
name 'Electricity'
|
15
|
+
label :electricity
|
16
|
+
path '/business/energy/electricity/grid'
|
17
|
+
drill {
|
18
|
+
label :country
|
19
|
+
path 'country'
|
20
|
+
value 'Argentina'
|
21
|
+
}
|
22
|
+
profile {
|
23
|
+
label :usage
|
24
|
+
name 'Electricity Used'
|
25
|
+
path 'energyPerTime'
|
26
|
+
default_unit :kWh
|
27
|
+
}
|
28
|
+
output {
|
29
|
+
label :co2
|
30
|
+
name 'Carbon Dioxide'
|
31
|
+
path :default
|
32
|
+
default_unit :t
|
33
|
+
}
|
34
|
+
}
|
35
|
+
calculation{
|
36
|
+
name 'Transport'
|
37
|
+
label :transport
|
38
|
+
path '/transport/defra/vehicle'
|
39
|
+
drill {
|
40
|
+
label :type
|
41
|
+
path 'type'
|
42
|
+
name 'Type'
|
43
|
+
}
|
44
|
+
drill {
|
45
|
+
label :size
|
46
|
+
path 'size'
|
47
|
+
name 'Size'
|
48
|
+
}
|
49
|
+
drill {
|
50
|
+
label :fuel
|
51
|
+
path 'fuel'
|
52
|
+
name 'Fuel'
|
53
|
+
}
|
54
|
+
profile {
|
55
|
+
label :distance
|
56
|
+
name 'distance'
|
57
|
+
path 'distance'
|
58
|
+
default_unit :km
|
59
|
+
}
|
60
|
+
output {
|
61
|
+
label :co2
|
62
|
+
name 'Carbon Dioxide'
|
63
|
+
path :default
|
64
|
+
default_unit :t
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}"
|
32
68
|
end
|
33
69
|
|
34
70
|
def add_elec_calc(act,res)
|
35
|
-
calc =
|
71
|
+
calc = Calculations[:electricity].begin_calculation
|
36
72
|
calc['usage'].value act
|
37
73
|
calc['co2'].value res
|
38
74
|
return calc
|
39
75
|
end
|
40
76
|
|
41
77
|
def add_transport_calc(act,res)
|
42
|
-
calc =
|
78
|
+
calc = Calculations[:transport].begin_calculation
|
43
79
|
calc['distance'].value act
|
44
80
|
calc['co2'].value res
|
45
81
|
return calc
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: amee-analytics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
|
-
-
|
8
|
-
- 1
|
7
|
+
- 2
|
9
8
|
- 0
|
10
|
-
|
9
|
+
- 0
|
10
|
+
version: 2.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- James Hetherington
|
@@ -18,133 +18,147 @@ 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-data-abstraction
|
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: 3
|
32
34
|
segments:
|
33
|
-
-
|
34
|
-
-
|
35
|
-
version: "
|
36
|
-
prerelease: false
|
37
|
-
type: :runtime
|
35
|
+
- 2
|
36
|
+
- 0
|
37
|
+
version: "2.0"
|
38
38
|
requirement: *id001
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
|
+
prerelease: false
|
40
41
|
name: amee-data-persistence
|
42
|
+
type: :runtime
|
41
43
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
42
44
|
none: false
|
43
45
|
requirements:
|
44
46
|
- - ~>
|
45
47
|
- !ruby/object:Gem::Version
|
46
|
-
hash:
|
48
|
+
hash: 3
|
47
49
|
segments:
|
48
|
-
- 1
|
49
50
|
- 2
|
50
|
-
|
51
|
-
|
52
|
-
type: :runtime
|
51
|
+
- 0
|
52
|
+
version: "2.0"
|
53
53
|
requirement: *id002
|
54
54
|
- !ruby/object:Gem::Dependency
|
55
|
-
|
55
|
+
prerelease: false
|
56
|
+
name: bundler
|
57
|
+
type: :development
|
56
58
|
version_requirements: &id003 !ruby/object:Gem::Requirement
|
57
59
|
none: false
|
58
60
|
requirements:
|
59
61
|
- - ~>
|
60
62
|
- !ruby/object:Gem::Version
|
61
|
-
hash:
|
63
|
+
hash: 23
|
62
64
|
segments:
|
63
65
|
- 1
|
64
|
-
-
|
65
|
-
-
|
66
|
-
version: 1.
|
67
|
-
prerelease: false
|
68
|
-
type: :development
|
66
|
+
- 0
|
67
|
+
- 0
|
68
|
+
version: 1.0.0
|
69
69
|
requirement: *id003
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
|
-
|
71
|
+
prerelease: false
|
72
|
+
name: jeweler
|
73
|
+
type: :development
|
72
74
|
version_requirements: &id004 !ruby/object:Gem::Requirement
|
73
75
|
none: false
|
74
76
|
requirements:
|
75
|
-
- -
|
77
|
+
- - ~>
|
76
78
|
- !ruby/object:Gem::Version
|
77
|
-
hash:
|
79
|
+
hash: 7
|
78
80
|
segments:
|
79
81
|
- 1
|
80
|
-
-
|
81
|
-
-
|
82
|
-
version: 1.
|
83
|
-
prerelease: false
|
84
|
-
type: :development
|
82
|
+
- 6
|
83
|
+
- 4
|
84
|
+
version: 1.6.4
|
85
85
|
requirement: *id004
|
86
86
|
- !ruby/object:Gem::Dependency
|
87
|
-
|
87
|
+
prerelease: false
|
88
|
+
name: rails
|
89
|
+
type: :development
|
88
90
|
version_requirements: &id005 !ruby/object:Gem::Requirement
|
89
91
|
none: false
|
90
92
|
requirements:
|
91
|
-
- -
|
93
|
+
- - ~>
|
92
94
|
- !ruby/object:Gem::Version
|
93
|
-
hash:
|
95
|
+
hash: 19
|
94
96
|
segments:
|
97
|
+
- 3
|
95
98
|
- 0
|
96
|
-
|
97
|
-
|
98
|
-
type: :development
|
99
|
+
- 10
|
100
|
+
version: 3.0.10
|
99
101
|
requirement: *id005
|
100
102
|
- !ruby/object:Gem::Dependency
|
101
|
-
|
103
|
+
prerelease: false
|
104
|
+
name: rspec
|
105
|
+
type: :development
|
102
106
|
version_requirements: &id006 !ruby/object:Gem::Requirement
|
103
107
|
none: false
|
104
108
|
requirements:
|
105
109
|
- - "="
|
106
110
|
- !ruby/object:Gem::Version
|
107
|
-
hash:
|
111
|
+
hash: 23
|
108
112
|
segments:
|
109
|
-
-
|
110
|
-
-
|
111
|
-
-
|
112
|
-
version:
|
113
|
-
prerelease: false
|
114
|
-
type: :development
|
113
|
+
- 2
|
114
|
+
- 6
|
115
|
+
- 0
|
116
|
+
version: 2.6.0
|
115
117
|
requirement: *id006
|
116
118
|
- !ruby/object:Gem::Dependency
|
119
|
+
prerelease: false
|
117
120
|
name: flexmock
|
121
|
+
type: :development
|
118
122
|
version_requirements: &id007 !ruby/object:Gem::Requirement
|
119
123
|
none: false
|
120
124
|
requirements:
|
121
|
-
- -
|
125
|
+
- - ~>
|
122
126
|
- !ruby/object:Gem::Version
|
123
|
-
hash:
|
127
|
+
hash: 59
|
124
128
|
segments:
|
125
129
|
- 0
|
126
|
-
-
|
127
|
-
-
|
128
|
-
version: 0.
|
129
|
-
prerelease: false
|
130
|
-
type: :development
|
130
|
+
- 9
|
131
|
+
- 0
|
132
|
+
version: 0.9.0
|
131
133
|
requirement: *id007
|
132
134
|
- !ruby/object:Gem::Dependency
|
133
|
-
|
135
|
+
prerelease: false
|
136
|
+
name: rcov
|
137
|
+
type: :development
|
134
138
|
version_requirements: &id008 !ruby/object:Gem::Requirement
|
135
139
|
none: false
|
136
140
|
requirements:
|
137
|
-
- -
|
141
|
+
- - ">="
|
138
142
|
- !ruby/object:Gem::Version
|
139
|
-
hash:
|
143
|
+
hash: 3
|
140
144
|
segments:
|
141
|
-
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
+
- 0
|
146
|
+
version: "0"
|
147
|
+
requirement: *id008
|
148
|
+
- !ruby/object:Gem::Dependency
|
145
149
|
prerelease: false
|
150
|
+
name: rdoc
|
146
151
|
type: :development
|
147
|
-
|
152
|
+
version_requirements: &id009 !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ">="
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
hash: 3
|
158
|
+
segments:
|
159
|
+
- 0
|
160
|
+
version: "0"
|
161
|
+
requirement: *id009
|
148
162
|
description: Part of the AMEE AppKit, this gem provides the ability to do mathmatical operations over a set of calculations
|
149
163
|
email: help@amee.com
|
150
164
|
executables: []
|
@@ -158,22 +172,20 @@ files:
|
|
158
172
|
- .rvmrc
|
159
173
|
- CHANGELOG.txt
|
160
174
|
- Gemfile
|
175
|
+
- Gemfile.lock
|
161
176
|
- LICENSE.txt
|
162
177
|
- README.txt
|
163
178
|
- Rakefile
|
164
179
|
- VERSION
|
165
180
|
- amee-analytics.gemspec
|
166
|
-
- init.rb
|
167
181
|
- lib/amee-analytics.rb
|
168
|
-
- lib/amee/
|
169
|
-
- lib/amee/
|
170
|
-
- lib/amee/
|
171
|
-
- lib/amee/
|
172
|
-
- rails/init.rb
|
182
|
+
- lib/amee/analytics/calculation_collection_analytics_support.rb
|
183
|
+
- lib/amee/analytics/result.rb
|
184
|
+
- lib/amee/analytics/term_analytics_support.rb
|
185
|
+
- lib/amee/analytics/terms_list_analytics_support.rb
|
173
186
|
- spec/amee/analytics/calculation_collection_spec.rb
|
174
187
|
- spec/amee/analytics/term_spec.rb
|
175
188
|
- spec/amee/analytics/terms_list_spec.rb
|
176
|
-
- spec/fixtures/config/calculations/calcs.rb
|
177
189
|
- spec/spec.opts
|
178
190
|
- spec/spec_helper.rb
|
179
191
|
has_rdoc: true
|
@@ -206,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
206
218
|
requirements: []
|
207
219
|
|
208
220
|
rubyforge_project:
|
209
|
-
rubygems_version: 1.
|
221
|
+
rubygems_version: 1.4.2
|
210
222
|
signing_key:
|
211
223
|
specification_version: 3
|
212
224
|
summary: Analytics module for use with AMEE AppKit
|
data/init.rb
DELETED
data/rails/init.rb
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
|
2
|
-
# Copyright (C) 2011 AMEE UK Ltd. - http://www.amee.com
|
3
|
-
# Released as Open Source Software under the BSD 3-Clause license. See LICENSE.txt for details.
|
4
|
-
|
5
|
-
require 'amee-data-abstraction'
|
6
|
-
|
7
|
-
::AMEE::DataAbstraction::CalculationCollection.class_eval { include AMEE::DataAbstraction::CalculationCollectionAnalyticsSupport }
|
8
|
-
::AMEE::DataAbstraction::TermsList.class_eval { include AMEE::DataAbstraction::TermsListAnalyticsSupport }
|
9
|
-
::AMEE::DataAbstraction::Term.class_eval { include AMEE::DataAbstraction::TermAnalyticsSupport }
|
@@ -1,55 +0,0 @@
|
|
1
|
-
calculation{
|
2
|
-
name 'Electricity'
|
3
|
-
label :electricity
|
4
|
-
path '/business/energy/electricity/grid'
|
5
|
-
drill {
|
6
|
-
label :country
|
7
|
-
path 'country'
|
8
|
-
value 'Argentina'
|
9
|
-
}
|
10
|
-
profile {
|
11
|
-
label :usage
|
12
|
-
name 'Electricity Used'
|
13
|
-
path 'energyPerTime'
|
14
|
-
default_unit :kWh
|
15
|
-
}
|
16
|
-
output {
|
17
|
-
label :co2
|
18
|
-
name 'Carbon Dioxide'
|
19
|
-
path 'default'
|
20
|
-
default_unit :t
|
21
|
-
}
|
22
|
-
}
|
23
|
-
|
24
|
-
calculation{
|
25
|
-
name 'Transport'
|
26
|
-
label :transport
|
27
|
-
path '/transport/defra/vehicle'
|
28
|
-
drill {
|
29
|
-
label :type
|
30
|
-
path 'type'
|
31
|
-
name 'Type'
|
32
|
-
}
|
33
|
-
drill {
|
34
|
-
label :size
|
35
|
-
path 'size'
|
36
|
-
name 'Size'
|
37
|
-
}
|
38
|
-
drill {
|
39
|
-
label :fuel
|
40
|
-
path 'fuel'
|
41
|
-
name 'Fuel'
|
42
|
-
}
|
43
|
-
profile {
|
44
|
-
label :distance
|
45
|
-
name 'distance'
|
46
|
-
path 'distance'
|
47
|
-
default_unit :km
|
48
|
-
}
|
49
|
-
output {
|
50
|
-
label :co2
|
51
|
-
name 'Carbon Dioxide'
|
52
|
-
path 'default'
|
53
|
-
default_unit :t
|
54
|
-
}
|
55
|
-
}
|