earth 0.12.3 → 0.12.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. data/Gemfile +1 -0
  2. data/TODO +1 -0
  3. data/bin/earth_tester.rb +39 -47
  4. data/data/air/airlines.csv +45 -0
  5. data/data/air/airports.csv +11 -0
  6. data/data/hospitality/lodging_classes.csv +4 -0
  7. data/data/locality/national_electricity_efs.csv +137 -0
  8. data/earth.gemspec +1 -1
  9. data/errata/airline/bts_carrier_codes_errata.csv +2 -0
  10. data/lib/earth.rb +3 -0
  11. data/lib/earth/active_record_base_class_methods.rb +25 -0
  12. data/lib/earth/air/aircraft.rb +5 -4
  13. data/lib/earth/air/airline.rb +5 -1
  14. data/lib/earth/air/airline/data_miner.rb +1 -1
  15. data/lib/earth/air/airport.rb +10 -2
  16. data/lib/earth/air/airport/data_miner.rb +11 -5
  17. data/lib/earth/air/bts_aircraft.rb +1 -1
  18. data/lib/earth/air/flight_segment.rb +14 -1
  19. data/lib/earth/air/flight_segment/data_miner.rb +6 -13
  20. data/lib/earth/automobile/automobile_activity_year/data_miner.rb +1 -1
  21. data/lib/earth/automobile/automobile_activity_year_type/data_miner.rb +1 -1
  22. data/lib/earth/automobile/automobile_fuel/data_miner.rb +5 -5
  23. data/lib/earth/automobile/automobile_make/data_miner.rb +1 -1
  24. data/lib/earth/automobile/automobile_make_model/data_miner.rb +1 -1
  25. data/lib/earth/automobile/automobile_make_model_year/data_miner.rb +1 -1
  26. data/lib/earth/automobile/automobile_make_model_year_variant/data_miner.rb +6 -6
  27. data/lib/earth/automobile/automobile_type_fuel/data_miner.rb +2 -2
  28. data/lib/earth/automobile/automobile_type_fuel_year/data_miner.rb +1 -1
  29. data/lib/earth/conversions_ext.rb +7 -6
  30. data/lib/earth/fuel/fuel.rb +1 -1
  31. data/lib/earth/fuel/fuel/data_miner.rb +1 -3
  32. data/lib/earth/hospitality/commercial_building_energy_consumption_survey_response.rb +3 -1
  33. data/lib/earth/hospitality/commercial_building_energy_consumption_survey_response/data_miner.rb +44 -11
  34. data/lib/earth/hospitality/lodging_class.rb +0 -1
  35. data/lib/earth/hospitality/lodging_class/data_miner.rb +3 -9
  36. data/lib/earth/industry/merchant_category/data_miner.rb +14 -0
  37. data/lib/earth/locality/country.rb +33 -7
  38. data/lib/earth/locality/country/data_miner.rb +46 -32
  39. data/lib/earth/locality/egrid_subregion.rb +1 -1
  40. data/lib/earth/locality/egrid_subregion/data_miner.rb +16 -31
  41. data/lib/earth/locality/electricity_mix.rb +37 -0
  42. data/lib/earth/locality/electricity_mix/data_miner.rb +87 -0
  43. data/lib/earth/locality/state.rb +12 -4
  44. data/lib/earth/locality/state/data_miner.rb +33 -18
  45. data/lib/earth/locality/zip_code.rb +9 -1
  46. data/lib/earth/locality/zip_code/data_miner.rb +4 -0
  47. data/lib/earth/rail/country_rail_traction/data_miner.rb +2 -2
  48. data/lib/earth/rail/country_rail_traction_class/data_miner.rb +2 -2
  49. data/lib/earth/rail/national_transit_database_record.rb +4 -0
  50. data/lib/earth/rail/rail_company/data_miner.rb +3 -3
  51. data/lib/earth/rail/rail_fuel/data_miner.rb +1 -1
  52. data/lib/earth/residence/clothes_machine_use/data_miner.rb +1 -1
  53. data/lib/earth/residence/dishwasher_use/data_miner.rb +1 -1
  54. data/lib/earth/residence/residence_fuel_price.rb +1 -1
  55. data/lib/earth/version.rb +1 -1
  56. data/spec/earth/air/airline_spec.rb +1 -1
  57. data/spec/earth/air/airport_spec.rb +7 -0
  58. data/spec/earth/air/flight_segment_spec.rb +26 -12
  59. data/spec/earth/automobile/automobile_type_fuel_spec.rb +1 -1
  60. data/spec/earth/automobile/automobile_type_fuel_year_spec.rb +3 -3
  61. data/spec/earth/fuel/fuel_spec.rb +1 -1
  62. data/spec/earth/hospitality/commercial_building_energy_consumption_survey_response_spec.rb +32 -19
  63. data/spec/earth/hospitality/lodging_class_spec.rb +18 -0
  64. data/spec/earth/industry/mecs_energy_spec.rb +2 -2
  65. data/spec/earth/industry/mecs_ratio_spec.rb +1 -1
  66. data/spec/earth/industry/merchant_category_spec.rb +17 -0
  67. data/spec/earth/locality/country_spec.rb +32 -16
  68. data/spec/earth/locality/egrid_subregion_spec.rb +40 -27
  69. data/spec/earth/locality/electricity_mix_spec.rb +70 -0
  70. data/spec/earth/locality/state_spec.rb +10 -11
  71. data/spec/earth/locality/zip_code_spec.rb +9 -5
  72. data/spec/earth_spec.rb +4 -4
  73. data/spec/spec_helper.rb +3 -0
  74. metadata +19 -10
  75. data/lib/earth/hospitality/country_lodging_class.rb +0 -18
  76. data/lib/earth/hospitality/country_lodging_class/data_miner.rb +0 -40
  77. data/lib/earth/industry/merchant.rb +0 -9
  78. data/spec/earth/hospitality/country_lodging_class_spec.rb +0 -30
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+ require 'earth/hospitality/lodging_class'
3
+
4
+ describe LodgingClass do
5
+ describe 'when importing data', :data_miner => true do
6
+ before do
7
+ Earth.init :hospitality, :load_data_miner => true
8
+ end
9
+
10
+ it 'imports data' do
11
+ LodgingClass.run_data_miner!
12
+ end
13
+ end
14
+
15
+ describe 'verify imported data', :sanity => true do
16
+ it { LodgingClass.count.should == 3 }
17
+ end
18
+ end
@@ -21,13 +21,13 @@ describe MecsEnergy do
21
21
  apparel.census_region_number.should be_nil
