earth 0.3.11 → 0.3.13
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +7 -3
- data/features/automobile_fuel_type.feature +8 -18
- data/features/automobile_make_fleet_year.feature +4 -4
- data/features/automobile_make_model_year.feature +4 -4
- data/features/automobile_make_model_year_variant.feature +4 -4
- data/features/automobile_make_year.feature +4 -4
- data/features/automobile_size_class_year.feature +34 -0
- data/features/automobile_type_fuel_age.feature +54 -0
- data/features/automobile_type_fuel_control.feature +34 -0
- data/features/automobile_type_fuel_year.feature +54 -0
- data/features/automobile_type_fuel_year_control.feature +34 -0
- data/features/automobile_type_year.feature +44 -0
- data/features/computation_platform.feature +14 -0
- data/features/data_center_company.feature +14 -0
- data/features/egrid_region.feature +6 -0
- data/features/egrid_subregion.feature +4 -4
- data/features/flight_segment.feature +14 -0
- data/features/fuel_year.feature +44 -0
- data/features/greenhouse_gas.feature +44 -0
- data/features/server_type.feature +34 -0
- data/features/server_type_alias.feature +14 -0
- data/features/support/imports/automobile_make_fleet_year_bad.csv +1 -2
- data/features/support/imports/automobile_make_fleet_year_good.csv +1 -2
- data/features/support/imports/automobile_size_class_year_bad.csv +2 -0
- data/features/support/imports/automobile_size_class_year_good.csv +2 -0
- data/features/support/imports/automobile_type_fuel_age_bad.csv +3 -0
- data/features/support/imports/automobile_type_fuel_age_good.csv +3 -0
- data/features/support/imports/automobile_type_fuel_control_bad.csv +3 -0
- data/features/support/imports/automobile_type_fuel_control_good.csv +3 -0
- data/features/support/imports/automobile_type_fuel_year_bad.csv +2 -0
- data/features/support/imports/automobile_type_fuel_year_control_bad.csv +3 -0
- data/features/support/imports/automobile_type_fuel_year_control_good.csv +3 -0
- data/features/support/imports/automobile_type_fuel_year_good.csv +2 -0
- data/features/support/imports/automobile_type_year_bad.csv +2 -0
- data/features/support/imports/automobile_type_year_good.csv +2 -0
- data/features/support/imports/computation_platform_bad.csv +3 -0
- data/features/support/imports/computation_platform_good.csv +3 -0
- data/features/support/imports/data_center_company_bad.csv +3 -0
- data/features/support/imports/data_center_company_good.csv +3 -0
- data/features/support/imports/egrid_subregion_good.csv +2 -2
- data/features/support/imports/flight_segment_bad.csv +8 -0
- data/features/support/imports/flight_segment_good.csv +8 -0
- data/features/support/imports/fuel_year_bad.csv +2 -0
- data/features/support/imports/fuel_year_good.csv +2 -0
- data/features/support/imports/greenhouse_gas_bad.csv +2 -0
- data/features/support/imports/greenhouse_gas_good.csv +2 -0
- data/features/support/imports/server_type_alias_bad.csv +3 -0
- data/features/support/imports/server_type_alias_good.csv +3 -0
- data/features/support/imports/server_type_bad.csv +3 -0
- data/features/support/imports/server_type_good.csv +3 -0
- data/lib/earth/air/aircraft.rb +2 -3
- data/lib/earth/air/aircraft/data_miner.rb +2 -4
- data/lib/earth/air/aircraft_class/data_miner.rb +3 -1
- data/lib/earth/air/airport/data_miner.rb +4 -3
- data/lib/earth/air/flight_distance_class/data_miner.rb +2 -0
- data/lib/earth/air/flight_seat_class/data_miner.rb +4 -4
- data/lib/earth/air/flight_segment/data_miner.rb +7 -0
- data/lib/earth/all.rb +1 -0
- data/lib/earth/automobile.rb +6 -0
- data/lib/earth/automobile/automobile_fuel_type/data_miner.rb +68 -25
- data/lib/earth/automobile/automobile_make_fleet_year/data_miner.rb +5 -6
- data/lib/earth/automobile/automobile_make_model/data_miner.rb +1 -2
- data/lib/earth/automobile/automobile_make_model_year/data_miner.rb +3 -4
- data/lib/earth/automobile/automobile_make_model_year_variant/data_miner.rb +14 -10
- data/lib/earth/automobile/automobile_make_year/data_miner.rb +2 -2
- data/lib/earth/automobile/automobile_size_class/data_miner.rb +28 -26
- data/lib/earth/automobile/automobile_size_class_year.rb +7 -0
- data/lib/earth/automobile/automobile_size_class_year/data_miner.rb +56 -0
- data/lib/earth/automobile/automobile_type_fuel_age.rb +7 -0
- data/lib/earth/automobile/automobile_type_fuel_age/data_miner.rb +195 -0
- data/lib/earth/automobile/automobile_type_fuel_control.rb +7 -0
- data/lib/earth/automobile/automobile_type_fuel_control/data_miner.rb +57 -0
- data/lib/earth/automobile/automobile_type_fuel_year.rb +7 -0
- data/lib/earth/automobile/automobile_type_fuel_year/data_miner.rb +164 -0
- data/lib/earth/automobile/automobile_type_fuel_year_control.rb +7 -0
- data/lib/earth/automobile/automobile_type_fuel_year_control/data_miner.rb +46 -0
- data/lib/earth/automobile/automobile_type_year.rb +7 -0
- data/lib/earth/automobile/automobile_type_year/data_miner.rb +55 -0
- data/lib/earth/automobile/data_miner.rb +6 -0
- data/lib/earth/computation.rb +4 -0
- data/lib/earth/computation/computation_platform.rb +9 -0
- data/lib/earth/computation/computation_platform/data_miner.rb +24 -0
- data/lib/earth/computation/data_center_company.rb +7 -0
- data/lib/earth/computation/data_center_company/data_miner.rb +22 -0
- data/lib/earth/computation/data_miner.rb +4 -0
- data/lib/earth/computation/server_type.rb +9 -0
- data/lib/earth/computation/server_type/data_miner.rb +49 -0
- data/lib/earth/computation/server_type_alias.rb +10 -0
- data/lib/earth/computation/server_type_alias/data_miner.rb +30 -0
- data/lib/earth/data_miner.rb +1 -0
- data/lib/earth/fuel.rb +2 -0
- data/lib/earth/fuel/data_miner.rb +2 -0
- data/lib/earth/fuel/fuel_year.rb +7 -0
- data/lib/earth/fuel/fuel_year/data_miner.rb +76 -0
- data/lib/earth/fuel/greenhouse_gas.rb +7 -0
- data/lib/earth/fuel/greenhouse_gas/data_miner.rb +59 -0
- data/lib/earth/locality/country/data_miner.rb +1 -1
- data/lib/earth/locality/egrid_region/data_miner.rb +8 -0
- data/lib/earth/locality/egrid_subregion/data_miner.rb +3 -3
- data/lib/earth/locality/urbanity/data_miner.rb +2 -2
- data/lib/earth/locality/zip_code/data_miner.rb +2 -3
- data/lib/earth/residence/air_conditioner_use/data_miner.rb +2 -2
- data/lib/earth/residence/clothes_machine_use/data_miner.rb +3 -3
- data/lib/earth/residence/dishwasher_use/data_miner.rb +1 -1
- data/lib/earth/residence/residence_class/data_miner.rb +2 -2
- data/lib/earth/residence/residential_energy_consumption_survey_response.rb +4 -4
- data/lib/earth/residence/residential_energy_consumption_survey_response/data_miner.rb +3 -4
- data/spec/earth_spec.rb +4 -5
- metadata +196 -81
@@ -0,0 +1,46 @@
|
|
1
|
+
AutomobileTypeFuelYearControl.class_eval do
|
2
|
+
data_miner do
|
3
|
+
schema Earth.database_options do
|
4
|
+
string 'name'
|
5
|
+
string 'type_name'
|
6
|
+
string 'fuel_common_name'
|
7
|
+
integer 'year'
|
8
|
+
string 'control_name'
|
9
|
+
float 'total_travel_percent'
|
10
|
+
end
|
11
|
+
|
12
|
+
import "automobile type fuel year control data derived from the 2010 EPA GHG Inventory",
|
13
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGpQV2xMdlZkV1JzVlVTeU5ZalF6elE&hl=en&output=csv' do
|
14
|
+
key 'name'
|
15
|
+
store 'type_name'
|
16
|
+
store 'fuel_common_name'
|
17
|
+
store 'year'
|
18
|
+
store 'control_name'
|
19
|
+
store 'total_travel_percent'
|
20
|
+
end
|
21
|
+
|
22
|
+
verify "Type name, fuel common name, and control name should never be missing" do
|
23
|
+
AutomobileTypeFuelYearControl.all.each do |record|
|
24
|
+
%w{ type_name fuel_common_name control_name }.each do |attribute|
|
25
|
+
value = record.send(:"#{attribute}")
|
26
|
+
if value.nil?
|
27
|
+
raise "Missing #{attribute} for AutomobileTypeFuelYearControl '#{record.name}'"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
verify "Year should be from 1990 to 2008" do
|
34
|
+
AutomobileTypeFuelYearControl.all.each do |record|
|
35
|
+
year = record.send(:year)
|
36
|
+
unless year > 1989 and year < 2009
|
37
|
+
raise "Invalid year for AutomobileTypeFuelYearControl '#{record.name}': #{year} (should be from 1990 to 2008)"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# FIXME TODO
|
43
|
+
# verify "Total travel percent for each type fuel year should sum to one" do
|
44
|
+
# end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
AutomobileTypeYear.class_eval do
|
2
|
+
data_miner do
|
3
|
+
schema Earth.database_options do
|
4
|
+
string 'name'
|
5
|
+
string 'type_name'
|
6
|
+
integer 'year'
|
7
|
+
float 'hfc_emissions'
|
8
|
+
string 'hfc_emissions_units'
|
9
|
+
end
|
10
|
+
|
11
|
+
import "automobile type year air conditioning emissions derived from the 2010 EPA GHG Inventory",
|
12
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdFoyTWhDeHpndTV5Ny1aX0sxR1ljSFE&hl=en&output=csv' do
|
13
|
+
key 'name'
|
14
|
+
store 'type_name'
|
15
|
+
store 'year'
|
16
|
+
store 'hfc_emissions', :units_field_name => 'hfc_emissions_units'
|
17
|
+
end
|
18
|
+
|
19
|
+
verify "Type name should never be missing" do
|
20
|
+
AutomobileTypeYear.all.each do |record|
|
21
|
+
value = record.send(:type_name)
|
22
|
+
if value.nil?
|
23
|
+
raise "Missing type name for AutomobileTypeYear '#{record.name}'"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
verify "Year should be from 1990 to 2008" do
|
29
|
+
AutomobileTypeYear.all.each do |record|
|
30
|
+
year = record.send(:year)
|
31
|
+
unless year > 1989 and year < 2009
|
32
|
+
raise "Invalid year for AutomobileTypeYear '#{record.name}': #{year} (should be from 1990 to 2008)"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
verify "HFC emissions should be zero or more" do
|
38
|
+
AutomobileTypeYear.all.each do |record|
|
39
|
+
emissions = record.send(:hfc_emissions)
|
40
|
+
unless emissions >= 0
|
41
|
+
raise "Invalid HFC emissions for AutomobileTypeYear '#{record.name}': #{emissions} (should be zero or more)"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
verify "HFC emissions units should be kilograms CO2e" do
|
47
|
+
AutomobileTypeYear.all.each do |record|
|
48
|
+
units = record.send(:hfc_emissions_units)
|
49
|
+
unless units == "kilograms_co2e"
|
50
|
+
raise "Invalid HFC emissions units for AutomobileTypeYear '#{record.name}': #{units} (should be kilograms_co2e)"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -5,4 +5,10 @@ require 'earth/automobile/automobile_make_year/data_miner'
|
|
5
5
|
require 'earth/automobile/automobile_make_model/data_miner'
|
6
6
|
require 'earth/automobile/automobile_make_model_year/data_miner'
|
7
7
|
require 'earth/automobile/automobile_size_class/data_miner'
|
8
|
+
require 'earth/automobile/automobile_size_class_year/data_miner'
|
8
9
|
require 'earth/automobile/automobile_make_model_year_variant/data_miner'
|
10
|
+
require 'earth/automobile/automobile_type_year/data_miner'
|
11
|
+
require 'earth/automobile/automobile_type_fuel_age/data_miner'
|
12
|
+
require 'earth/automobile/automobile_type_fuel_control/data_miner'
|
13
|
+
require 'earth/automobile/automobile_type_fuel_year/data_miner'
|
14
|
+
require 'earth/automobile/automobile_type_fuel_year_control/data_miner'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
ComputationPlatform.class_eval do
|
2
|
+
data_miner do
|
3
|
+
schema Earth.database_options do
|
4
|
+
string 'name'
|
5
|
+
string 'data_center_company_name'
|
6
|
+
end
|
7
|
+
|
8
|
+
import "a list of computation platforms and the data center company they use",
|
9
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AkCJNpm9Ks6JdG5zVER5THhXRlE4N0RXTklVaS03Ymc&single=true&gid=0&output=csv' do
|
10
|
+
key 'name'
|
11
|
+
store 'data_center_company_name'
|
12
|
+
end
|
13
|
+
|
14
|
+
verify "Data center company name should never be missing" do
|
15
|
+
ComputationPlatform.all.each do |platform|
|
16
|
+
if platform.data_center_company_name.nil?
|
17
|
+
raise "Invalid data center company name for DataCenterCompany #{platform.name}: #{platform.data_center_company_name}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# FIXME TODO verify that all data center company names appear in data_center_companies
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
DataCenterCompany.class_eval do
|
2
|
+
data_miner do
|
3
|
+
schema Earth.database_options do
|
4
|
+
string 'name'
|
5
|
+
float 'power_usage_effectiveness'
|
6
|
+
end
|
7
|
+
|
8
|
+
import "a list of data center companies and their power usage effectiveness",
|
9
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdFlxZVZLai01WWJOOTFiaUd1blF6VkE&hl=en&single=true&gid=0&output=csv' do
|
10
|
+
key 'name'
|
11
|
+
store 'power_usage_effectiveness'
|
12
|
+
end
|
13
|
+
|
14
|
+
verify "Power usage effectiveness should be one or more" do
|
15
|
+
DataCenterCompany.all.each do |company|
|
16
|
+
unless company.power_usage_effectiveness >= 1.0
|
17
|
+
raise "Invalid power usage effectiveness for DataCenterCompany #{company.name}: #{company.power_usage_effectiveness} (should be >= 1.0)"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
ServerType.class_eval do
|
2
|
+
data_miner do
|
3
|
+
schema Earth.database_options do
|
4
|
+
string 'name'
|
5
|
+
string 'data_center_company_name'
|
6
|
+
float 'cpu'
|
7
|
+
string 'cpu_units'
|
8
|
+
float 'memory'
|
9
|
+
string 'memory_units'
|
10
|
+
float 'electricity_draw'
|
11
|
+
string 'electricity_draw_units'
|
12
|
+
end
|
13
|
+
|
14
|
+
import "a list of server types and their characteristics",
|
15
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AkCJNpm9Ks6JdGExaW1ic2c0d2s1ZmpzeUdOa2kyRlE&hl=en&single=true&gid=0&output=csv' do
|
16
|
+
key 'name'
|
17
|
+
store 'data_center_company_name'
|
18
|
+
store 'cpu', :units_field_name => 'cpu_units'
|
19
|
+
store 'memory', :units_field_name => 'memory_units'
|
20
|
+
store 'electricity_draw', :units_field_name => 'electricity_draw_units'
|
21
|
+
end
|
22
|
+
|
23
|
+
# FIXME TODO verify that data center company name appears in data_center_companies
|
24
|
+
|
25
|
+
verify "Data center company name should never be missing" do
|
26
|
+
ServerType.all.each do |server|
|
27
|
+
if server.data_center_company_name.nil?
|
28
|
+
raise "Invalid data center company name for ServerType #{server.name}: #{server.data_center_company_name}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
verify "Electricity draw should be more than zero" do
|
34
|
+
ServerType.all.each do |server|
|
35
|
+
unless server.electricity_draw > 0
|
36
|
+
raise "Invalid electricity draw for ServerType #{server.name}: #{server.electricity_draw} (should be > 0)"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
verify "Electricity draw units should be kilowatts" do
|
42
|
+
ServerType.all.each do |server|
|
43
|
+
unless server.electricity_draw_units == 'kilowatts'
|
44
|
+
raise "Invalid electricity draw units for ServerType #{server.name}: #{server.electricity_draw_units} (should be kilowatts)"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
class ServerTypeAlias < ActiveRecord::Base
|
2
|
+
set_primary_key :name
|
3
|
+
|
4
|
+
belongs_to :server_type, :foreign_key => 'server_type_name'
|
5
|
+
belongs_to :platform, :foreign_key => 'platform_name', :class_name => 'ComputationPlatform'
|
6
|
+
|
7
|
+
data_miner do
|
8
|
+
tap "Brighter Planet's server type data", Earth.taps_server
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
ServerTypeAlias.class_eval do
|
2
|
+
data_miner do
|
3
|
+
schema Earth.database_options do
|
4
|
+
string 'name'
|
5
|
+
string 'server_type_name'
|
6
|
+
string 'platform_name'
|
7
|
+
end
|
8
|
+
|
9
|
+
import "a list of server type aliases and their characteristics",
|
10
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AkCJNpm9Ks6JdDdkVlBzSUYweFN0OHBreEN6YTdTZ3c&hl=en&single=true&gid=0&output=csv' do
|
11
|
+
key 'name', :field_name => 'alias'
|
12
|
+
store 'server_type_name'
|
13
|
+
store 'platform_name'
|
14
|
+
end
|
15
|
+
|
16
|
+
# FIXME TODO verify that server type name appears in server_types
|
17
|
+
# FIXME TODO verify that platform name appears in computation_platforms
|
18
|
+
|
19
|
+
verify "Server type name and platform name should never be missing" do
|
20
|
+
ServerTypeAlias.all.each do |server_alias|
|
21
|
+
[:server_type_name, :platform_name].each do |x|
|
22
|
+
test_item = server_alias.send(x)
|
23
|
+
if test_item.nil?
|
24
|
+
raise "Invalid #{x} for ServerTypeAlias #{server_alias.name}: #{test_item}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/earth/data_miner.rb
CHANGED
data/lib/earth/fuel.rb
CHANGED
@@ -0,0 +1,76 @@
|
|
1
|
+
FuelYear.class_eval do
|
2
|
+
data_miner do
|
3
|
+
schema Earth.database_options do
|
4
|
+
string 'name'
|
5
|
+
string 'fuel_name'
|
6
|
+
integer 'year'
|
7
|
+
string 'fuel_common_name'
|
8
|
+
float 'carbon_content'
|
9
|
+
string 'carbon_content_units'
|
10
|
+
float 'energy_content'
|
11
|
+
string 'energy_content_units'
|
12
|
+
float 'co2_emission_factor'
|
13
|
+
string 'co2_emission_factor_units'
|
14
|
+
end
|
15
|
+
|
16
|
+
import "a list of fuel years and their carbon and energy contents, derived from the 2010 EPA GHG Inventory",
|
17
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdFZVSlZ3SUZsTzZLVTB5bVk5THdBN2c&hl=en&single=true&gid=0&output=csv' do
|
18
|
+
key 'name'
|
19
|
+
store 'fuel_name'
|
20
|
+
store 'year'
|
21
|
+
store 'fuel_common_name'
|
22
|
+
store 'carbon_content', :units_field_name => 'carbon_content_units'
|
23
|
+
store 'energy_content', :units_field_name => 'energy_content_units'
|
24
|
+
end
|
25
|
+
|
26
|
+
process "Calculate CO2 emission factor" do
|
27
|
+
conversion_factor = (1000000.0 / 1000000000000000.0) * (1000000000000.0 / 1000.0) * (1.0 / 158.987295) * (44.0 / 12.0)
|
28
|
+
update_all "co2_emission_factor = carbon_content * energy_content * #{conversion_factor}"
|
29
|
+
update_all "co2_emission_factor_units = 'kilograms_per_litre'"
|
30
|
+
end
|
31
|
+
|
32
|
+
verify "Fuel name and fuel common name should never be missing" do
|
33
|
+
FuelYear.all.each do |record|
|
34
|
+
%w{ fuel_name fuel_common_name }.each do |attribute|
|
35
|
+
value = record.send(:"#{attribute}")
|
36
|
+
if value.nil?
|
37
|
+
raise "Missing #{attribute} for FuelYear '#{record.name}'"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
verify "Year should be from 1990 to 2008" do
|
44
|
+
FuelYear.all.each do |record|
|
45
|
+
year = record.send(:year)
|
46
|
+
unless year > 1989 and year < 2009
|
47
|
+
raise "Invalid year for FuelYear '#{record.name}': #{year} (should be from 1990 to 2008)"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
verify "Carbon content, energy content, and CO2 emission factor should be greater than zero" do
|
53
|
+
FuelYear.all.each do |record|
|
54
|
+
%w{ carbon_content energy_content co2_emission_factor }.each do |attribute|
|
55
|
+
value = record.send(:"#{attribute}")
|
56
|
+
unless value > 0
|
57
|
+
raise "Invalid #{attribute} for FuelYear '#{record.name}': #{value} (should be > 0)"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
verify "Units should be correct" do
|
64
|
+
FuelYear.all.each do |record|
|
65
|
+
["carbon_content_units teragrams_per_quadrillion_btu", "energy_content_units million_btu_per_barrel", "co2_emission_factor_units kilograms_per_litre"].each do |pair|
|
66
|
+
attribute = pair.split[0]
|
67
|
+
proper_units = pair.split[1]
|
68
|
+
units = record.send(:"#{attribute}")
|
69
|
+
unless units == proper_units
|
70
|
+
raise "Invalid #{attribute} for FuelYear '#{record.name}': #{units} (should be #{proper_units})"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
GreenhouseGas.class_eval do
|
2
|
+
data_miner do
|
3
|
+
schema Earth.database_options do
|
4
|
+
string 'name'
|
5
|
+
string 'abbreviation'
|
6
|
+
string 'ipcc_report'
|
7
|
+
integer 'time_horizon'
|
8
|
+
string 'time_horizon_units'
|
9
|
+
integer 'global_warming_potential'
|
10
|
+
end
|
11
|
+
|
12
|
+
import "greenhouse gas global warming potentials taken from the IPCC AR4",
|
13
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdE1tUjBwS1ZHZnBUUG1XcVpkOTVHOVE&single=true&gid=0&output=csv' do
|
14
|
+
key 'name'
|
15
|
+
store 'abbreviation'
|
16
|
+
store 'ipcc_report'
|
17
|
+
store 'time_horizon', :units_field_name => 'time_horizon_units'
|
18
|
+
store 'global_warming_potential'
|
19
|
+
end
|
20
|
+
|
21
|
+
verify "Abbreviation and IPCC report should never be missing" do
|
22
|
+
GreenhouseGas.all.each do |record|
|
23
|
+
%w{ abbreviation ipcc_report }.each do |attribute|
|
24
|
+
value = record.send(:"#{attribute}")
|
25
|
+
if value.nil?
|
26
|
+
raise "Missing #{attribute} for GreenhouseGas '#{record.name}'"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
verify "Time horizon should be 100" do
|
33
|
+
GreenhouseGas.all.each do |record|
|
34
|
+
value = record.send(:time_horizon)
|
35
|
+
unless value == 100
|
36
|
+
raise "Invalid time horizon for GreenhouseGas '#{record.name}': #{value} (should be 100)"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
verify "Time horizon units should be years" do
|
42
|
+
GreenhouseGas.all.each do |record|
|
43
|
+
units = record.send(:time_horizon_units)
|
44
|
+
unless units == "years"
|
45
|
+
raise "Invalid time horizon units for GreenhouseGas '#{record.name}': #{units} (should be years)"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
verify "Global warming potential should be one or more" do
|
51
|
+
GreenhouseGas.all.each do |record|
|
52
|
+
value = record.send(:global_warming_potential)
|
53
|
+
unless value >= 1
|
54
|
+
raise "Invalid global warming potential for GreenhouseGas '#{record.name}': #{value} (should >= 1)"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|