earth 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (239) hide show
  1. data/Rakefile +9 -21
  2. data/data/rail/ntd_companies.csv +1 -0
  3. data/data/rail/ntd_fuel_consumption.csv +1 -0
  4. data/data/rail/ntd_modes.csv +1 -0
  5. data/data/rail/ntd_service.csv +1 -0
  6. data/errata/flight_segment/bts_errata.csv +6 -0
  7. data/lib/earth.rb +1 -0
  8. data/lib/earth/air/aircraft.rb +3 -5
  9. data/lib/earth/air/airline.rb +2 -3
  10. data/lib/earth/air/airport.rb +4 -5
  11. data/lib/earth/air/bts_aircraft.rb +1 -1
  12. data/lib/earth/air/flight_distance_class.rb +0 -1
  13. data/lib/earth/air/flight_distance_class/data_miner.rb +0 -4
  14. data/lib/earth/air/flight_distance_class_seat_class.rb +0 -1
  15. data/lib/earth/air/flight_segment.rb +12 -13
  16. data/lib/earth/air/flight_segment/data_miner.rb +13 -0
  17. data/lib/earth/automobile/automobile_activity_year.rb +0 -1
  18. data/lib/earth/automobile/automobile_activity_year_type.rb +4 -4
  19. data/lib/earth/automobile/automobile_activity_year_type_fuel.rb +1 -2
  20. data/lib/earth/automobile/automobile_fuel.rb +1 -2
  21. data/lib/earth/automobile/automobile_make.rb +0 -1
  22. data/lib/earth/automobile/automobile_make/data_miner.rb +2 -0
  23. data/lib/earth/automobile/automobile_make_model.rb +1 -2
  24. data/lib/earth/automobile/automobile_make_model_year_variant.rb +0 -1
  25. data/lib/earth/automobile/automobile_make_model_year_variant/data_miner.rb +2 -223
  26. data/lib/earth/automobile/automobile_make_model_year_variant/parser.rb +224 -0
  27. data/lib/earth/automobile/automobile_make_year_fleet.rb +0 -1
  28. data/lib/earth/automobile/automobile_model.rb +0 -1
  29. data/lib/earth/automobile/automobile_size_class.rb +0 -1
  30. data/lib/earth/automobile/automobile_type_fuel.rb +0 -1
  31. data/lib/earth/automobile/automobile_type_fuel_control.rb +0 -1
  32. data/lib/earth/automobile/automobile_type_fuel_year.rb +4 -4
  33. data/lib/earth/automobile/automobile_type_fuel_year_control.rb +7 -15
  34. data/lib/earth/automobile/automobile_year.rb +0 -1
  35. data/lib/earth/bus/bus_class.rb +0 -1
  36. data/lib/earth/bus/bus_fuel.rb +1 -72
  37. data/lib/earth/bus/bus_fuel_control.rb +0 -1
  38. data/lib/earth/bus/bus_fuel_control/data_miner.rb +0 -2
  39. data/lib/earth/bus/bus_fuel_year_control.rb +0 -1
  40. data/lib/earth/bus/bus_fuel_year_control/data_miner.rb +0 -2
  41. data/lib/earth/computation/computation_carrier.rb +1 -11
  42. data/lib/earth/computation/computation_carrier_instance_class.rb +4 -25
  43. data/lib/earth/computation/computation_carrier_region.rb +0 -1
  44. data/lib/earth/computation/computation_carrier_region/data_miner.rb +0 -3
  45. data/lib/earth/diet/diet_class.rb +0 -1
  46. data/lib/earth/diet/food_group.rb +1 -1
  47. data/lib/earth/electricity/electric_market.rb +2 -0
  48. data/lib/earth/electricity/electric_utility.rb +11 -4
  49. data/lib/earth/electricity/electric_utility/data_miner.rb +2 -8
  50. data/lib/earth/electricity/green_button_adoption.rb +2 -1
  51. data/lib/earth/fuel/fuel.rb +20 -81
  52. data/lib/earth/fuel/fuel_year.rb +0 -44
  53. data/lib/earth/fuel/greenhouse_gas.rb +0 -40
  54. data/lib/earth/hospitality/lodging_class.rb +0 -1
  55. data/lib/earth/industry/cbecs_energy_intensity.rb +25 -29
  56. data/lib/earth/industry/cbecs_energy_intensity/data_miner.rb +1 -1
  57. data/lib/earth/industry/industry.rb +1 -2
  58. data/lib/earth/industry/mecs_energy.rb +9 -10
  59. data/lib/earth/industry/mecs_ratio.rb +2 -1
  60. data/lib/earth/industry/merchant_category.rb +1 -0
  61. data/lib/earth/industry/naics_2002.rb +2 -0
  62. data/lib/earth/industry/naics_2002_naics_2007_concordance.rb +1 -0
  63. data/lib/earth/industry/naics_2002_sic_1987_concordance.rb +1 -0
  64. data/lib/earth/industry/naics_2007.rb +1 -0
  65. data/lib/earth/industry/sic_1987.rb +1 -0
  66. data/lib/earth/locality/census_division.rb +1 -3
  67. data/lib/earth/locality/climate_division.rb +0 -1
  68. data/lib/earth/locality/country.rb +1 -2
  69. data/lib/earth/locality/country/data_miner.rb +4 -0
  70. data/lib/earth/locality/egrid_country.rb +0 -1
  71. data/lib/earth/locality/egrid_region.rb +1 -3
  72. data/lib/earth/locality/egrid_subregion.rb +1 -3
  73. data/lib/earth/locality/electricity_mix.rb +2 -4
  74. data/lib/earth/locality/petroleum_administration_for_defense_district.rb +0 -1
  75. data/lib/earth/locality/state.rb +0 -1
  76. data/lib/earth/locality/zip_code.rb +0 -1
  77. data/lib/earth/model.rb +1 -1
  78. data/lib/earth/pet/breed.rb +0 -1
  79. data/lib/earth/pet/breed_gender.rb +0 -1
  80. data/lib/earth/pet/gender.rb +0 -1
  81. data/lib/earth/pet/species.rb +1 -3
  82. data/lib/earth/rail/country_rail_class.rb +0 -1
  83. data/lib/earth/rail/country_rail_traction.rb +0 -1
  84. data/lib/earth/rail/country_rail_traction_class.rb +0 -1
  85. data/lib/earth/rail/national_transit_database_company.rb +1 -3
  86. data/lib/earth/rail/national_transit_database_company/data_miner.rb +1 -1
  87. data/lib/earth/rail/national_transit_database_mode.rb +0 -1
  88. data/lib/earth/rail/national_transit_database_mode/data_miner.rb +1 -1
  89. data/lib/earth/rail/national_transit_database_record.rb +0 -1
  90. data/lib/earth/rail/national_transit_database_record/data_miner.rb +2 -2
  91. data/lib/earth/rail/rail_class.rb +0 -1
  92. data/lib/earth/rail/rail_class/data_miner.rb +5 -4
  93. data/lib/earth/rail/rail_company.rb +0 -1
  94. data/lib/earth/rail/rail_fuel.rb +0 -1
  95. data/lib/earth/rail/rail_traction.rb +0 -1
  96. data/lib/earth/rail/rail_traction/data_miner.rb +2 -8
  97. data/lib/earth/residence/air_conditioner_use.rb +0 -1
  98. data/lib/earth/residence/clothes_machine_use.rb +0 -1
  99. data/lib/earth/residence/dishwasher_use.rb +0 -1
  100. data/lib/earth/residence/residence_appliance.rb +0 -1
  101. data/lib/earth/residence/residence_class.rb +0 -1
  102. data/lib/earth/residence/residence_fuel_price.rb +1 -2
  103. data/lib/earth/residence/urbanity.rb +0 -1
  104. data/lib/earth/shipping/carrier.rb +1 -52
  105. data/lib/earth/shipping/carrier_mode.rb +0 -34
  106. data/lib/earth/shipping/shipment_mode.rb +0 -26
  107. data/lib/earth/tasks.rb +14 -4
  108. data/lib/earth/version.rb +1 -1
  109. data/spec/earth/air/aircraft_spec.rb +9 -1
  110. data/spec/earth/air/airline_spec.rb +2 -2
  111. data/spec/earth/air/airport_spec.rb +1 -2
  112. data/spec/earth/air/bts_aircraft_spec.rb +2 -2
  113. data/spec/earth/air/flight_distance_class_seat_class_spec.rb +22 -0
  114. data/spec/earth/air/flight_distance_class_spec.rb +26 -18
  115. data/spec/earth/air/flight_seat_class_spec.rb +12 -0
  116. data/spec/earth/air/flight_segment_spec.rb +38 -33
  117. data/spec/earth/automobile/automobile_activity_year_spec.rb +20 -14
  118. data/spec/earth/automobile/automobile_activity_year_type_fuel_spec.rb +14 -10
  119. data/spec/earth/automobile/automobile_activity_year_type_spec.rb +28 -20
  120. data/spec/earth/automobile/automobile_fuel_spec.rb +106 -52
  121. data/spec/earth/automobile/automobile_make_model_spec.rb +103 -62
  122. data/spec/earth/automobile/automobile_make_model_year_spec.rb +69 -46
  123. data/spec/earth/automobile/automobile_make_model_year_variant_spec.rb +108 -109
  124. data/spec/earth/automobile/automobile_make_spec.rb +8 -8
  125. data/spec/earth/automobile/automobile_make_year_fleet_spec.rb +10 -6
  126. data/spec/earth/automobile/automobile_make_year_spec.rb +10 -9
  127. data/spec/earth/automobile/automobile_model_spec.rb +3 -0
  128. data/spec/earth/automobile/automobile_size_class_spec.rb +12 -11
  129. data/spec/earth/automobile/automobile_type_fuel_control_spec.rb +9 -9
  130. data/spec/earth/automobile/automobile_type_fuel_spec.rb +23 -18
  131. data/spec/earth/automobile/automobile_type_fuel_year_control_spec.rb +37 -29
  132. data/spec/earth/automobile/automobile_type_fuel_year_spec.rb +35 -36
  133. data/spec/earth/automobile/automobile_year_spec.rb +4 -2
  134. data/spec/earth/bus/bus_class_spec.rb +10 -0
  135. data/spec/earth/bus/bus_fuel_control_spec.rb +3 -5
  136. data/spec/earth/bus/bus_fuel_spec.rb +16 -8
  137. data/spec/earth/bus/bus_fuel_year_control_spec.rb +7 -7
  138. data/spec/earth/computation/computation_carrrier_instance_class_spec.rb +17 -0
  139. data/spec/earth/computation/computation_carrrier_region_spec.rb +10 -0
  140. data/spec/earth/computation/computation_carrrier_spec.rb +17 -0
  141. data/spec/earth/diet/diet_class_spec.rb +14 -0
  142. data/spec/earth/diet/food_group_spec.rb +26 -0
  143. data/spec/earth/electricity/electric_market_spec.rb +4 -5
  144. data/spec/earth/electricity/electric_utility_spec.rb +30 -19
  145. data/spec/earth/electricity/green_button_adoption_spec.rb +29 -7
  146. data/spec/earth/fuel/fuel_spec.rb +88 -14
  147. data/spec/earth/fuel/fuel_year_spec.rb +21 -0
  148. data/spec/earth/fuel/greenhouse_gas_spec.rb +23 -0
  149. data/spec/earth/hospitality/commercial_building_energy_consumption_survey_response_spec.rb +13 -10
  150. data/spec/earth/hospitality/lodging_class_spec.rb +1 -1
  151. data/spec/earth/industry/cbecs_energy_intensity_spec.rb +72 -72
  152. data/spec/earth/industry/industry_spec.rb +16 -9
  153. data/spec/earth/industry/mecs_energy_spec.rb +76 -72
  154. data/spec/earth/industry/mecs_ratio_spec.rb +35 -31
  155. data/spec/earth/industry/merchant_category_spec.rb +7 -5
  156. data/spec/earth/industry/naics_2002_naics_2007_concordance_spec.rb +10 -19
  157. data/spec/earth/industry/naics_2002_sic_1987_concordance_spec.rb +9 -19
  158. data/spec/earth/industry/naics_2002_spec.rb +1 -11
  159. data/spec/earth/industry/naics_2007_spec.rb +2 -11
  160. data/spec/earth/industry/sic_1987_spec.rb +3 -14
  161. data/spec/earth/locality/census_division_spec.rb +25 -0
  162. data/spec/earth/locality/census_region_spec.rb +8 -0
  163. data/spec/earth/locality/climate_division_spec.rb +13 -0
  164. data/spec/earth/locality/country_spec.rb +24 -23
  165. data/spec/earth/locality/egrid_country_spec.rb +7 -6
  166. data/spec/earth/locality/egrid_region_spec.rb +6 -6
  167. data/spec/earth/locality/egrid_subregion_spec.rb +14 -14
  168. data/spec/earth/locality/electricity_mix_spec.rb +17 -17
  169. data/spec/earth/locality/padd_spec.rb +21 -0
  170. data/spec/earth/locality/state_spec.rb +8 -11
  171. data/spec/earth/locality/zip_code_spec.rb +29 -22
  172. data/spec/earth/pet/breed_gender_spec.rb +8 -0
  173. data/spec/earth/pet/breed_spec.rb +8 -0
  174. data/spec/earth/pet/gender_spec.rb +8 -0
  175. data/spec/earth/pet/species_spec.rb +11 -5
  176. data/spec/earth/rail/country_rail_class_spec.rb +16 -0
  177. data/spec/earth/rail/country_rail_traction_class_spec.rb +14 -0
  178. data/spec/earth/rail/country_rail_traction_spec.rb +14 -0
  179. data/spec/earth/rail/national_transit_database_company_spec.rb +103 -0
  180. data/spec/earth/rail/national_transit_database_mode_spec.rb +21 -0
  181. data/spec/earth/rail/national_transit_database_record_spec.rb +31 -0
  182. data/spec/earth/rail/rail_class_spec.rb +8 -0
  183. data/spec/earth/rail/rail_company_spec.rb +20 -0
  184. data/spec/earth/rail/rail_fuel_spec.rb +19 -0
  185. data/spec/earth/rail/rail_traction_spec.rb +8 -0
  186. data/spec/earth/residence/air_conditioner_use_spec.rb +17 -0
  187. data/spec/earth/residence/clothes_machine_use_spec.rb +11 -0
  188. data/spec/earth/residence/dishwasher_use_spec.rb +11 -0
  189. data/spec/earth/residence/residence_appliance_spec.rb +19 -0
  190. data/spec/earth/residence/residence_class_spec.rb +15 -0
  191. data/spec/earth/residence/residence_fuel_price_spec.rb +12 -0
  192. data/spec/earth/residence/residence_fuel_type_spec.rb +18 -0
  193. data/spec/earth/residence/residential_energy_consumption_survey_response_spec.rb +13 -0
  194. data/spec/earth/residence/urbanity_spec.rb +8 -0
  195. data/spec/earth/shipping/carrier_mode_spec.rb +18 -0
  196. data/spec/earth/shipping/carrier_spec.rb +27 -0
  197. data/spec/earth/shipping/shipment_mode_spec.rb +16 -0
  198. data/spec/earth_spec.rb +1 -1
  199. data/spec/factories/airline.rb +0 -1
  200. data/spec/factories/airport.rb +0 -1
  201. data/spec/factories/automobile_activity_year.rb +8 -0
  202. data/spec/factories/automobile_activity_year_type.rb +8 -0
  203. data/spec/factories/automobile_activity_year_type_fuel.rb +9 -0
  204. data/spec/factories/automobile_fuel.rb +15 -0
  205. data/spec/factories/automobile_make.rb +9 -0
  206. data/spec/factories/automobile_make_model.rb +10 -0
  207. data/spec/factories/automobile_make_model_year.rb +9 -0
  208. data/spec/factories/automobile_model.rb +9 -0
  209. data/spec/factories/automobile_type_fuel.rb +7 -0
  210. data/spec/factories/automobile_type_fuel_control.rb +16 -0
  211. data/spec/factories/automobile_type_fuel_year.rb +9 -0
  212. data/spec/factories/automobile_type_fuel_year_control.rb +11 -0
  213. data/spec/factories/bus_fuel.rb +7 -0
  214. data/spec/factories/bus_fuel_year_control.rb +9 -0
  215. data/spec/factories/cbecs_energy_intensity.rb +15 -0
  216. data/spec/factories/commercial_building_energy_consumption_survey_response.rb +10 -0
  217. data/spec/factories/electric_utility.rb +8 -0
  218. data/spec/factories/flight_distance_class.rb +8 -0
  219. data/spec/factories/flight_segment.rb +0 -1
  220. data/spec/factories/food_group.rb +8 -0
  221. data/spec/factories/fuel.rb +8 -0
  222. data/spec/factories/fuel_year.rb +8 -0
  223. data/spec/factories/green_button_adoption.rb +8 -0
  224. data/spec/factories/greenhouse_gas.rb +7 -0
  225. data/spec/factories/industry.rb +9 -0
  226. data/spec/factories/mecs_energy.rb +15 -0
  227. data/spec/factories/mecs_ratio.rb +15 -0
  228. data/spec/factories/national_transit_database_company.rb +8 -0
  229. data/spec/factories/national_transit_database_mode.rb +8 -0
  230. data/spec/factories/national_transit_database_record.rb +9 -0
  231. data/spec/factories/residence_appliance.rb +7 -0
  232. data/spec/factories/zip_code.rb +9 -0
  233. data/spec/spec_helper.rb +36 -19
  234. metadata +346 -66
  235. data/lib/earth/acronyms.rb +0 -12
  236. data/lib/earth/rail/rail_company_traction.rb +0 -24
  237. data/lib/earth/rail/rail_company_traction/data_miner.rb +0 -4
  238. data/lib/earth/rail/rail_company_traction_class.rb +0 -26
  239. data/lib/earth/rail/rail_company_traction_class/data_miner.rb +0 -4
