earth 0.4.4 → 0.4.5

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.
Files changed (59) hide show
  1. data/README.markdown +1 -1
  2. data/Rakefile +44 -16
  3. data/earth.gemspec +4 -8
  4. data/features/automobile_make_model_year_variant.feature +4 -4
  5. data/features/step_definitions/data_steps.rb +32 -0
  6. data/features/support/env.rb +6 -3
  7. data/features/support/imports/automobile_make_model_year_variant_bad.csv +1 -1
  8. data/features/support/imports/automobile_make_model_year_variant_good.csv +1 -1
  9. data/lib/earth/air/aircraft/data_miner.rb +1 -1
  10. data/lib/earth/air/aircraft_class/data_miner.rb +1 -1
  11. data/lib/earth/air/flight_distance_class/data_miner.rb +1 -1
  12. data/lib/earth/air/flight_seat_class/data_miner.rb +2 -2
  13. data/lib/earth/automobile/automobile_fuel/data_miner.rb +9 -2
  14. data/lib/earth/automobile/automobile_make/data_miner.rb +1 -1
  15. data/lib/earth/automobile/automobile_make_fleet_year/data_miner.rb +1 -1
  16. data/lib/earth/automobile/automobile_make_model_year_variant/data_miner.rb +2 -16
  17. data/lib/earth/automobile/automobile_make_model_year_variant.rb +0 -1
  18. data/lib/earth/automobile/automobile_size_class/data_miner.rb +2 -2
  19. data/lib/earth/automobile/automobile_size_class_year/data_miner.rb +1 -1
  20. data/lib/earth/automobile/automobile_type_fuel_control/data_miner.rb +1 -1
  21. data/lib/earth/automobile/automobile_type_fuel_year/data_miner.rb +1 -1
  22. data/lib/earth/automobile/automobile_type_fuel_year_control/data_miner.rb +1 -1
  23. data/lib/earth/automobile/automobile_type_year/data_miner.rb +1 -1
  24. data/lib/earth/automobile/data_miner.rb +0 -1
  25. data/lib/earth/automobile.rb +0 -1
  26. data/lib/earth/bus/bus_class/data_miner.rb +1 -1
  27. data/lib/earth/bus/bus_fuel/data_miner.rb +3 -3
  28. data/lib/earth/bus/bus_fuel_control/data_miner.rb +1 -1
  29. data/lib/earth/bus/bus_fuel_year_control/data_miner.rb +1 -1
  30. data/lib/earth/computation/computation_platform/data_miner.rb +1 -1
  31. data/lib/earth/computation/data_center_company/data_miner.rb +1 -1
  32. data/lib/earth/computation/server_type/data_miner.rb +1 -1
  33. data/lib/earth/computation/server_type_alias/data_miner.rb +1 -1
  34. data/lib/earth/diet/food_group/data_miner.rb +1 -1
  35. data/lib/earth/fuel/fuel/data_miner.rb +2 -2
  36. data/lib/earth/fuel/fuel_price/data_miner.rb +1 -1
  37. data/lib/earth/fuel/fuel_type/data_miner.rb +1 -1
  38. data/lib/earth/fuel/fuel_year/data_miner.rb +1 -1
  39. data/lib/earth/fuel/greenhouse_gas/data_miner.rb +1 -1
  40. data/lib/earth/hospitality/lodging_class/data_miner.rb +1 -1
  41. data/lib/earth/locality/census_division/data_miner.rb +2 -2
  42. data/lib/earth/locality/country/data_miner.rb +1 -1
  43. data/lib/earth/locality/egrid_subregion/data_miner.rb +1 -1
  44. data/lib/earth/locality/petroleum_administration_for_defense_district/data_miner.rb +1 -1
  45. data/lib/earth/locality/state/data_miner.rb +1 -1
  46. data/lib/earth/rail/rail_class/data_miner.rb +1 -1
  47. data/lib/earth/residence/air_conditioner_use/data_miner.rb +1 -1
  48. data/lib/earth/residence/residence_fuel_type/data_miner.rb +1 -1
  49. data/lib/earth/shipping/carrier/data_miner.rb +1 -1
  50. data/lib/earth/shipping/carrier_mode/data_miner.rb +1 -1
  51. data/lib/earth/shipping/shipment_mode/data_miner.rb +1 -1
  52. data/lib/earth/version.rb +1 -1
  53. data/spec/earth_spec.rb +2 -2
  54. metadata +38 -116
  55. data/features/automobile_fuel_type.feature +0 -34
  56. data/features/support/imports/automobile_fuel_type_bad.csv +0 -3
  57. data/features/support/imports/automobile_fuel_type_good.csv +0 -3
  58. data/lib/earth/automobile/automobile_fuel_type/data_miner.rb +0 -115
  59. data/lib/earth/automobile/automobile_fuel_type.rb +0 -17