22
22
  apparel.energy.should be_within(20_000).of(14770781900)
23
23
  apparel.energy_units.should == 'megajoules'
24
- apparel.electricity.should == be_within(1_000).of(7.trillion_btus.to(:megajoules))
24
+ apparel.electricity.should be_within(1_000).of(7.trillion_btus.to(:megajoules))
25
25
  apparel.electricity_units.should == 'megajoules'
26
26
  apparel.residual_fuel_oil.should == 0
27
27
  apparel.residual_fuel_oil_units.should == 'megajoules'
28
28
  apparel.distillate_fuel_oil.should == 0
29
29
  apparel.distillate_fuel_oil_units.should == 'megajoules'
30
- apparel.natural_gas.should == be_within(1_000).of(7.trillion_btus.to(:megajoules))
30
+ apparel.natural_gas.should be_within(1_000).of(7.trillion_btus.to(:megajoules))
31
31
  apparel.natural_gas_units.should == 'megajoules'
32
32
  apparel.lpg_and_ngl.should == 0
33
33
  apparel.lpg_and_ngl_units.should == 'megajoules'
@@ -19,7 +19,7 @@ describe MecsRatio do
19
19
  it 'spot checks the data' do
20
20
  apparel = MecsRatio.find_by_naics_code '315'
21
21
  apparel.census_region_number.should be_nil
22
- apparel.energy_per_dollar_of_shipments.should == be_within(0.000_001).of(0.5.kbtus.to(:megajoules))
22
+ apparel.energy_per_dollar_of_shipments.should be_within(5e-6).of(0.5.kbtus.to(:megajoules))
23
23
  apparel.energy_per_dollar_of_shipments_units.should == 'megajoules'
24
24
  end
25
25
  end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+ require 'earth/industry/merchant_category'
3
+
4
+ describe MerchantCategory do
5
+ describe 'import', :data_miner => true do
6
+ before do
7
+ Earth.init :industry, :load_data_miner => true, :skip_parent_associations => :true
8
+ end
9
+
10
+ it 'should import data' do
11
+ MerchantCategory.run_data_miner!
12
+ MerchantCategory.count.should > 0
13
+ MerchantCategory.first.mcc.to_s.should =~ /^\d+$/
14
+ MerchantCategory.first.description.to_s.should_not be_empty
15
+ end
16
+ end
17
+ end
@@ -6,11 +6,10 @@ require 'earth/locality/country'
6
6
  describe Country do
7
7
  describe 'import', :data_miner => true do
8
8
  before do
9
- Earth.init :locality, :load_data_miner => true, :skip_parent_associations => :true
9
+ Earth.init :locality, :load_data_miner => true
10
10
  end
11
11
 
12
12
  it 'should import data' do
13
- Country.delete_all if Country.table_exists?
14
13
  Country.run_data_miner!
15
14
  end
