earth 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- data/earth.gemspec +2 -2
- data/lib/earth/automobile/automobile_fuel.rb +25 -1
- metadata +61 -49
data/earth.gemspec
CHANGED
@@ -4,8 +4,8 @@ require "earth/version"
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "earth"
|
7
|
-
s.version =
|
8
|
-
s.date = "2011-02-
|
7
|
+
s.version = "0.4.3"
|
8
|
+
s.date = "2011-02-25"
|
9
9
|
s.platform = Gem::Platform::RUBY
|
10
10
|
s.authors = ["Seamus Abshere", "Derek Kastner", "Andy Rossmeissl"]
|
11
11
|
s.email = %q{andy@rossmeissl.net}
|
@@ -12,6 +12,18 @@ class AutomobileFuel < ActiveRecord::Base
|
|
12
12
|
belongs_to :blend_fuel, :class_name => 'Fuel', :foreign_key => 'blend_fuel_name'
|
13
13
|
|
14
14
|
class << self
|
15
|
+
def fallback_latest_type_fuel_year_ages
|
16
|
+
AutomobileTypeFuelYearAge.where(:year => AutomobileTypeFuelYearAge.maximum('year'))
|
17
|
+
end
|
18
|
+
|
19
|
+
def fallback_annual_distance
|
20
|
+
fallback_latest_type_fuel_year_ages.weighted_average(:annual_distance, :weighted_by => :vehicles)
|
21
|
+
end
|
22
|
+
|
23
|
+
def fallback_annual_distance_units
|
24
|
+
fallback_latest_type_fuel_year_ages.first.annual_distance_units
|
25
|
+
end
|
26
|
+
|
15
27
|
def fallback_blend_portion
|
16
28
|
latest_year = AutomobileTypeFuelYear.maximum('year')
|
17
29
|
gas_use = AutomobileTypeFuelYear.where(:year => latest_year, :fuel_common_name => 'gasoline').sum('fuel_consumption')
|
@@ -19,6 +31,15 @@ class AutomobileFuel < ActiveRecord::Base
|
|
19
31
|
diesel_use / (gas_use + diesel_use)
|
20
32
|
end
|
21
33
|
|
34
|
+
def fallback_annual_distance
|
35
|
+
(AutomobileFuel.find_by_code("R").annual_distance * (1 - AutomobileFuel.fallback_blend_portion)) +
|
36
|
+
(AutomobileFuel.find_by_code("D").annual_distance * AutomobileFuel.fallback_blend_portion)
|
37
|
+
end
|
38
|
+
|
39
|
+
def fallback_annual_distance_units
|
40
|
+
AutomobileFuel.find_by_code("R").annual_distance_units
|
41
|
+
end
|
42
|
+
|
22
43
|
def fallback_co2_emission_factor
|
23
44
|
(Fuel.find_by_name("Motor Gasoline").co2_emission_factor * (1 - AutomobileFuel.fallback_blend_portion)) +
|
24
45
|
(Fuel.find_by_name("Distillate Fuel Oil No. 2").co2_emission_factor * AutomobileFuel.fallback_blend_portion)
|
@@ -72,7 +93,10 @@ class AutomobileFuel < ActiveRecord::Base
|
|
72
93
|
end
|
73
94
|
end
|
74
95
|
|
75
|
-
falls_back_on :
|
96
|
+
falls_back_on :name => 'fallback',
|
97
|
+
:annual_distance => lambda { AutomobileFuel.fallback_annual_distance },
|
98
|
+
:annual_distance_units => lambda { AutomobileFuel.fallback_annual_distance_units },
|
99
|
+
:co2_emission_factor => lambda { AutomobileFuel.fallback_co2_emission_factor },
|
76
100
|
:co2_emission_factor_units => lambda { AutomobileFuel.fallback_co2_emission_factor_units },
|
77
101
|
:co2_biogenic_emission_factor => lambda { AutomobileFuel.fallback_co2_biogenic_emission_factor },
|
78
102
|
:co2_biogenic_emission_factor_units => lambda { AutomobileFuel.fallback_co2_biogenic_emission_factor_units },
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: earth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 9
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
9
|
+
- 3
|
10
|
+
version: 0.4.3
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Seamus Abshere
|
@@ -16,168 +17,179 @@ autorequire:
|
|
16
17
|
bindir: bin
|
17
18
|
cert_chain: []
|
18
19
|
|
19
|
-
date: 2011-02-
|
20
|
+
date: 2011-02-25 00:00:00 -08:00
|
20
21
|
default_executable:
|
21
22
|
dependencies:
|
22
23
|
- !ruby/object:Gem::Dependency
|
23
|
-
|
24
|
-
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
25
26
|
none: false
|
26
27
|
requirements:
|
27
28
|
- - ~>
|
28
29
|
- !ruby/object:Gem::Version
|
30
|
+
hash: 5
|
29
31
|
segments:
|
30
32
|
- 3
|
31
33
|
version: "3"
|
34
|
+
requirement: *id001
|
35
|
+
name: activerecord
|
32
36
|
type: :runtime
|
33
|
-
prerelease: false
|
34
|
-
version_requirements: *id001
|
35
37
|
- !ruby/object:Gem::Dependency
|
36
|
-
|
37
|
-
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
38
40
|
none: false
|
39
41
|
requirements:
|
40
42
|
- - ~>
|
41
43
|
- !ruby/object:Gem::Version
|
44
|
+
hash: 17
|
42
45
|
segments:
|
43
46
|
- 1
|
44
47
|
- 1
|
45
48
|
- 1
|
46
49
|
version: 1.1.1
|
50
|
+
requirement: *id002
|
51
|
+
name: data_miner
|
47
52
|
type: :runtime
|
48
|
-
prerelease: false
|
49
|
-
version_requirements: *id002
|
50
53
|
- !ruby/object:Gem::Dependency
|
51
|
-
|
52
|
-
|
54
|
+
prerelease: false
|
55
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
53
56
|
none: false
|
54
57
|
requirements:
|
55
58
|
- - ">="
|
56
59
|
- !ruby/object:Gem::Version
|
60
|
+
hash: 3
|
57
61
|
segments:
|
58
62
|
- 0
|
59
63
|
version: "0"
|
64
|
+
requirement: *id003
|
65
|
+
name: errata
|
60
66
|
type: :runtime
|
61
|
-
prerelease: false
|
62
|
-
version_requirements: *id003
|
63
67
|
- !ruby/object:Gem::Dependency
|
64
|
-
|
65
|
-
|
68
|
+
prerelease: false
|
69
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
66
70
|
none: false
|
67
71
|
requirements:
|
68
72
|
- - ">="
|
69
73
|
- !ruby/object:Gem::Version
|
74
|
+
hash: 25
|
70
75
|
segments:
|
71
76
|
- 0
|
72
77
|
- 0
|
73
78
|
- 3
|
74
79
|
version: 0.0.3
|
80
|
+
requirement: *id004
|
81
|
+
name: falls_back_on
|
75
82
|
type: :runtime
|
76
|
-
prerelease: false
|
77
|
-
version_requirements: *id004
|
78
83
|
- !ruby/object:Gem::Dependency
|
79
|
-
|
80
|
-
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
81
86
|
none: false
|
82
87
|
requirements:
|
83
88
|
- - ">="
|
84
89
|
- !ruby/object:Gem::Version
|
90
|
+
hash: 3
|
85
91
|
segments:
|
86
92
|
- 1
|
87
93
|
- 5
|
88
94
|
- 0
|
89
95
|
version: 1.5.0
|
96
|
+
requirement: *id005
|
97
|
+
name: geokit
|
90
98
|
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: *id005
|
93
99
|
- !ruby/object:Gem::Dependency
|
94
|
-
|
95
|
-
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
96
102
|
none: false
|
97
103
|
requirements:
|
98
104
|
- - ">="
|
99
105
|
- !ruby/object:Gem::Version
|
106
|
+
hash: 3
|
100
107
|
segments:
|
101
108
|
- 0
|
102
109
|
version: "0"
|
110
|
+
requirement: *id006
|
111
|
+
name: geokit-rails
|
103
112
|
type: :runtime
|
104
|
-
prerelease: false
|
105
|
-
version_requirements: *id006
|
106
113
|
- !ruby/object:Gem::Dependency
|
107
|
-
|
108
|
-
|
114
|
+
prerelease: false
|
115
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
109
116
|
none: false
|
110
117
|
requirements:
|
111
118
|
- - ">="
|
112
119
|
- !ruby/object:Gem::Version
|
120
|
+
hash: 17
|
113
121
|
segments:
|
114
122
|
- 0
|
115
123
|
- 0
|
116
124
|
- 7
|
117
125
|
version: 0.0.7
|
126
|
+
requirement: *id007
|
127
|
+
name: cohort_scope
|
118
128
|
type: :runtime
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: *id007
|
121
129
|
- !ruby/object:Gem::Dependency
|
122
|
-
|
123
|
-
|
130
|
+
prerelease: false
|
131
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
124
132
|
none: false
|
125
133
|
requirements:
|
126
134
|
- - ">="
|
127
135
|
- !ruby/object:Gem::Version
|
136
|
+
hash: 13
|
128
137
|
segments:
|
129
138
|
- 1
|
130
139
|
- 4
|
131
140
|
- 5
|
132
141
|
version: 1.4.5
|
142
|
+
requirement: *id008
|
143
|
+
name: conversions
|
133
144
|
type: :runtime
|
134
|
-
prerelease: false
|
135
|
-
version_requirements: *id008
|
136
145
|
- !ruby/object:Gem::Dependency
|
137
|
-
|
138
|
-
|
146
|
+
prerelease: false
|
147
|
+
version_requirements: &id009 !ruby/object:Gem::Requirement
|
139
148
|
none: false
|
140
149
|
requirements:
|
141
150
|
- - ">="
|
142
151
|
- !ruby/object:Gem::Version
|
152
|
+
hash: 23
|
143
153
|
segments:
|
144
154
|
- 0
|
145
155
|
- 0
|
146
156
|
- 4
|
147
157
|
version: 0.0.4
|
158
|
+
requirement: *id009
|
159
|
+
name: weighted_average
|
148
160
|
type: :runtime
|
149
|
-
prerelease: false
|
150
|
-
version_requirements: *id009
|
151
161
|
- !ruby/object:Gem::Dependency
|
152
|
-
|
153
|
-
|
162
|
+
prerelease: false
|
163
|
+
version_requirements: &id010 !ruby/object:Gem::Requirement
|
154
164
|
none: false
|
155
165
|
requirements:
|
156
166
|
- - ">="
|
157
167
|
- !ruby/object:Gem::Version
|
168
|
+
hash: 15
|
158
169
|
segments:
|
159
170
|
- 0
|
160
171
|
- 0
|
161
172
|
- 8
|
162
173
|
version: 0.0.8
|
174
|
+
requirement: *id010
|
175
|
+
name: loose_tight_dictionary
|
163
176
|
type: :runtime
|
164
|
-
prerelease: false
|
165
|
-
version_requirements: *id010
|
166
177
|
- !ruby/object:Gem::Dependency
|
167
|
-
|
168
|
-
|
178
|
+
prerelease: false
|
179
|
+
version_requirements: &id011 !ruby/object:Gem::Requirement
|
169
180
|
none: false
|
170
181
|
requirements:
|
171
182
|
- - ~>
|
172
183
|
- !ruby/object:Gem::Version
|
184
|
+
hash: 5
|
173
185
|
segments:
|
174
186
|
- 0
|
175
187
|
- 6
|
176
188
|
- 1
|
177
189
|
version: 0.6.1
|
190
|
+
requirement: *id011
|
191
|
+
name: sniff
|
178
192
|
type: :development
|
179
|
-
prerelease: false
|
180
|
-
version_requirements: *id011
|
181
193
|
description: An earth-simulation environment with ActiveRecord models and data
|
182
194
|
email: andy@rossmeissl.net
|
183
195
|
executables: []
|
@@ -532,7 +544,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
532
544
|
requirements:
|
533
545
|
- - ">="
|
534
546
|
- !ruby/object:Gem::Version
|
535
|
-
hash:
|
547
|
+
hash: 3
|
536
548
|
segments:
|
537
549
|
- 0
|
538
550
|
version: "0"
|
@@ -541,7 +553,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
541
553
|
requirements:
|
542
554
|
- - ">="
|
543
555
|
- !ruby/object:Gem::Version
|
544
|
-
hash:
|
556
|
+
hash: 3
|
545
557
|
segments:
|
546
558
|
- 0
|
547
559
|
version: "0"
|