@@ -3,7 +3,7 @@ LodgingClass.class_eval do
3
3
  LodgingClass.define_schema(self)
4
4
 
5
5
  import "a list of lodging classes and pre-calculated emission factors",
6
- :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGZZWmZtWEJlYzhRNXlPdWpBTldlcUE&hl=en&output=csv' do
6
+ :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGZZWmZtWEJlYzhRNXlPdWpBTldlcUE&hl=en&gid=0&output=csv' do
7
7
  key 'name'
8
8
  store 'natural_gas_intensity', :units_field_name => 'natural_gas_intensity_units'
9
9
  store 'fuel_oil_intensity', :units_field_name => 'fuel_oil_intensity_units'
@@ -44,7 +44,7 @@ CensusDivision.class_eval do
44
44
  end
45
45
 
46
46
  import 'meeting building fuel intensities calculated from CBECS 2003',
47
- :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGotdjgtUEk0eUU0R3lxM1hHdlF1V0E&hl=en&output=csv' do
47
+ :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGotdjgtUEk0eUU0R3lxM1hHdlF1V0E&hl=en&gid=0&output=csv' do
48
48
  key 'number', :field_name => 'census_division'
49
49
  store 'meeting_building_natural_gas_intensity', :from_units => :hundred_cubic_feet_per_square_foot_hour, :to_units => :cubic_metres_per_square_metre_hour
50
50
  store 'meeting_building_fuel_oil_intensity', :from_units => :gallons_per_square_foot_hour, :to_units => :litres_per_square_metre_hour
@@ -53,7 +53,7 @@ CensusDivision.class_eval do
53
53
  end
54
54
 
55
55
  import 'lodging building fuel intensities calculated from CBECS 2003',
56
- :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdHZ1QjdNTGVpbWxmZDVLbjlpTHlFVHc&hl=en&output=csv' do
56
+ :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdHZ1QjdNTGVpbWxmZDVLbjlpTHlFVHc&hl=en&gid=0&output=csv' do
57
57
  key 'number', :field_name => 'census_division'
58
58
  store 'lodging_building_natural_gas_intensity', :from_units => :hundred_cubic_feet_per_room_night, :to_units => :cubic_metres_per_room_night
59
59
  store 'lodging_building_fuel_oil_intensity', :from_units => :gallons_per_room_night, :to_units => :litres_per_room_night
@@ -17,7 +17,7 @@ Country.class_eval do
17
17
  end
18
18
 
19
19
  import "country-specific flight route inefficiency factors derived from Kettunen et al. (2005)",
20
- :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdEJoRVBZaGhnUmlhX240VXE3X0F3WkE&output=csv' do
20
+ :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdEJoRVBZaGhnUmlhX240VXE3X0F3WkE&gid=0&output=csv' do
21
21
  key 'iso_3166_code'
22
22
  store 'flight_route_inefficiency_factor'
23
23
  end
@@ -37,7 +37,7 @@ EgridSubregion.class_eval do
37
37
  # end
38
38
 
39
39
  import "eGRID subregion data",
40
- :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGRORTJNSWRMQ1puRVprYlAtZHhDaFE&hl=en&single=true&gid=0&output=csv' do
40
+ :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGRORTJNSWRMQ1puRVprYlAtZHhDaFE&hl=en&gid=0&output=csv' do
41
41
  key 'abbreviation'
42
42
  store 'name'
43
43
  store 'nerc_abbreviation'
@@ -9,7 +9,7 @@ PetroleumAdministrationForDefenseDistrict.class_eval do
9
9
  end
10
10
 
11
11
  import "a list of PADD districts and states derived from the EIA PADD definitions",