@@ -2,30 +2,21 @@ require 'spec_helper'
2
2
  require 'earth/industry/naics_2002_naics_2007_concordance'
3
3
 
4
4
  describe Naics2002Naics2007Concordance do
5
- describe 'verify imported data', :sanity => true do
6
- it "extracts a note from a description" do
7
- Naics2002Naics2007Concordance.extract_note("Internet Service Providers - Internet services providers providing services via client-supplied telecommunications connection").
5
+ let(:n2n) { Naics2002Naics2007Concordance }
6
+
7
+ describe '.extract_note(description)' do
8
+ it "extracts a paranthetical note from a description" do
9
+ n2n.extract_note("Internet Service Providers - Internet services providers providing services via client-supplied telecommunications connection").
8
10
  should == "Internet services providers providing services via client-supplied telecommunications connection"
9
11
  end
10
- it 'should have all the data' do
11
- Naics2002Naics2007Concordance.count.should == 1200
12
- end
13
12
  end
14
13
 
15
- describe "relationships" do
16
- before do
17
- require 'earth/industry/naics_2002'
18
- require 'earth/industry/naics_2007'
19
- end
20
-
21
- it "belongs to :naics_2002" do
22
- Naics2002Naics2007Concordance.find_by_naics_2002_code("111219").
23
- naics_2002.should == Naics2002.find("111219")
14
+ describe 'Sanity check', :sanity => true do
15
+ it 'should have all the data' do
16
+ n2n.count.should == 1200
24
17
  end