16
15
  end
@@ -38,17 +37,27 @@ describe Country do
38
37
  describe 'electricity data' do
39
38
  it { Country.where('electricity_emission_factor >= 0').count.should == 136 }
40
39
  it { Country.where(:electricity_emission_factor_units => 'kilograms_co2e_per_kilowatt_hour').count.should == 136 }
40
+ it { Country.where('electricity_co2_emission_factor >= 0').count.should == 136 }
41
+ it { Country.where(:electricity_co2_emission_factor_units => 'kilograms_per_kilowatt_hour').count.should == 136 }
42
+ it { Country.where('electricity_ch4_emission_factor >= 0').count.should == 136 }
43
+ it { Country.where(:electricity_ch4_emission_factor_units => 'kilograms_co2e_per_kilowatt_hour').count.should == 136 }
44
+ it { Country.where('electricity_n2o_emission_factor >= 0').count.should == 136 }
45
+ it { Country.where(:electricity_n2o_emission_factor_units => 'kilograms_co2e_per_kilowatt_hour').count.should == 136 }
41
46
  it { Country.where('electricity_loss_factor >= 0').count.should == 136 }
42
47
  it { Country.maximum(:electricity_loss_factor).should < 0.3 }
43
48
 
44
49
  # spot checks
45
- it { us.electricity_emission_factor.should be_within(5e-6).of(0.55437) }
46
- it { us.electricity_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour' }
50
+ it { us.electricity_emission_factor.should be_within(6e-6).of(0.55437) }
51
+ it { us.electricity_co2_emission_factor.should be_within(5e-6).of(0.55165) }
52
+ it { us.electricity_ch4_emission_factor.should be_within(5e-9).of(0.00027255) }
53
+ it { us.electricity_n2o_emission_factor.should be_within(5e-8).of(0.0024437) }
47
54
  it { us.electricity_loss_factor.should be_within(5e-6).of(0.06503) }
48
55
 
49
- it { uk.electricity_emission_factor.should be_within(1e-5).of(0.51020) }
50
- it { uk.electricity_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour' }
51
- it { uk.electricity_loss_factor.should be_within(1e-3).of(0.073) }
56
+ it { uk.electricity_emission_factor.should be_within(5e-6).of(0.51020) }
57
+ it { uk.electricity_co2_emission_factor.should be_within(5e-6).of(0.5085) }
58
+ it { uk.electricity_ch4_emission_factor.should be_within(5e-9).of(0.00016875) }
59
+ it { uk.electricity_n2o_emission_factor.should be_within(5e-8).of(0.00152576) }
60
+ it { uk.electricity_loss_factor.should be_within(5e-4).of(0.073) }
52
61
  end
53
62
 
54
63
  describe 'flight data' do
@@ -58,9 +67,9 @@ describe Country do
58
67
  end
59
68
 
60
69
  describe 'lodging data' do
61
- it { us.lodging_occupancy_rate.should be_within(0.001).of(0.601) }
62
- it { us.lodging_natural_gas_intensity.should be_within(0.00001).of(1.93316) }
63
- it { us.lodging_natural_gas_intensity_units.should == 'cubic_metres_per_occupied_room_night' }
70
+ it { us.lodging_occupancy_rate.should be_within(5e-4).of(0.601) }
71
+ it { us.lodging_natural_gas_intensity.should be_within(5e-4).of(50.719) }
72
+ it { us.lodging_natural_gas_intensity_units.should == 'megajoules_per_room_night' }
64
73
  end
65
74
 
66
75
  describe 'rail data' do
@@ -93,11 +102,18 @@ describe Country do
93
102
  end
94
103
 
95
104
  describe '.fallback' do
96
- it 'has fallback electricity emission factor and electricity loss factor' do
97
- fallback = Country.fallback
98
- fallback.electricity_emission_factor.should be_within(0.00001).of(0.62609)
99
- fallback.electricity_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour'
100
- fallback.electricity_loss_factor.should be_within(0.001).of(0.096)
101
- end
105
+ let(:fallback) { Country.fallback }
106
+
107
+ it { fallback.name.should == 'fallback' }
108
+ it { fallback.electricity_emission_factor.should be_within(5e-6).of(0.62609) }
109
+ it { fallback.electricity_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour' }
110
+ it { fallback.electricity_co2_emission_factor.should be_within(5e-6).of(0.62354) }
111
+ it { fallback.electricity_co2_emission_factor_units.should == 'kilograms_per_kilowatt_hour' }
112
+ it { fallback.electricity_ch4_emission_factor.should be_within(5e-6).of(0.00021) }
113
+ it { fallback.electricity_ch4_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour' }
114
+ it { fallback.electricity_n2o_emission_factor.should be_within(5e-6).of(0.00234) }
115
+ it { fallback.electricity_n2o_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour' }
116
+ it { fallback.electricity_loss_factor.should be_within(5e-4).of(0.096) }
117
+ it { fallback.electricity_mix.should == ElectricityMix.fallback }
102
118
  end
103
119
  end
@@ -13,37 +13,50 @@ describe EgridSubregion do
13
13
  end
14
14
 
15
15
  describe 'verify imported data', :sanity => true do
16
- it { EgridSubregion.count.should == 26 }
17
- it { EgridSubregion.where("net_generation > 0").count.should == EgridSubregion.count }
18
- it { EgridSubregion.where("co2_emission_factor > 0").count.should == EgridSubregion.count }
19
- it { EgridSubregion.where("co2_biogenic_emission_factor >= 0").count.should == EgridSubregion.count }
20
- it { EgridSubregion.where("ch4_emission_factor > 0").count.should == EgridSubregion.count }
21
- it { EgridSubregion.where("n2o_emission_factor > 0").count.should == EgridSubregion.count }
22
- it { EgridSubregion.where("electricity_emission_factor > 0").count.should == EgridSubregion.count }
16
+ let(:total) { EgridSubregion.count }
17
+ let(:akgd) { EgridSubregion.find 'akgd' }
18
+
19
+ it { total.should == 26 }
20
+ it { EgridSubregion.where("net_generation > 0").count.should == total }
21
+ it { EgridSubregion.where("co2_emission_factor > 0").count.should == total }
22
+ it { EgridSubregion.where(:co2_biogenic_emission_factor => nil).count.should == total }
23
+ it { EgridSubregion.where("ch4_emission_factor > 0").count.should == total }
24
+ it { EgridSubregion.where("n2o_emission_factor > 0").count.should == total }
25
+
26
+ # DEPRECATED
27
+ it { EgridSubregion.where("electricity_emission_factor > 0").count.should == total }
23
28
 
24
29
  # spot check
25
- it { EgridSubregion.first.net_generation.should be_within(5).of(5_337_982) }
26
- it { EgridSubregion.first.co2_emission_factor.should be_within(5e-6).of(0.58099) }
27
- it { EgridSubregion.first.co2_biogenic_emission_factor.should be_within(5e-6).of(0.0) }
28
- it { EgridSubregion.first.ch4_emission_factor.should be_within(5e-6).of(0.00031) }
29
- it { EgridSubregion.first.n2o_emission_factor.should be_within(5e-6).of(0.00104) }
30
- it { EgridSubregion.first.electricity_emission_factor.should be_within(5e-6).of(0.58234) }
31
-
32
- it { EgridSubregion.first.net_generation_units.should == 'megawatt_hours' }
33
- it { EgridSubregion.first.co2_emission_factor_units.should == 'kilograms_per_kilowatt_hour' }
34
- it { EgridSubregion.first.co2_biogenic_emission_factor_units.should == 'kilograms_per_kilowatt_hour' }
35
- it { EgridSubregion.first.ch4_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour' }
36
- it { EgridSubregion.first.n2o_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour' }
37
- it { EgridSubregion.first.electricity_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour' }
30
+ it { akgd.net_generation.should be_within(5).of(5_337_982) }
31
+ it { akgd.co2_emission_factor.should be_within(5e-6).of(0.58099) }
32
+ it { akgd.co2_biogenic_emission_factor.should == nil }
33
+ it { akgd.ch4_emission_factor.should be_within(5e-6).of(0.00031) }
34
+ it { akgd.n2o_emission_factor.should be_within(5e-6).of(0.00104) }
35
+
36
+ # DEPRECATED
37
+ it { akgd.electricity_emission_factor.should be_within(5e-6).of(0.58234) }
38
+
39
+ it { akgd.net_generation_units.should == 'megawatt_hours' }
40
+ it { akgd.co2_emission_factor_units.should == 'kilograms_per_kilowatt_hour' }
41
+ it { akgd.co2_biogenic_emission_factor_units.should == nil }
42
+ it { akgd.ch4_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour' }
43
+ it { akgd.n2o_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour' }
44
+
45
+ # DEPRECATED
46
+ it { akgd.electricity_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour' }
38
47
  end
39
48
 
40
49
  describe '.fallback' do
41
- it { EgridSubregion.fallback.name.should == 'fallback' }
42
- it { EgridSubregion.fallback.egrid_region.name.should == 'fallback' }
43
- it { EgridSubregion.fallback.co2_emission_factor.should be_within(5e-6).of(0.55165) }
44
- it { EgridSubregion.fallback.co2_biogenic_emission_factor.should be_within(5e-6).of(0.0) }
45
- it { EgridSubregion.fallback.ch4_emission_factor.should be_within(5e-6).of(0.00027) }
46
- it { EgridSubregion.fallback.n2o_emission_factor.should be_within(5e-6).of(0.00244) }
47
- it { EgridSubregion.fallback.electricity_emission_factor.should be_within(5e-6).of(0.55437) }
50
+ let(:fallback) { EgridSubregion.fallback }
51
+
52
+ it { fallback.name.should == 'fallback' }
53
+ it { fallback.egrid_region.name.should == 'fallback' }
54
+ it { fallback.co2_emission_factor.should be_within(5e-6).of(0.55165) }
55
+ it { fallback.co2_biogenic_emission_factor.should == nil }
56
+ it { fallback.ch4_emission_factor.should be_within(5e-6).of(0.00027) }
57
+ it { fallback.n2o_emission_factor.should be_within(5e-6).of(0.00244) }
58
+
59
+ # DEPRECATED
60
+ it { fallback.electricity_emission_factor.should be_within(5e-6).of(0.55437) }
48
61
  end
49
62
  end
@@ -0,0 +1,70 @@
1
+ require 'spec_helper'
2
+ require 'earth/locality/electricity_mix'
3
+
4
+ describe ElectricityMix do
5
+ describe 'import', :data_miner => true do
6
+ before do
7
+ Earth.init :locality, :load_data_miner => true
8
+ end
9
+
10
+ it 'should import data' do
11
+ ElectricityMix.run_data_miner!
12
+ end
13
+ end
14
+
15
+ describe 'verify imported data', :sanity => true do
16
+ let(:total) { ElectricityMix.count }
17
+ let(:uk) { ElectricityMix.find_by_country_iso_3166_code 'GB' }
18
+ let(:akgd) { ElectricityMix.find_by_egrid_subregion_abbreviation 'akgd' }
19
+ let(:us) { ElectricityMix.find_by_country_iso_3166_code 'US' }
20
+ let(:ca) { ElectricityMix.find_by_state_postal_abbreviation 'CA' }
21
+
22
+ it { total.should == 213 }
23
+ it { ElectricityMix.where('co2_emission_factor >= 0').count.should == total }
24
+ it { ElectricityMix.where(:co2_emission_factor_units => 'kilograms_per_kilowatt_hour').count.should == total }
25
+ it { ElectricityMix.where('ch4_emission_factor >= 0').count.should == total }
26
+ it { ElectricityMix.where(:ch4_emission_factor_units => 'kilograms_co2e_per_kilowatt_hour').count.should == total }
27
+ it { ElectricityMix.where('n2o_emission_factor >= 0').count.should == total }
28
+ it { ElectricityMix.where(:n2o_emission_factor_units => 'kilograms_co2e_per_kilowatt_hour').count.should == total }
29
+ it { ElectricityMix.where('loss_factor >= 0').count.should == total }
30
+ it { ElectricityMix.maximum(:loss_factor).should < 0.3 }
31
+
32
+ # spot checks
33
+ it { uk.co2_emission_factor.should be_within(5e-6).of(0.5085) }
34
+ it { uk.ch4_emission_factor.should be_within(5e-9).of(0.00016875) }
35
+ it { uk.n2o_emission_factor.should be_within(5e-9).of(0.00152576) }
36
+ it { uk.loss_factor.should be_within(5e-4).of(0.073) }
37
+
38
+ it { akgd.co2_emission_factor.should be_within(5e-6).of(0.58099) }
39
+ it { akgd.co2_biogenic_emission_factor.should == nil }
40
+ it { akgd.ch4_emission_factor.should be_within(5e-6).of(0.00031) }
41
+ it { akgd.n2o_emission_factor.should be_within(5e-6).of(0.00104) }
42
+ it { akgd.loss_factor.should be_within(5e-6).of(0.0584) }
43
+
44
+ it { us.co2_emission_factor.should be_within(5e-6).of(0.55165) }
45
+ it { us.ch4_emission_factor.should be_within(5e-9).of(0.00027255) }
46
+ it { us.n2o_emission_factor.should be_within(5e-8).of(0.0024437) }
47
+ it { us.loss_factor.should be_within(5e-6).of(0.06503) }
48
+
49
+ it { ca.co2_emission_factor.should be_within(5e-6).of(0.30163) }
50
+ it { ca.ch4_emission_factor.should be_within(5e-6).of(0.00033) }
51
+ it { ca.n2o_emission_factor.should be_within(5e-6).of(0.00085) }
52
+ it { ca.loss_factor.should be_within(5e-6).of(0.08208) }
53
+ end
54
+
55
+ describe '.fallback' do
56
+ it { ElectricityMix.fallback.name.should == 'fallback' }
57
+ it { ElectricityMix.fallback.co2_emission_factor.should be_within(5e-6).of(0.62354) }
58
+ it { ElectricityMix.fallback.ch4_emission_factor.should be_within(5e-6).of(0.00021) }
59
+ it { ElectricityMix.fallback.n2o_emission_factor.should be_within(5e-6).of(0.00234) }
60
+ it { ElectricityMix.fallback.loss_factor.should be_within(5e-6).of(0.096) }
61
+ end
62
+
63
+ describe '#energy_content' do
64
+ it { ElectricityMix.first.energy_content.should be_within(5e-6).of(3.6) }
65
+ end
66
+
67
+ describe '#energy_content_units' do
68
+ it { ElectricityMix.first.energy_content_units.should == 'megajoules_per_kilowatt_hour' }
69
+ end
70
+ end
@@ -4,7 +4,7 @@ require 'earth/locality/state'
4
4
  describe State do
5
5
  describe 'when importing data', :data_miner => true do
6
6
  before do
7
- Earth.init :locality, :load_data_miner => true, :skip_parent_associations => :true
7
+ Earth.init :locality, :load_data_miner => true
8
8
  end
9
9
 
10
10
  it 'imports data' do
@@ -24,21 +24,21 @@ describe State do
24
24
  end
25
25
 
26
26
  it 'should have an average electricity emission factor' do
27
- State.find('VT').electricity_emission_factor.should be_within(0.00001).of(0.37848)
27
+ State.find('VT').electricity_emission_factor.should be_within(5e-6).of(0.33313)
28
28
  State.find('VT').electricity_emission_factor_units.should == "kilograms_co2e_per_kilowatt_hour"
29
- State.find('CA').electricity_emission_factor.should be_within(0.00001).of(0.31315)
29
+ State.find('CA').electricity_emission_factor.should be_within(5e-6).of(0.30281)
30
30
  State.find('CA').electricity_emission_factor_units.should == "kilograms_co2e_per_kilowatt_hour"
31
- State.find('MT').electricity_emission_factor.should be_within(0.00001).of(0.41092)
31
+ State.find('MT').electricity_emission_factor.should be_within(5e-6).of(0.39160)
32
32
  State.find('MT').electricity_emission_factor_units.should == "kilograms_co2e_per_kilowatt_hour"
33
- State.find('NM').electricity_emission_factor.should be_within(0.00001).of(0.57194)
33
+ State.find('NM').electricity_emission_factor.should be_within(5e-6).of(0.54601)
34
34
  State.find('NM').electricity_emission_factor_units.should == "kilograms_co2e_per_kilowatt_hour"
35
35
  end
36
36
 
37
37
  it 'should have an average electricity loss factor' do
38
- State.find('VT').electricity_loss_factor.should be_within(0.00001).of(0.0647079)
39
- State.find('CA').electricity_loss_factor.should be_within(0.00001).of(0.0483723)
40
- State.find('MT').electricity_loss_factor.should be_within(0.00001).of(0.0491516)
41
- State.find('NM').electricity_loss_factor.should be_within(0.00001).of(0.0499872)
38
+ State.find('VT').electricity_loss_factor.should be_within(5e-6).of(0.05822)
39
+ State.find('CA').electricity_loss_factor.should be_within(5e-6).of(0.08208)
40
+ State.find('MT').electricity_loss_factor.should be_within(5e-6).of(0.08094)
41
+ State.find('NM').electricity_loss_factor.should be_within(5e-6).of(0.08007)
42
42
  end
43
43
  end
44
44
 
@@ -47,9 +47,8 @@ describe State do
47
47
  require 'earth/locality/country'
48
48
  end
49
49
 
50
- it 'should the United States' do
50
+ it 'should return the United States' do
51
51
  State.first.country.should == Country.united_states
52
- State.last.country.should == Country.united_states
53
52
  end
54
53
  end
55
54
  end
@@ -21,6 +21,15 @@ describe ZipCode do
21
21
  it { ZipCode.where('population IS NOT NULL').count.should == 33120 }
22
22
  end
23
23
 
24
+ # from acts_as_mappable
25
+ describe '.find_within' do
26
+ it { ZipCode.find_within(15, :units => :kms, :origin => ZipCode.find('05753').latitude_longitude).count.should == 7 }
27
+ end
28
+
29
+ describe '.known_subregion' do
30
+ it { ZipCode.known_subregion.where(:egrid_subregion_abbreviation => nil).count.should == 0 }
31
+ end
32
+
24
33
  describe '#country' do
25
34
  before do
26
35
  require 'earth/locality/country'
@@ -38,9 +47,4 @@ describe ZipCode do
38
47
  ZipCode.find('00210').latitude_longitude.should == ['43.005895', '-71.013202']
39
48
  end
40
49
  end
41
-
42
- # from acts_as_mappable
43
- describe '.find_within' do
44
- it { ZipCode.find_within(15, :units => :kms, :origin => ZipCode.find('05753').latitude_longitude).count.should == 7 }
45
- end
46
50
  end
data/spec/earth_spec.rb CHANGED
@@ -22,7 +22,7 @@ describe Earth do
22
22
 
23
23
  describe '.resources' do
24
24
  it 'should get a list of all resource names' do
25
- Earth.resources.length.should == 101
25
+ Earth.resources.length.should == 100
26
26
  Earth.resources.should include('Aircraft')
27
27
  Earth.resources.should include('Industry')
28
28
  end
@@ -34,9 +34,9 @@ describe Earth do
34
34
  Earth.resources('diet').length.should == 2
35
35
  Earth.resources('electricity').length.should == 3
36
36
  Earth.resources('fuel').length.should == 5
37
- Earth.resources('hospitality').length.should == 3
38
- Earth.resources('industry').length.should == 18
39
- Earth.resources('locality').length.should == 10
37
+ Earth.resources('hospitality').length.should == 2
38
+ Earth.resources('industry').length.should == 17
39
+ Earth.resources('locality').length.should == 11
40
40
  Earth.resources('pet').length.should == 4
41
41
  Earth.resources('rail').length.should == 12
42
42
  Earth.resources('residence').length.should == 9
data/spec/spec_helper.rb CHANGED
@@ -50,4 +50,7 @@ RSpec.configure do |c|
50
50
  unless ENV['ALL'] == 'true'
51
51
  c.filter_run_excluding :data_miner => true
52
52
  end
53
+ if ENV['SKIP_FLIGHT_SEGMENT'] == 'true'
54
+ c.filter_run_excluding :flight_segment => true
55
+ end
53
56
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: earth
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.12.3
5
+ version: 0.12.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Seamus Abshere
@@ -12,7 +12,7 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2012-06-20 00:00:00 Z
15
+ date: 2012-07-25 00:00:00 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activerecord
@@ -131,7 +131,7 @@ dependencies:
131
131
  requirements:
132
132
  - - ">="
133
133
  - !ruby/object:Gem::Version
134
- version: 1.3.0
134
+ version: 2.0.2
135
135
  type: :runtime
136
136
  prerelease: false
137
137
  version_requirements: *id011
@@ -314,6 +314,8 @@ files:
314
314
  - TODO
315
315
  - bin/earth_tester.rb
316
316
  - certification_changelog.markdown
317
+ - data/air/airlines.csv
318
+ - data/air/airports.csv
317
319
  - data/automobile/annual_emission_controls.csv
318
320
  - data/automobile/annual_fuel_consumption.csv
319
321
  - data/automobile/annual_sizes.csv
@@ -325,9 +327,11 @@ files:
325
327
  - data/automobile/hybridity_multipliers.csv
326
328
  - data/automobile/sizes.csv
327
329
  - data/automobile/trip_distances.csv
330
+ - data/hospitality/lodging_classes.csv
328
331
  - data/locality/country_flight_data.csv
329
332
  - data/locality/egrid_relationships.csv
330
333
  - data/locality/misc_zip_data.csv
334
+ - data/locality/national_electricity_efs.csv
331
335
  - data/locality/us_auto_data.csv
332
336
  - data/locality/wri_hdd_cdd_data.csv
333
337
  - data/locality/zip_climate_divisions.csv
@@ -345,6 +349,7 @@ files:
345
349
  - errata/readme
346
350
  - lib/earth.rb
347
351
  - lib/earth/acronyms.rb
352
+ - lib/earth/active_record_base_class_methods.rb
348
353
  - lib/earth/air.rb
349
354
  - lib/earth/air/aircraft.rb
350
355
  - lib/earth/air/aircraft/data_miner.rb
@@ -450,8 +455,6 @@ files:
450
455
  - lib/earth/hospitality.rb
451
456
  - lib/earth/hospitality/commercial_building_energy_consumption_survey_response.rb
452
457
  - lib/earth/hospitality/commercial_building_energy_consumption_survey_response/data_miner.rb
453
- - lib/earth/hospitality/country_lodging_class.rb
454
- - lib/earth/hospitality/country_lodging_class/data_miner.rb
455
458
  - lib/earth/hospitality/data_miner.rb
456
459
  - lib/earth/hospitality/lodging_class.rb
457
460
  - lib/earth/hospitality/lodging_class/data_miner.rb
@@ -468,8 +471,8 @@ files:
468
471
  - lib/earth/industry/mecs_energy/data_miner.rb
469
472
  - lib/earth/industry/mecs_ratio.rb
470
473
  - lib/earth/industry/mecs_ratio/data_miner.rb
471
- - lib/earth/industry/merchant.rb
472
474
  - lib/earth/industry/merchant_category.rb
475
+ - lib/earth/industry/merchant_category/data_miner.rb
473
476
  - lib/earth/industry/merchant_category_industry.rb
474
477
  - lib/earth/industry/naics_2002.rb
475
478
  - lib/earth/industry/naics_2002/data_miner.rb
@@ -501,6 +504,8 @@ files:
501
504
  - lib/earth/locality/egrid_region/data_miner.rb
502
505
  - lib/earth/locality/egrid_subregion.rb
503
506
  - lib/earth/locality/egrid_subregion/data_miner.rb
507
+ - lib/earth/locality/electricity_mix.rb
508
+ - lib/earth/locality/electricity_mix/data_miner.rb
504
509
  - lib/earth/locality/petroleum_administration_for_defense_district.rb
505
510
  - lib/earth/locality/petroleum_administration_for_defense_district/data_miner.rb
506
511
  - lib/earth/locality/state.rb
@@ -604,11 +609,12 @@ files:
604
609
  - spec/earth/electricity/green_button_adoption_spec.rb
605
610
  - spec/earth/fuel/fuel_spec.rb
606
611
  - spec/earth/hospitality/commercial_building_energy_consumption_survey_response_spec.rb
607
- - spec/earth/hospitality/country_lodging_class_spec.rb
612
+ - spec/earth/hospitality/lodging_class_spec.rb
608
613
  - spec/earth/industry/cbecs_energy_intensity_spec.rb
609
614
  - spec/earth/industry/industry_spec.rb
610
615
  - spec/earth/industry/mecs_energy_spec.rb
611
616
  - spec/earth/industry/mecs_ratio_spec.rb
617
+ - spec/earth/industry/merchant_category_spec.rb
612
618
  - spec/earth/industry/naics_2002_naics_2007_concordance_spec.rb
613
619
  - spec/earth/industry/naics_2002_sic_1987_concordance_spec.rb
614
620
  - spec/earth/industry/naics_2002_spec.rb
@@ -618,6 +624,7 @@ files:
618
624
  - spec/earth/locality/egrid_country_spec.rb
619
625
  - spec/earth/locality/egrid_region_spec.rb
620
626
  - spec/earth/locality/egrid_subregion_spec.rb
627
+ - spec/earth/locality/electricity_mix_spec.rb
621
628
  - spec/earth/locality/state_spec.rb
622
629
  - spec/earth/locality/zip_code_spec.rb
623
630
  - spec/earth/pet/species_spec.rb
@@ -681,7 +688,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
681
688
  requirements:
682
689
  - - ">="
683
690
  - !ruby/object:Gem::Version
684
- hash: -307877030326161721
691
+ hash: -3264838130013702299
685
692
  segments:
686
693
  - 0
687
694
  version: "0"
@@ -690,7 +697,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
690
697
  requirements:
691
698
  - - ">="
692
699
  - !ruby/object:Gem::Version
693
- hash: -307877030326161721
700
+ hash: -3264838130013702299
694
701
  segments:
695
702
  - 0
696
703
  version: "0"
@@ -733,11 +740,12 @@ test_files:
733
740
  - spec/earth/electricity/green_button_adoption_spec.rb
734
741
  - spec/earth/fuel/fuel_spec.rb
735
742
  - spec/earth/hospitality/commercial_building_energy_consumption_survey_response_spec.rb
736
- - spec/earth/hospitality/country_lodging_class_spec.rb
743
+ - spec/earth/hospitality/lodging_class_spec.rb
737
744
  - spec/earth/industry/cbecs_energy_intensity_spec.rb
738
745
  - spec/earth/industry/industry_spec.rb
739
746
  - spec/earth/industry/mecs_energy_spec.rb
740
747
  - spec/earth/industry/mecs_ratio_spec.rb
748
+ - spec/earth/industry/merchant_category_spec.rb
741
749
  - spec/earth/industry/naics_2002_naics_2007_concordance_spec.rb
742
750
  - spec/earth/industry/naics_2002_sic_1987_concordance_spec.rb
743
751
  - spec/earth/industry/naics_2002_spec.rb
@@ -747,6 +755,7 @@ test_files:
747
755
  - spec/earth/locality/egrid_country_spec.rb
748
756
  - spec/earth/locality/egrid_region_spec.rb
749
757
  - spec/earth/locality/egrid_subregion_spec.rb
758
+ - spec/earth/locality/electricity_mix_spec.rb
750
759
  - spec/earth/locality/state_spec.rb
751
760
  - spec/earth/locality/zip_code_spec.rb
752
761
  - spec/earth/pet/species_spec.rb