12
- :url => 'http://spreadsheets.google.com/pub?key=t5HM1KbaRngmTUbntg8JwPA' do
12
+ :url => 'http://spreadsheets.google.com/pub?key=t5HM1KbaRngmTUbntg8JwPA&gid=0&output=csv' do
13
13
  key 'code', :field_name => 'Code'
14
14
  store 'district_code', :field_name => 'PAD district code'
15
15
  store 'subdistrict_code', :field_name => 'PAD subdistrict code'
@@ -28,7 +28,7 @@ State.class_eval do
28
28
 
29
29
  # PADD
30
30
  import 'a list of state Petroleum Administration for Defense Districts',
31
- :url => 'http://spreadsheets.google.com/pub?key=t5HM1KbaRngmTUbntg8JwPA' do
31
+ :url => 'http://spreadsheets.google.com/pub?key=t5HM1KbaRngmTUbntg8JwPA&gid=0&output=csv' do
32
32
  key 'postal_abbreviation', :field_name => 'State'
33
33
  store 'petroleum_administration_for_defense_district_code', :field_name => 'Code'
34
34
  end
@@ -19,7 +19,7 @@ RailClass.class_eval do
19
19
  end
20
20
 
21
21
  import "a list of rail classes and pre-calculated trip and fuel use characteristics",
22
- :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdHRYaDNvRXMtZGoxNmRiOHlNWGV6b2c&hl=en&single=true&gid=0&output=csv' do
22
+ :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdHRYaDNvRXMtZGoxNmRiOHlNWGV6b2c&hl=en&gid=0&output=csv' do
23
23
  key 'name'
24
24
  store 'description'
25
25
  store 'passengers'
@@ -13,7 +13,7 @@ AirConditionerUse.class_eval do
13
13
  }
14
14
  end
15
15
 
16
- import "Ian's precalculated fugitive emissions values", :url => 'http://spreadsheets.google.com/pub?key=ri_380yQZAqBKeqie_TECgg' do
16
+ import "Ian's precalculated fugitive emissions values", :url => 'http://spreadsheets.google.com/pub?key=ri_380yQZAqBKeqie_TECgg&gid=0&output=csv' do
17
17
  key 'name', :field_name => 'air_conditioner_use_name'
18
18
  store 'fugitive_emission', :units_field_name => 'unit', :to_units => :kilograms_per_square_metre
19
19
  end
@@ -9,7 +9,7 @@ ResidenceFuelType.class_eval do
9
9
  end
10
10
 
11
11
  import "a list of residential fuels and their emissions factors",
12
- :url => 'http://spreadsheets.google.com/pub?key=rukxnmuhhsOsrztTrUaFCXQ' do
12
+ :url => 'http://spreadsheets.google.com/pub?key=rukxnmuhhsOsrztTrUaFCXQ&gid=0&output=csv' do
13
13
  key 'name'
14
14
  store 'emission_factor', :field_name => 'emission_factor', :units_field_name => 'units'
15
15
  end
@@ -11,7 +11,7 @@ Carrier.class_eval do
11
11
  end
12
12
 
13
13
  import "a list of shipping companies and their characteristics",
14
- :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdG1ONU1HZDdZTFJNclFYVkRzR0k5Z2c&hl=en&single=true&gid=0&output=csv' do
14
+ :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdG1ONU1HZDdZTFJNclFYVkRzR0k5Z2c&hl=en&gid=0&output=csv' do
15
15
  key 'name'
16
16
  store 'package_volume'
17
17
  store 'route_inefficiency_factor'
@@ -11,7 +11,7 @@ CarrierMode.class_eval do
11
11
  end
12
12
 
13
13
  import "a list of carrier modes and their characteristics",
14
- :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGRsRkJOd0NPd0FETTI0NmpYUlBsN2c&hl=en&single=true&gid=0&output=csv' do
14
+ :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGRsRkJOd0NPd0FETTI0NmpYUlBsN2c&hl=en&gid=0&output=csv' do
15
15
  key 'name'
16
16
  store 'carrier_name'
17
17
  store 'mode_name'
@@ -8,7 +8,7 @@ ShipmentMode.class_eval do
8
8
  end
9
9
 
10
10
  import "a list of shipment modes and their characteristics",