25
18
 
26
- it "belongs to :naics_2007" do
27
- Naics2002Naics2007Concordance.find_by_naics_2007_code("111211").
28
- naics_2007.should == Naics2007.find("111211")
29
- end
19
+ # spot check
20
+ it { n2n.where(:naics_2002_code => '111219').map(&:naics_2007_code).should == ['111219', '111211'] }
30
21
  end
31
22
  end
@@ -2,31 +2,21 @@ require 'spec_helper'
2
2
  require 'earth/industry/naics_2002_sic_1987_concordance'
3
3
 
4
4
  describe Naics2002Sic1987Concordance do
5
- describe 'verify imported data', :sanity => true do
6
- it 'should have all the data' do
7
- Naics2002Sic1987Concordance.count.should == 2164
8
- end
9
-
5
+ let(:n2s) { Naics2002Sic1987Concordance }
6
+
7
+ describe '.extract_note(description)' do
10
8
  it "extracts a paranthetical note from a description" do
11
- Naics2002Sic1987Concordance.extract_note("Wood Household Furniture, Except Upholstered (wood box spring frames(parts))").
9
+ n2s.extract_note("Wood Household Furniture, Except Upholstered (wood box spring frames(parts))").
12
10
  should == "wood box spring frames(parts)"
13
11
  end