11
- :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGR2a2RYcEg2RnRKbkRQcXc0ZkQ5U0E&hl=en&single=true&gid=0&output=csv' do
11
+ :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGR2a2RYcEg2RnRKbkRQcXc0ZkQ5U0E&hl=en&gid=0&output=csv' do
12
12
  key 'name'
13
13
  store 'route_inefficiency_factor'
14
14
  store 'transport_emission_factor', :units_field_name => 'transport_emission_factor_units'
data/lib/earth/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Earth
2
- VERSION = '0.4.2'
2
+ VERSION = '0.4.5'
3
3
  end
data/spec/earth_spec.rb CHANGED
@@ -23,7 +23,7 @@ describe Earth do
23
23
  describe '.resources' do
24
24
  it 'should get a list of resources' do
25
25
  resources = Earth.resources
26
- resources.keys.count.should == 77
26
+ resources.keys.count.should == 76
27
27
  resources['FuelType'][:domain].should == 'fuel'
28
28
  end
29
29
  it 'should exclude data_miner files' do
@@ -33,7 +33,7 @@ describe Earth do
33
33
 
34
34
  describe '.resource_names' do
35
35
  it 'should get a list of all resource names' do
36
- Earth.resource_names.count.should == 77
36
+ Earth.resource_names.count.should == 76
37
37
  Earth.resource_names.should include('Aircraft')
38
38
  Earth.resource_names.should include('Industry')
39
39
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: earth
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
7
  - 4
9
- - 4
10
- version: 0.4.4
8
+ - 5
9
+ version: 0.4.5
11
10
  platform: ruby
12
11
  authors:
13
12
  - Seamus Abshere
@@ -17,179 +16,110 @@ autorequire:
17
16
  bindir: bin
18
17
  cert_chain: []
19
18
 
20
- date: 2011-02-25 00:00:00 -08:00
19
+ date: 2011-03-04 00:00:00 -05:00
21
20
  default_executable:
22
21
  dependencies:
23
22
  - !ruby/object:Gem::Dependency
23
+ name: activerecord
24
24
  prerelease: false
25
- version_requirements: &id001 !ruby/object:Gem::Requirement
25
+ requirement: &id001 !ruby/object:Gem::Requirement
26
26
  none: false
27
27
  requirements:
28
28
  - - ~>
29
29
  - !ruby/object:Gem::Version
30
- hash: 5
31
30
  segments:
32
31
  - 3
33
32
  version: "3"
34
- requirement: *id001
35
- name: activerecord
36
33
  type: :runtime
34
+ version_requirements: *id001
37
35
  - !ruby/object:Gem::Dependency
36
+ name: cohort_scope
38
37
  prerelease: false
39
- version_requirements: &id002 !ruby/object:Gem::Requirement
38
+ requirement: &id002 !ruby/object:Gem::Requirement
40
39
  none: false
41
40
  requirements:
42
- - - ~>
41
+ - - ">="
43
42
  - !ruby/object:Gem::Version
44
- hash: 17
45
43
  segments:
46
- - 1
47
- - 1
48
- - 1
49
- version: 1.1.1
50
- requirement: *id002
51
- name: data_miner
44
+ - 0
45
+ - 0
46
+ - 7
47
+ version: 0.0.7
52
48
  type: :runtime
49
+ version_requirements: *id002
53
50
  - !ruby/object:Gem::Dependency
51
+ name: data_miner
54
52
  prerelease: false
55
- version_requirements: &id003 !ruby/object:Gem::Requirement
53
+ requirement: &id003 !ruby/object:Gem::Requirement
56
54
  none: false
57
55
  requirements:
58
- - - ">="
56
+ - - ~>
59
57
  - !ruby/object:Gem::Version
60
- hash: 3
61
58
  segments:
62
- - 0
63
- version: "0"
64
- requirement: *id003
65
- name: errata
59
+ - 1
60
+ - 1
61
+ - 1
62
+ version: 1.1.1
66
63
  type: :runtime
64
+ version_requirements: *id003
67
65
  - !ruby/object:Gem::Dependency
66
+ name: falls_back_on
68
67
  prerelease: false
69
- version_requirements: &id004 !ruby/object:Gem::Requirement
68
+ requirement: &id004 !ruby/object:Gem::Requirement
70
69
  none: false
71
70
  requirements:
72
71
  - - ">="
73
72
  - !ruby/object:Gem::Version
74
- hash: 25
75
73
  segments:
76
74
  - 0
77
75
  - 0
78
76
  - 3
79
77
  version: 0.0.3
80
- requirement: *id004
81
- name: falls_back_on
82
- type: :runtime
83
- - !ruby/object:Gem::Dependency
84
- prerelease: false
85
- version_requirements: &id005 !ruby/object:Gem::Requirement
86
- none: false
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- hash: 3
91
- segments:
92
- - 1
93
- - 5
94
- - 0
95
- version: 1.5.0
96
- requirement: *id005
97
- name: geokit
98
78
  type: :runtime
79
+ version_requirements: *id004
99
80
  - !ruby/object:Gem::Dependency
81
+ name: geokit-rails
100
82
  prerelease: false
101
- version_requirements: &id006 !ruby/object:Gem::Requirement
83
+ requirement: &id005 !ruby/object:Gem::Requirement
102
84
  none: false
103
85
  requirements:
104
86
  - - ">="
105
87
  - !ruby/object:Gem::Version
106
- hash: 3
107
88
  segments:
108
89
  - 0
109
90
  version: "0"
110
- requirement: *id006
111
- name: geokit-rails
112
91
  type: :runtime
92
+ version_requirements: *id005
113
93
  - !ruby/object:Gem::Dependency
94
+ name: loose_tight_dictionary
114
95
  prerelease: false
115
- version_requirements: &id007 !ruby/object:Gem::Requirement
96
+ requirement: &id006 !ruby/object:Gem::Requirement
116
97
  none: false
117
98
  requirements:
118
99
  - - ">="
119
100
  - !ruby/object:Gem::Version
120
- hash: 17
121
101
  segments:
122
102
  - 0
123
103
  - 0
124
- - 7
125
- version: 0.0.7
126
- requirement: *id007
127
- name: cohort_scope
128
- type: :runtime
129
- - !ruby/object:Gem::Dependency
130
- prerelease: false
131
- version_requirements: &id008 !ruby/object:Gem::Requirement
132
- none: false
133
- requirements:
134
- - - ">="
135
- - !ruby/object:Gem::Version
136
- hash: 13
137
- segments:
138
- - 1
139
- - 4
140
- - 5
141
- version: 1.4.5
142
- requirement: *id008
143
- name: conversions
104
+ - 8
105
+ version: 0.0.8
144
106
  type: :runtime
107
+ version_requirements: *id006
145
108
  - !ruby/object:Gem::Dependency
109
+ name: weighted_average
146
110
  prerelease: false
147
- version_requirements: &id009 !ruby/object:Gem::Requirement
111
+ requirement: &id007 !ruby/object:Gem::Requirement
148
112
  none: false
149
113
  requirements:
150
114
  - - ">="
151
115
  - !ruby/object:Gem::Version
152
- hash: 23
153
116
  segments:
154
117
  - 0
155
118
  - 0
156
119
  - 4
157
120
  version: 0.0.4
158
- requirement: *id009
159
- name: weighted_average
160
121
  type: :runtime
161
- - !ruby/object:Gem::Dependency
162
- prerelease: false
163
- version_requirements: &id010 !ruby/object:Gem::Requirement
164
- none: false
165
- requirements:
166
- - - ">="
167
- - !ruby/object:Gem::Version
168
- hash: 15
169
- segments:
170
- - 0
171
- - 0
172
- - 8
173
- version: 0.0.8
174
- requirement: *id010
175
- name: loose_tight_dictionary
176
- type: :runtime
177
- - !ruby/object:Gem::Dependency
178
- prerelease: false
179
- version_requirements: &id011 !ruby/object:Gem::Requirement
180
- none: false
181
- requirements:
182
- - - ~>
183
- - !ruby/object:Gem::Version
184
- hash: 5
185
- segments:
186
- - 0
187
- - 6
188
- - 1
189
- version: 0.6.1
190
- requirement: *id011
191
- name: sniff
192
- type: :development
122
+ version_requirements: *id007
193
123
  description: An earth-simulation environment with ActiveRecord models and data
194
124
  email: andy@rossmeissl.net
195
125
  executables: []
@@ -210,7 +140,6 @@ files:
210
140
  - Rakefile
211
141
  - earth.gemspec
212
142
  - features/automobile_fuel.feature