14
12
  end
15
13
 
16
- describe "relationships" do
17
- before do
18
- require 'earth/industry/naics_2002'
19
- require 'earth/industry/sic_1987'
20
- end
21
-
22
- it "belongs to :naics_2002" do
23
- Naics2002Sic1987Concordance.find_by_naics_2002_code("111150").
24
- naics_2002.should == Naics2002.find("111150")
14
+ describe 'Sanity check', :sanity => true do
15
+ it 'should have all the data' do
16
+ n2s.count.should == 2164
25
17
  end
26
18
 
27
- it "belongs to :sic_1987" do
28
- Naics2002Sic1987Concordance.find_by_sic_1987_code("0119").
29
- sic_1987.should == Sic1987.find("0119")
30
- end
19
+ # spot check
20
+ it { n2s.where(:naics_2002_code => '111150').map(&:sic_1987_code).should == ['0119', '0115'] }
31
21
  end
32
22
  end
@@ -2,20 +2,10 @@ require 'spec_helper'
2
2
  require 'earth/industry/naics_2002'
3
3
 
4
4
  describe Naics2002 do
5
- describe "verify imported data", :sanity => true do
5
+ describe "Sanity check", :sanity => true do
6
6
  it "should have all the data" do
7
7
  Naics2002.count.should == 2341