213
- - features/automobile_fuel_type.feature
214
143
  - features/automobile_make.feature
215
144
  - features/automobile_make_fleet_year.feature
216
145
  - features/automobile_make_model.feature
@@ -240,11 +169,10 @@ files:
240
169
  - features/server_type.feature
241
170
  - features/server_type_alias.feature
242
171
  - features/shipment_mode.feature
172
+ - features/step_definitions/data_steps.rb
243
173
  - features/support/env.rb
244
174
  - features/support/imports/automobile_fuel_bad.csv
245
175
  - features/support/imports/automobile_fuel_good.csv
246
- - features/support/imports/automobile_fuel_type_bad.csv
247
- - features/support/imports/automobile_fuel_type_good.csv
248
176
  - features/support/imports/automobile_make_bad.csv
249
177
  - features/support/imports/automobile_make_fleet_year_bad.csv
250
178
  - features/support/imports/automobile_make_fleet_year_good.csv
@@ -329,8 +257,6 @@ files:
329
257
  - lib/earth/automobile.rb
330
258
  - lib/earth/automobile/automobile_fuel.rb
331
259
  - lib/earth/automobile/automobile_fuel/data_miner.rb
332
- - lib/earth/automobile/automobile_fuel_type.rb
333
- - lib/earth/automobile/automobile_fuel_type/data_miner.rb
334
260
  - lib/earth/automobile/automobile_make.rb
335
261
  - lib/earth/automobile/automobile_make/data_miner.rb
336
262
  - lib/earth/automobile/automobile_make_fleet_year.rb
@@ -544,7 +470,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
544
470
  requirements:
545
471
  - - ">="
546
472
  - !ruby/object:Gem::Version
547
- hash: 3
548
473
  segments:
549
474
  - 0
550
475
  version: "0"
@@ -553,7 +478,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
553
478
  requirements:
554
479
  - - ">="
555
480
  - !ruby/object:Gem::Version
556
- hash: 3
557
481
  segments:
558
482
  - 0
559
483
  version: "0"
@@ -566,7 +490,6 @@ specification_version: 3
566
490
  summary: Land, sky, and sea
567
491
  test_files:
568
492
  - features/automobile_fuel.feature
569
- - features/automobile_fuel_type.feature
570
493
  - features/automobile_make.feature
571
494
  - features/automobile_make_fleet_year.feature
572
495
  - features/automobile_make_model.feature
@@ -596,11 +519,10 @@ test_files:
596
519
  - features/server_type.feature
597
520
  - features/server_type_alias.feature
598
521
  - features/shipment_mode.feature
522
+ - features/step_definitions/data_steps.rb
599
523
  - features/support/env.rb
600
524
  - features/support/imports/automobile_fuel_bad.csv
601
525
  - features/support/imports/automobile_fuel_good.csv
602
- - features/support/imports/automobile_fuel_type_bad.csv
603
- - features/support/imports/automobile_fuel_type_good.csv
604
526
  - features/support/imports/automobile_make_bad.csv
605
527
  - features/support/imports/automobile_make_fleet_year_bad.csv
606
528
  - features/support/imports/automobile_make_fleet_year_good.csv
@@ -1,34 +0,0 @@
1
- Feature: Data import for AutomobileFuelType
2
- As a data user
3
- I want to import AutomobileFuelType data
4
- So that I can perform fuel type-based calculations
5
-
6
- Scenario: Successfully verifying that annual distance and emission factor > 0
7
- Given a "AutomobileFuelType" data import fetches results listed in "automobile_fuel_type_good"
8
- When a data import verifies "Annual distance and emission factor should be greater than zero"
9
- Then the verification should be successful
10
-
11
- Scenario: Successfully verifying that annual distance units are kilometres
12
- Given a "AutomobileFuelType" data import fetches results listed in "automobile_fuel_type_good"
13
- When a data import verifies "Annual distance units should be kilometres"
14
- Then the verification should be successful
15
-
16
- Scenario: Successfully verifying that emission factor units are never missing
17
- Given a "AutomobileFuelType" data import fetches results listed in "automobile_fuel_type_good"
18
- When a data import verifies "Emission factor units should never be missing"
19
- Then the verification should be successful
20
-
21
- Scenario: Failing to verify that annual distance and emission factor > 0
22
- Given a "AutomobileFuelType" data import fetches results listed in "automobile_fuel_type_bad"
23
- When a data import verifies "Annual distance and emission factor should be greater than zero"
24
- Then the verification should not be successful
25
-
26
- Scenario: Failing to verify that annual distance units are kilometres
27
- Given a "AutomobileFuelType" data import fetches results listed in "automobile_fuel_type_bad"
28
- When a data import verifies "Annual distance units should be kilometres"
29
- Then the verification should not be successful
30
-
31
- Scenario: Failing to verify that emission factor units are never missing
32
- Given a "AutomobileFuelType" data import fetches results listed in "automobile_fuel_type_bad"
33
- When a data import verifies "Emission factor units should never be missing"
34
- Then the verification should not be successful
@@ -1,3 +0,0 @@
1
- code,name,annual_distance,emission_factor,annual_distance_units,emission_factor_units
2
- D,diesel,1000.0,0.1,kilometres,kilograms_per_kilometre
3
- R,regular gasoline,0.0,-0.1
@@ -1,3 +0,0 @@
1
- code,name,annual_distance,emission_factor,annual_distance_units,emission_factor_units
2
- D,diesel,1000.0,0.1,kilometres,kilograms_per_kilometre
3
- R,regular gasoline,1.0,2.1,kilometres,kilograms_per_kilometre
@@ -1,115 +0,0 @@
1
- # DEPRECATED - use AutomobileFuel
2
- AutomobileFuelType.class_eval do
3
- data_miner do
4
- schema Earth.database_options do
5
- string 'code'
6
- string 'name'
7
- string 'fuel_name_for_distance'
8
- string 'fuel_name_for_efs'
9
- float 'blend_portion'
10
- float 'emission_factor'
11
- string 'emission_factor_units'
12
- float 'annual_distance'
13
- string 'annual_distance_units'
14
- end
15
-
16
- import "a list of fuel type codes and attributes",
17
- :url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdDlqeU9vQkVkNG1NZXV4WklKTjJkU3c&hl=en&single=true&gid=0&output=csv' do
18
- key 'code'
19
- store 'name'
20
- store 'fuel_name_for_distance'
21
- store 'fuel_name_for_efs'
22
- store 'blend_portion'
23
- end
24
-
25
- process "Calculate annual distance from AutomobileTypeFuelAge" do
26
- AutomobileTypeFuelAge.run_data_miner!
27
- ages = AutomobileTypeFuelAge.arel_table
28
- types = AutomobileFuelType.arel_table
29
- conditional_relation = ages[:fuel_common_name].eq(types[:fuel_name_for_distance])
30
- update_all "annual_distance = (#{AutomobileTypeFuelAge.weighted_average_relation(:annual_distance, :weighted_by => :vehicles).where(conditional_relation).to_sql})"
31
- update_all "annual_distance_units = 'kilometres'"
32
- end
33
-
34
- process "Calculate emission factor from FuelYear, AutomobileTypeFuelYear, and GreenhouseGas" do
35
- FuelYear.run_data_miner!
36
- AutomobileTypeFuelYear.run_data_miner!
37
- GreenhouseGas.run_data_miner!
38
-
39
- co2_gwp = GreenhouseGas.find_by_abbreviation("co2").global_warming_potential
40
- ch4_gwp = GreenhouseGas.find_by_abbreviation("ch4").global_warming_potential
41
- n2o_gwp = GreenhouseGas.find_by_abbreviation("n2o").global_warming_potential
42
-
43
- latest_year = FuelYear.all.collect{|x| x.year }.max
44
-
45
- fuel_years = FuelYear.arel_table
46
- type_fuel_years = AutomobileTypeFuelYear.arel_table
47
- fuel_types = AutomobileFuelType.arel_table
48
-
49
- AutomobileFuelType.all.each do |fuel_type|
50
- current_name = fuel_type.name
51
-
52
- if fuel_type.fuel_name_for_efs.present?
53
- co2_factor_sql = fuel_years.project(fuel_years[:co2_emission_factor]).where(fuel_years[:fuel_common_name].eq(fuel_types[:fuel_name_for_efs]).and(fuel_years[:year].eq(latest_year))).to_sql
54
- ch4_factor_sql = AutomobileTypeFuelYear.weighted_average_relation(:ch4_emission_factor, :weighted_by => :total_travel).where(type_fuel_years[:fuel_common_name].eq(fuel_types[:fuel_name_for_efs]).and(type_fuel_years[:year].eq(latest_year))).to_sql
55
- n2o_factor_sql = AutomobileTypeFuelYear.weighted_average_relation(:n2o_emission_factor, :weighted_by => :total_travel).where(type_fuel_years[:fuel_common_name].eq(fuel_types[:fuel_name_for_efs]).and(type_fuel_years[:year].eq(latest_year))).to_sql
56
- hfc_factor_sql = AutomobileTypeFuelYear.weighted_average_relation(:hfc_emission_factor, :weighted_by => :total_travel).where(type_fuel_years[:fuel_common_name].eq(fuel_types[:fuel_name_for_efs]).and(type_fuel_years[:year].eq(latest_year))).to_sql
57
-
58
- connection.execute %{
59
- UPDATE automobile_fuel_types
60
- SET emission_factor = (((#{co2_factor_sql}) * #{co2_gwp} * (1 - blend_portion)) + ((#{ch4_factor_sql}) * #{ch4_gwp}) + ((#{n2o_factor_sql}) * #{n2o_gwp}) + (#{hfc_factor_sql}))
61
- WHERE automobile_fuel_types.name = '#{current_name}'
62
- }
63
- connection.execute %{
64
- UPDATE automobile_fuel_types
65
- SET emission_factor_units = 'kilograms_co2e_per_litre'
66
- WHERE automobile_fuel_types.name = '#{current_name}'
67
- }
68
- end
69
- end
70
- end
71
-
72
- process "Calculate emission factor for electricity from EgridSubregion and EgridRegion" do
73
- EgridSubregion.run_data_miner!
74
- EgridRegion.run_data_miner!
75
- electricity_ef = (EgridSubregion.find_by_abbreviation("US").electricity_emission_factor / (1 - EgridRegion.find_by_name("US").loss_factor))
76
- connection.execute %{
77
- UPDATE automobile_fuel_types
78
- SET emission_factor = #{electricity_ef}
79
- WHERE automobile_fuel_types.name = 'electricity'
80
- }
81
- connection.execute %{
82
- UPDATE automobile_fuel_types
83
- SET emission_factor_units = 'kilograms_co2e_per_kilowatt_hour'
84
- WHERE automobile_fuel_types.name = 'electricity'
85
- }
86
- end
87
-
88
- verify "Annual distance and emission factor should be greater than zero" do
89
- AutomobileFuelType.all.each do |fuel_type|
90
- %w{ annual_distance emission_factor }.each do |attribute|
91
- value = fuel_type.send(:"#{attribute}")
92
- unless value > 0
93
- raise "Invalid #{attribute} for AutomobileFuelType #{fuel_type.name}: #{value} (should be > 0)"
94
- end
95
- end
96
- end
97
- end
98
-
99
- verify "Annual distance units should be kilometres" do
100
- AutomobileFuelType.all.each do |fuel_type|
101
- unless fuel_type.annual_distance_units == "kilometres"
102
- raise "Missing annual distance units for AutomobileFuelType #{fuel_type.name}"
103
- end
104
- end
105
- end
106
-
107
- verify "Emission factor units should never be missing" do
108
- AutomobileFuelType.all.each do |fuel_type|
109
- unless fuel_type.emission_factor_units.present?
110
- raise "Missing emission factor units for AutomobileFuelType #{fuel_type.name}"
111
- end
112
- end
113
- end
114
- end
115
- end
@@ -1,17 +0,0 @@
1
- # DEPRECATED - use AutomobileFuel
2
- class AutomobileFuelType < ActiveRecord::Base
3
- set_primary_key :code
4
-
5
- scope :ordered, :order => 'name'
6
-
7
- falls_back_on :emission_factor => 20.781.pounds_per_gallon.to(:kilograms_per_litre) # https://brighterplanet.sifterapp.com/projects/30/issues/428
8
-
9
- data_miner do
10
- tap "Brighter Planet's sanitized automobile fuel type data", Earth.taps_server
11
- end
12
-
13
- CODES = {
14
- :electricity => 'El',
15
- :diesel => 'D'
16
- }
17
- end