8
8
  end
9
- end
10
-
11
- describe "code translations" do
12
- before do
13
- require 'earth/industry/sic_1987'
14
- require 'earth/industry/naics_2002_sic_1987_concordance'
15
- require 'earth/industry/naics_2007'
16
- require 'earth/industry/naics_2002_naics_2007_concordance'
17
- require 'earth/industry/industry'
18
- end
19
9
 
20
10
  it "can be translated to a SIC 1987 code" do
21
11
  {
@@ -2,17 +2,8 @@ require 'spec_helper'
2
2
  require 'earth/industry/naics_2007'
3
3
 
4
4
  describe Naics2007 do
5
- describe 'verify imported data', :sanity => true do
6
- it 'should have all the data' do
7
- Naics2007.count.should == 2328
8
- end
9
- end
10
-
11
- describe "code translations" do
12
- before do
13
- require 'earth/industry/naics_2002'
14
- require 'earth/industry/naics_2002_naics_2007_concordance'
15
- end
5
+ describe 'Sanity check', :sanity => true do
6
+ it { Naics2007.count.should == 2328 }
16
7
 
17
8
  it "can be translated to a NAICS 2002 code" do
18
9
  {
@@ -2,20 +2,9 @@ require 'spec_helper'
2
2
  require 'earth/industry/sic_1987'
3
3
 
4
4
  describe Sic1987 do
5
- describe "verify imported data", :sanity => true do
6
- it "should have all the data" do
7
- Sic1987.count.should == 1004
8
- end
9
- it "has a description for every code" do
10
- Sic1987.find_by_description(nil).should be_nil
11
- end
12
- end
13
-
14
- describe "code translations" do
15
- before do
16
- require 'earth/industry/naics_2002'
17
- require 'earth/industry/naics_2002_sic_1987_concordance'
18
- end
5
+ describe "Sanity check", :sanity => true do
6
+ it { Sic1987.count.should == 1004 }
7
+ it { Sic1987.where(:description => nil).count.should == 0 }
19
8
 
20
9
  it "can be translated to a NAICS 2002 code" do
21
10
  {
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+ require 'earth/locality/census_division'
3
+
4
+ describe CensusDivision do
5
+ describe 'Sanity check', :sanity => true do
6
+ it { CensusDivision.count.should == 9 }
7
+
8
+ # spot check
9
+ let(:pacific) { CensusDivision.find 9 }
10
+ it { pacific.meeting_building_natural_gas_intensity.should be_within(5e-6).of(0.00179) }
11
+ it { pacific.meeting_building_fuel_oil_intensity.should be_within(5e-10).of(0.000000012) }
12
+ it { pacific.meeting_building_electricity_intensity.should be_within(5e-6).of(0.04644) }
13
+ it { pacific.meeting_building_district_heat_intensity.should be_within(5e-6).of(0) }
14
+
15
+ describe '.fallback' do
16
+ let(:fallback) { CensusDivision.fallback }
17
+
18
+ it { fallback.name.should == 'fallback' }
19
+ it { fallback.meeting_building_natural_gas_intensity.should be_within(5e-6).of(0.01327) }
20
+ it { fallback.meeting_building_fuel_oil_intensity.should be_within(5e-6).of(0.00377) }
21
+ it { fallback.meeting_building_electricity_intensity.should be_within(5e-6).of(0.09077) }
22
+ it { fallback.meeting_building_district_heat_intensity.should be_within(5e-6).of(0.00542) }
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+ require 'earth/locality/census_region'
3
+
4
+ describe CensusRegion do
5
+ describe 'Sanity check', :sanity => true do
6
+ it { CensusRegion.count.should == 4 }
7
+ end
8
+ end
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+ require 'earth/locality/climate_division'
3
+
4
+ describe ClimateDivision do
5
+ describe 'Sanity check', :sanity => true do
6
+ let(:total) { ClimateDivision.count }
7
+
8
+ it { total.should == 359 }
9
+ it { ClimateDivision.where('heating_degree_days > 0').count.should == total }
10
+ it { ClimateDivision.where('cooling_degree_days >= 0 ').count.should == total }
11
+ it { ClimateDivision.where(:state_postal_abbreviation => nil).count.should == 0 }
12
+ end
13
+ end
@@ -4,11 +4,18 @@ require 'spec_helper'
4
4
  require 'earth/locality/country'
5
5
 
6
6
  describe Country do
7
- describe 'verify imported data', :sanity => true do
7
+ describe '.united_states' do
8
+ it 'should return the United States' do
9
+ us = Country.find_or_create_by_iso_3166_code 'US'
10
+ Country.united_states.should == us
11
+ end
12
+ end
13
+
14
+ describe 'Sanity check', :sanity => true do
8
15
  let(:us) { Country.united_states }
9
16
  let(:uk) { Country.find 'GB' }
10
17
 
11
- it { Country.count.should == 249 }
18
+ it { Country.count.should == 250 }
12
19
 
13
20
  describe 'uses UTF-8 encoding' do
14
21
  it { Country.find('AX').name.should == "Åland Islands" }
@@ -83,27 +90,21 @@ describe Country do
83
90
  it { uk.rail_trip_diesel_intensity.should be_within(5e-5).of(0.0028) }
84
91
  it { uk.rail_trip_co2_emission_factor.should be_within(5e-5).of(0.0458) }
85
92
  end
86
- end
87
-
88
- describe '.united_states' do
89
- it 'should return the United States' do
90
- Country.united_states.should == Country.find('US')
91
- end
92
- end
93
-
94
- describe '.fallback' do
95
- let(:fallback) { Country.fallback }
96
93
 
97
- it { fallback.name.should == 'fallback' }
98
- it { fallback.electricity_emission_factor.should be_within(5e-6).of(0.62609) }
99
- it { fallback.electricity_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour' }
100
- it { fallback.electricity_co2_emission_factor.should be_within(5e-6).of(0.62354) }
101
- it { fallback.electricity_co2_emission_factor_units.should == 'kilograms_per_kilowatt_hour' }
102
- it { fallback.electricity_ch4_emission_factor.should be_within(5e-6).of(0.00021) }
103
- it { fallback.electricity_ch4_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour' }
104
- it { fallback.electricity_n2o_emission_factor.should be_within(5e-6).of(0.00234) }
105
- it { fallback.electricity_n2o_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour' }
106
- it { fallback.electricity_loss_factor.should be_within(5e-4).of(0.096) }
107
- it { fallback.electricity_mix.should == ElectricityMix.fallback }
94
+ describe '.fallback' do
95
+ let(:fallback) { Country.fallback }
96
+
97
+ it { fallback.name.should == 'fallback' }
98
+ it { fallback.electricity_emission_factor.should be_within(5e-6).of(0.62609) }
99
+ it { fallback.electricity_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour' }
100
+ it { fallback.electricity_co2_emission_factor.should be_within(5e-6).of(0.62354) }
101
+ it { fallback.electricity_co2_emission_factor_units.should == 'kilograms_per_kilowatt_hour' }
102
+ it { fallback.electricity_ch4_emission_factor.should be_within(5e-6).of(0.00021) }
103
+ it { fallback.electricity_ch4_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour' }
104
+ it { fallback.electricity_n2o_emission_factor.should be_within(5e-6).of(0.00234) }
105
+ it { fallback.electricity_n2o_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour' }
106
+ it { fallback.electricity_loss_factor.should be_within(5e-4).of(0.096) }
107
+ it { fallback.electricity_mix.should == ElectricityMix.fallback }
108
+ end
108
109
  end
109
110
  end
@@ -2,14 +2,15 @@ require 'spec_helper'
2
2
  require 'earth/locality/egrid_country'
3
3
 
4
4
  describe EgridCountry do
5
- describe 'verify imported data', :sanity => true do
6
- it { EgridCountry.count.should == 1 }
7
- it { EgridCountry.us.loss_factor.should be_within(5e-6).of(0.06503) }
8
- end
9
-
10
5
  describe '.us' do
11
6
  it 'should return the US' do
12
- EgridCountry.us.should == EgridCountry.find('U.S.')
7
+ us = EgridCountry.find_or_create_by_name 'U.S.'
8
+ EgridCountry.us.should == us
13
9
  end
14
10
  end
11
+
12
+ describe 'Sanity check', :sanity => true do
13
+ it { EgridCountry.count.should == 1 }
14
+ it { EgridCountry.us.loss_factor.should be_within(5e-6).of(0.06503) }
15
+ end
15
16
  end
@@ -2,16 +2,16 @@ require 'spec_helper'
2
2
  require 'earth/locality/egrid_region'
3
3
 
4
4
  describe EgridRegion do
5
- describe 'verify imported data', :sanity => true do
5
+ describe 'Sanity check', :sanity => true do
6
6
  it { EgridRegion.count.should == 5 }
7
7
  it { EgridRegion.where("loss_factor > 0").count.should == EgridRegion.count }
8
8
 
9
9
  # spot check
10
10
  it { EgridRegion.first.loss_factor.should be_within(5e-6).of(0.05840) }
11
- end
12
-
13
- describe '.fallback' do
14
- it { EgridRegion.fallback.name.should == 'fallback' }
15
- it { EgridRegion.fallback.loss_factor.should be_within(5e-6).of(0.06503) }
11
+
12
+ describe '.fallback' do
13
+ it { EgridRegion.fallback.name.should == 'fallback' }
14
+ it { EgridRegion.fallback.loss_factor.should be_within(5e-6).of(0.06503) }
15
+ end
16
16
  end
17
17
  end
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
  require 'earth/locality/egrid_subregion'
3
3
 
4
4
  describe EgridSubregion do
5
- describe 'verify imported data', :sanity => true do
5
+ describe 'Sanity check', :sanity => true do
6
6
  let(:total) { EgridSubregion.count }
7
7
  let(:akgd) { EgridSubregion.find 'akgd' }
8
8
 
@@ -34,19 +34,19 @@ describe EgridSubregion do
34
34
 
35
35
  # DEPRECATED
36
36
  it { akgd.electricity_emission_factor_units.should == 'kilograms_co2e_per_kilowatt_hour' }
37
- end
38
-
39
- describe '.fallback' do
40
- let(:fallback) { EgridSubregion.fallback }
41
-
42
- it { fallback.name.should == 'fallback' }
43
- it { fallback.egrid_region.name.should == 'fallback' }
44
- it { fallback.co2_emission_factor.should be_within(5e-6).of(0.55165) }
45
- it { fallback.co2_biogenic_emission_factor.should == nil }
46
- it { fallback.ch4_emission_factor.should be_within(5e-6).of(0.00027) }
47
- it { fallback.n2o_emission_factor.should be_within(5e-6).of(0.00244) }
48
37
 
49
- # DEPRECATED
50
- it { fallback.electricity_emission_factor.should be_within(5e-6).of(0.55437) }
38
+ describe '.fallback' do
39
+ let(:fallback) { EgridSubregion.fallback }
40
+
41
+ it { fallback.name.should == 'fallback' }
42
+ it { fallback.egrid_region.name.should == 'fallback' }
43
+ it { fallback.co2_emission_factor.should be_within(5e-6).of(0.55165) }
44
+ it { fallback.co2_biogenic_emission_factor.should == nil }
45
+ it { fallback.ch4_emission_factor.should be_within(5e-6).of(0.00027) }
46
+ it { fallback.n2o_emission_factor.should be_within(5e-6).of(0.00244) }
47
+
48
+ # DEPRECATED
49
+ it { fallback.electricity_emission_factor.should be_within(5e-6).of(0.55437) }
50
+ end
51
51
  end
52
52
  end
@@ -2,7 +2,15 @@ require 'spec_helper'
2
2
  require 'earth/locality/electricity_mix'
3
3
 
4
4
  describe ElectricityMix do
5
- describe 'verify imported data', :sanity => true do
5
+ describe '#energy_content' do
6
+ it { ElectricityMix.new.energy_content.should be_within(5e-6).of(3.6) }
7
+ end
8
+
9
+ describe '#energy_content_units' do
10
+ it { ElectricityMix.new.energy_content_units.should == 'megajoules_per_kilowatt_hour' }
11
+ end
12
+
13
+ describe 'Sanity check', :sanity => true do
6
14
  let(:total) { ElectricityMix.count }
7
15
  let(:uk) { ElectricityMix.find_by_country_iso_3166_code 'GB' }
8
16
  let(:akgd) { ElectricityMix.find_by_egrid_subregion_abbreviation 'akgd' }
@@ -40,21 +48,13 @@ describe ElectricityMix do
40
48
  it { ca.ch4_emission_factor.should be_within(5e-6).of(0.00033) }
41
49
  it { ca.n2o_emission_factor.should be_within(5e-6).of(0.00085) }
42
50
  it { ca.loss_factor.should be_within(5e-6).of(0.08208) }
43
- end
44
-
45
- describe '.fallback' do
46
- it { ElectricityMix.fallback.name.should == 'fallback' }
47
- it { ElectricityMix.fallback.co2_emission_factor.should be_within(5e-6).of(0.62354) }
48
- it { ElectricityMix.fallback.ch4_emission_factor.should be_within(5e-6).of(0.00021) }
49
- it { ElectricityMix.fallback.n2o_emission_factor.should be_within(5e-6).of(0.00234) }
50
- it { ElectricityMix.fallback.loss_factor.should be_within(5e-6).of(0.096) }
51
- end
52
-
53
- describe '#energy_content' do
54
- it { ElectricityMix.first.energy_content.should be_within(5e-6).of(3.6) }
55
- end
56
-
57
- describe '#energy_content_units' do
58
- it { ElectricityMix.first.energy_content_units.should == 'megajoules_per_kilowatt_hour' }
51
+
52
+ describe '.fallback' do
53
+ it { ElectricityMix.fallback.name.should == 'fallback' }
54
+ it { ElectricityMix.fallback.co2_emission_factor.should be_within(5e-6).of(0.62354) }
55
+ it { ElectricityMix.fallback.ch4_emission_factor.should be_within(5e-6).of(0.00021) }
56
+ it { ElectricityMix.fallback.n2o_emission_factor.should be_within(5e-6).of(0.00234) }
57
+ it { ElectricityMix.fallback.loss_factor.should be_within(5e-6).of(0.096) }
58
+ end
59
59
  end
60
60
  end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+ require 'earth/locality/petroleum_administration_for_defense_district'
3
+
4
+ describe PetroleumAdministrationForDefenseDistrict do
5
+ let(:padd) { PetroleumAdministrationForDefenseDistrict }
6
+
7
+ describe '#name' do
8
+ it 'describes a PADD that is a district' do
9
+ test = padd.new(:district_code => 1, :district_name => 'East Coast')
10
+ test.name.should == 'PAD District 1 (East Coast)'
11
+ end
12
+ it 'describes a PADD that is a subdistric' do
13
+ test = padd.new(:district_code => 1, :district_name => 'East Coast', :subdistrict_code => 'A', :subdistrict_name => 'New England')
14
+ test.name.should == 'PAD District 1 (East Coast) Subdistrict 1A (New England)'
15
+ end
16
+ end
17
+
18
+ describe 'Sanity check', :sanity => true do
19
+ it { padd.count.should == 7 }
20
+ end
21
+ end
@@ -2,7 +2,14 @@ require 'spec_helper'
2
2
  require 'earth/locality/state'
3
3
 
4
4
  describe State do
5
- describe 'verify imported data', :sanity => true do
5
+ describe '#country' do
6
+ it 'should return the United States' do
7
+ us = Country.find_or_create_by_iso_3166_code 'US'
8
+ State.new.country.should == us
9
+ end
10
+ end
11
+
12
+ describe 'Sanity check', :sanity => true do
6
13
  it 'should have all the data' do
7
14
  State.count.should == 51 # includes DC but not any territories
8
15
  end
@@ -31,14 +38,4 @@ describe State do
31
38
  State.find('NM').electricity_loss_factor.should be_within(5e-6).of(0.08007)
32
39
  end
33
40
  end
34
-
35
- describe '#country' do
36
- before do
37
- require 'earth/locality/country'
38
- end
39
-
40
- it 'should return the United States' do
41
- State.first.country.should == Country.united_states
42
- end
43
- end
44
41
  end