earth 0.5.4 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/Gemfile +1 -0
  2. data/TODO +2 -0
  3. data/bin/earth_tester.rb +62 -9
  4. data/earth.gemspec +7 -4
  5. data/lib/earth.rb +18 -17
  6. data/lib/earth/air.rb +2 -0
  7. data/lib/earth/air/aircraft.rb +76 -19
  8. data/lib/earth/air/aircraft/data_miner.rb +1 -63
  9. data/lib/earth/air/aircraft_class.rb +48 -12
  10. data/lib/earth/air/aircraft_class/data_miner.rb +3 -46
  11. data/lib/earth/air/aircraft_fuel_use_equation.rb +11 -13
  12. data/lib/earth/air/aircraft_instance.rb +9 -0
  13. data/lib/earth/air/aircraft_instance_seat_class.rb +12 -0
  14. data/lib/earth/air/airline.rb +6 -8
  15. data/lib/earth/air/airline/data_miner.rb +3 -3
  16. data/lib/earth/air/airport.rb +8 -10
  17. data/lib/earth/air/airport/data_miner.rb +1 -1
  18. data/lib/earth/air/bts_aircraft.rb +3 -5
  19. data/lib/earth/air/flight_distance_class.rb +4 -6
  20. data/lib/earth/air/flight_seat_class.rb +5 -7
  21. data/lib/earth/air/flight_segment.rb +58 -42
  22. data/lib/earth/air/flight_segment/data_miner.rb +11 -26
  23. data/lib/earth/automobile.rb +1 -0
  24. data/lib/earth/automobile/automobile_fuel.rb +78 -25
  25. data/lib/earth/automobile/automobile_fuel/data_miner.rb +5 -72
  26. data/lib/earth/automobile/automobile_make.rb +14 -6
  27. data/lib/earth/automobile/automobile_make/data_miner.rb +20 -35
  28. data/lib/earth/automobile/automobile_make_fleet_year.rb +39 -10
  29. data/lib/earth/automobile/automobile_make_fleet_year/data_miner.rb +0 -29
  30. data/lib/earth/automobile/automobile_make_model.rb +30 -9
  31. data/lib/earth/automobile/automobile_make_model/data_miner.rb +11 -26
  32. data/lib/earth/automobile/automobile_make_model_year.rb +41 -12
  33. data/lib/earth/automobile/automobile_make_model_year/data_miner.rb +14 -34
  34. data/lib/earth/automobile/automobile_make_model_year_variant.rb +56 -38
  35. data/lib/earth/automobile/automobile_make_model_year_variant/data_miner.rb +15 -61
  36. data/lib/earth/automobile/automobile_make_year.rb +15 -8
  37. data/lib/earth/automobile/automobile_make_year/data_miner.rb +17 -51
  38. data/lib/earth/automobile/automobile_size_class.rb +78 -14
  39. data/lib/earth/automobile/automobile_size_class/data_miner.rb +0 -66
  40. data/lib/earth/automobile/automobile_size_class_year.rb +38 -10
  41. data/lib/earth/automobile/automobile_size_class_year/data_miner.rb +0 -30
  42. data/lib/earth/automobile/automobile_type_fuel_age.rb +60 -11
  43. data/lib/earth/automobile/automobile_type_fuel_age/data_miner.rb +10 -65
  44. data/lib/earth/automobile/automobile_type_fuel_control.rb +41 -10
  45. data/lib/earth/automobile/automobile_type_fuel_control/data_miner.rb +0 -33
  46. data/lib/earth/automobile/automobile_type_fuel_year.rb +60 -15
  47. data/lib/earth/automobile/automobile_type_fuel_year/data_miner.rb +1 -52
  48. data/lib/earth/automobile/automobile_type_fuel_year_age.rb +64 -12
  49. data/lib/earth/automobile/automobile_type_fuel_year_age/data_miner.rb +1 -59
  50. data/lib/earth/automobile/automobile_type_fuel_year_control.rb +31 -10
  51. data/lib/earth/automobile/automobile_type_fuel_year_control/data_miner.rb +2 -32
  52. data/lib/earth/automobile/automobile_type_year.rb +51 -10
  53. data/lib/earth/automobile/automobile_type_year/data_miner.rb +1 -43
  54. data/lib/earth/automobile/data_miner.rb +1 -0
  55. data/lib/earth/bus/bus_class.rb +108 -28
  56. data/lib/earth/bus/bus_class/data_miner.rb +0 -88
  57. data/lib/earth/bus/bus_fuel.rb +83 -15
  58. data/lib/earth/bus/bus_fuel/data_miner.rb +0 -76
  59. data/lib/earth/bus/bus_fuel_control.rb +8 -10
  60. data/lib/earth/bus/bus_fuel_year_control.rb +7 -9
  61. data/lib/earth/bus/bus_fuel_year_control/data_miner.rb +1 -5
  62. data/lib/earth/computation/computation_carrier.rb +11 -5
  63. data/lib/earth/computation/computation_carrier/data_miner.rb +0 -7
  64. data/lib/earth/computation/computation_carrier_instance_class.rb +25 -8
  65. data/lib/earth/computation/computation_carrier_instance_class/data_miner.rb +0 -18
  66. data/lib/earth/computation/computation_carrier_region.rb +5 -7
  67. data/lib/earth/diet/diet_class.rb +14 -16
  68. data/lib/earth/diet/food_group.rb +7 -9
  69. data/lib/earth/fuel/fuel.rb +14 -16
  70. data/lib/earth/fuel/fuel/data_miner.rb +7 -3
  71. data/lib/earth/fuel/fuel_price.rb +4 -6
  72. data/lib/earth/fuel/fuel_type.rb +12 -14
  73. data/lib/earth/fuel/fuel_year.rb +57 -16
  74. data/lib/earth/fuel/fuel_year/data_miner.rb +0 -43
  75. data/lib/earth/fuel/greenhouse_gas.rb +46 -9
  76. data/lib/earth/fuel/greenhouse_gas/data_miner.rb +0 -38
  77. data/lib/earth/hospitality/lodging_class.rb +10 -12
  78. data/lib/earth/industry/industry.rb +3 -5
  79. data/lib/earth/industry/industry_product.rb +6 -8
  80. data/lib/earth/industry/industry_product_line.rb +5 -7
  81. data/lib/earth/industry/industry_sector.rb +5 -7
  82. data/lib/earth/industry/merchant.rb +4 -6
  83. data/lib/earth/industry/merchant_category.rb +3 -5
  84. data/lib/earth/industry/merchant_category_industry.rb +5 -7
  85. data/lib/earth/industry/product_line.rb +5 -7
  86. data/lib/earth/industry/product_line_industry_product.rb +5 -7
  87. data/lib/earth/industry/sector.rb +5 -7
  88. data/lib/earth/locality/census_division.rb +21 -23
  89. data/lib/earth/locality/census_region.rb +3 -5
  90. data/lib/earth/locality/climate_division.rb +5 -7
  91. data/lib/earth/locality/country.rb +13 -15
  92. data/lib/earth/locality/egrid_region.rb +14 -5
  93. data/lib/earth/locality/egrid_region/data_miner.rb +0 -10
  94. data/lib/earth/locality/egrid_subregion.rb +71 -18
  95. data/lib/earth/locality/egrid_subregion/data_miner.rb +0 -59
  96. data/lib/earth/locality/petroleum_administration_for_defense_district.rb +6 -8
  97. data/lib/earth/locality/state.rb +6 -8
  98. data/lib/earth/locality/urbanity.rb +2 -4
  99. data/lib/earth/locality/urbanity/data_miner.rb +7 -3
  100. data/lib/earth/locality/zip_code.rb +8 -10
  101. data/lib/earth/pet/breed.rb +5 -7
  102. data/lib/earth/pet/breed_gender.rb +6 -8
  103. data/lib/earth/pet/gender.rb +2 -4
  104. data/lib/earth/pet/species.rb +15 -17
  105. data/lib/earth/rail/rail_class.rb +64 -14
  106. data/lib/earth/rail/rail_class/data_miner.rb +0 -51
  107. data/lib/earth/residence/air_conditioner_use.rb +4 -6
  108. data/lib/earth/residence/air_conditioner_use/data_miner.rb +7 -3
  109. data/lib/earth/residence/clothes_machine_use.rb +4 -6
  110. data/lib/earth/residence/clothes_machine_use/data_miner.rb +11 -9
  111. data/lib/earth/residence/dishwasher_use.rb +4 -6
  112. data/lib/earth/residence/dishwasher_use/data_miner.rb +11 -9
  113. data/lib/earth/residence/residence_appliance.rb +4 -6
  114. data/lib/earth/residence/residence_class.rb +2 -4
  115. data/lib/earth/residence/residence_class/data_miner.rb +7 -3
  116. data/lib/earth/residence/residence_fuel_price.rb +12 -14
  117. data/lib/earth/residence/residence_fuel_price/data_miner.rb +7 -0
  118. data/lib/earth/residence/residence_fuel_type.rb +6 -8
  119. data/lib/earth/residence/residential_energy_consumption_survey_response.rb +91 -93
  120. data/lib/earth/residence/residential_energy_consumption_survey_response/data_miner.rb +9 -8
  121. data/lib/earth/shipping/carrier.rb +57 -10
  122. data/lib/earth/shipping/carrier/data_miner.rb +0 -48
  123. data/lib/earth/shipping/carrier_mode.rb +41 -10
  124. data/lib/earth/shipping/carrier_mode/data_miner.rb +0 -33
  125. data/lib/earth/shipping/shipment_mode.rb +30 -7
  126. data/lib/earth/shipping/shipment_mode/data_miner.rb +0 -23
  127. data/lib/earth/utils.rb +45 -0
  128. data/lib/earth/version.rb +1 -1
  129. data/spec/earth/air/aircraft_spec.rb +1 -1
  130. data/vendor/clean_find_in_batches/init.rb +35 -0
  131. metadata +74 -47
@@ -3,9 +3,7 @@ class Merchant < ActiveRecord::Base
3
3
 
4
4
  belongs_to :merchant_category, :foreign_key => 'mcc'
5
5
 
6
- force_schema do
7
- string 'id'
8
- string 'name'
9
- string 'mcc'
10
- end
11
- end
6
+ col :id
7
+ col :name
8
+ col :mcc
9
+ end
@@ -8,8 +8,6 @@ class MerchantCategory < ActiveRecord::Base
8
8
  description
9
9
  end
10
10
 
11
- force_schema do
12
- string 'mcc'
13
- string 'description'
14
- end
15
- end
11
+ col :mcc
12
+ col :description
13
+ end
@@ -4,10 +4,8 @@ class MerchantCategoryIndustry < ActiveRecord::Base
4
4
  belongs_to :merchant_category, :foreign_key => 'mcc'
5
5
  belongs_to :industry, :foreign_key => 'naics_code'
6
6
 
7
- force_schema do
8
- string 'row_hash'
9
- string 'mcc'
10
- float 'ratio'
11
- string 'naics_code'
12
- end
13
- end
7
+ col :row_hash
8
+ col :mcc
9
+ col :ratio, :type => :float
10
+ col :naics_code
11
+ end
@@ -6,10 +6,8 @@ class ProductLine < ActiveRecord::Base
6
6
  has_many :product_line_industry_products, :foreign_key => 'ps_code'
7
7
  has_many :industry_products, :through => :product_line_industry_products
8
8
 
9
- force_schema do
10
- string 'ps_code'
11
- string 'description'
12
- string 'broadline' # FIXME TODO do we need this?
13
- string 'parent' # FIXME TODO do we need this?
14
- end
15
- end
9
+ col :ps_code
10
+ col :description
11
+ col :broadline # FIXME TODO do we need this?
12
+ col :parent # FIXME TODO do we need this?
13
+ end
@@ -4,10 +4,8 @@ class ProductLineIndustryProduct < ActiveRecord::Base
4
4
  belongs_to :product_line, :foreign_key => 'ps_code'
5
5
  belongs_to :industry_product, :foreign_key => 'naics_product_code'
6
6
 
7
- force_schema do
8
- string 'row_hash'
9
- string 'ps_code'
10
- float 'ratio'
11
- string 'naics_product_code'
12
- end
13
- end
7
+ col :row_hash
8
+ col :ps_code
9
+ col :ratio, :type => :float
10
+ col :naics_product_code
11
+ end
@@ -3,10 +3,8 @@ class Sector < ActiveRecord::Base
3
3
 
4
4
  has_many :industry_sectors, :foreign_key => 'io_code'
5
5
 
6
- force_schema do
7
- string 'io_code'
8
- string 'description'
9
- float 'value'
10
- string 'value_units'
11
- end
12
- end
6
+ col :io_code
7
+ col :description
8
+ col :value, :type => :float
9
+ col :value_units
10
+ end
@@ -13,26 +13,24 @@ class CensusDivision < ActiveRecord::Base
13
13
  :meeting_building_electricity_intensity => 0.0084323684 / 1.square_feet.to(:square_metres),
14
14
  :meeting_building_district_heat_intensity => 0.0004776370.kbtus.to(:megajoules) / 1.square_feet.to(:square_metres)
15
15
 
16
- force_schema do
17
- integer 'number'
18
- string 'name'
19
- string 'census_region_name'
20
- integer 'census_region_number'
21
- float 'meeting_building_natural_gas_intensity'
22
- string 'meeting_building_natural_gas_intensity_units'
23
- float 'meeting_building_fuel_oil_intensity'
24
- string 'meeting_building_fuel_oil_intensity_units'
25
- float 'meeting_building_electricity_intensity'
26
- string 'meeting_building_electricity_intensity_units'
27
- float 'meeting_building_district_heat_intensity'
28
- string 'meeting_building_district_heat_intensity_units'
29
- float 'lodging_building_natural_gas_intensity'
30
- string 'lodging_building_natural_gas_intensity_units'
31
- float 'lodging_building_fuel_oil_intensity'
32
- string 'lodging_building_fuel_oil_intensity_units'
33
- float 'lodging_building_electricity_intensity'
34
- string 'lodging_building_electricity_intensity_units'
35
- float 'lodging_building_district_heat_intensity'
36
- string 'lodging_building_district_heat_intensity_units'
37
- end
38
- end
16
+ col :number, :type => :integer
17
+ col :name
18
+ col :census_region_name
19
+ col :census_region_number, :type => :integer
20
+ col :meeting_building_natural_gas_intensity, :type => :float
21
+ col :meeting_building_natural_gas_intensity_units
22
+ col :meeting_building_fuel_oil_intensity, :type => :float
23
+ col :meeting_building_fuel_oil_intensity_units
24
+ col :meeting_building_electricity_intensity, :type => :float
25
+ col :meeting_building_electricity_intensity_units
26
+ col :meeting_building_district_heat_intensity, :type => :float
27
+ col :meeting_building_district_heat_intensity_units
28
+ col :lodging_building_natural_gas_intensity, :type => :float
29
+ col :lodging_building_natural_gas_intensity_units
30
+ col :lodging_building_fuel_oil_intensity, :type => :float
31
+ col :lodging_building_fuel_oil_intensity_units
32
+ col :lodging_building_electricity_intensity, :type => :float
33
+ col :lodging_building_electricity_intensity_units
34
+ col :lodging_building_district_heat_intensity, :type => :float
35
+ col :lodging_building_district_heat_intensity_units
36
+ end
@@ -7,8 +7,6 @@ class CensusRegion < ActiveRecord::Base
7
7
  # has_many :zip_codes, :through => :census_divisions
8
8
  has_many :residential_energy_consumption_survey_responses, :foreign_key => 'census_region_number'
9
9
 
10
- force_schema do
11
- integer 'number'
12
- string 'name'
13
- end
14
- end
10
+ col :number, :type => :integer
11
+ col :name
12
+ end
@@ -6,10 +6,8 @@ class ClimateDivision < ActiveRecord::Base
6
6
 
7
7
  RADIUS = 750
8
8
 
9
- force_schema do
10
- string 'name'
11
- float 'heating_degree_days'
12
- float 'cooling_degree_days'
13
- string 'state_postal_abbreviation'
14
- end
15
- end
9
+ col :name
10
+ col :heating_degree_days, :type => :float
11
+ col :cooling_degree_days, :type => :float
12
+ col :state_postal_abbreviation
13
+ end
@@ -19,18 +19,16 @@ class Country < ActiveRecord::Base
19
19
  end
20
20
  end
21
21
 
22
- force_schema do
23
- string 'iso_3166_code'
24
- string 'name'
25
- float 'automobile_urbanity'
26
- float 'automobile_fuel_efficiency'
27
- string 'automobile_fuel_efficiency_units'
28
- float 'automobile_city_speed'
29
- string 'automobile_city_speed_units'
30
- float 'automobile_highway_speed'
31
- string 'automobile_highway_speed_units'
32
- float 'automobile_trip_distance'
33
- string 'automobile_trip_distance_units'
34
- float 'flight_route_inefficiency_factor'
35
- end
36
- end
22
+ col :iso_3166_code
23
+ col :name
24
+ col :automobile_urbanity, :type => :float
25
+ col :automobile_fuel_efficiency, :type => :float
26
+ col :automobile_fuel_efficiency_units
27
+ col :automobile_city_speed, :type => :float
28
+ col :automobile_city_speed_units
29
+ col :automobile_highway_speed, :type => :float
30
+ col :automobile_highway_speed_units
31
+ col :automobile_trip_distance, :type => :float
32
+ col :automobile_trip_distance_units
33
+ col :flight_route_inefficiency_factor, :type => :float
34
+ end
@@ -7,8 +7,17 @@ class EgridRegion < ActiveRecord::Base
7
7
  falls_back_on :name => 'fallback',
8
8
  :loss_factor => 0.061879 # calculated using above formula 2/21/2011
9
9
 
10
- force_schema do
11
- string 'name'
12
- float 'loss_factor'
13
- end
14
- end
10
+ col :name
11
+ col :loss_factor, :type => :float
12
+
13
+ # verify "Loss factor should be greater than zero and less than one" do
14
+ # EgridRegion.all.each do |region|
15
+ # unless region.loss_factor > 0 and region.loss_factor < 1
16
+ # raise "Invalid loss factor for EgridRegion #{region.name}: #{region.loss_factor} (should be > 0 and < 1)"
17
+ # end
18
+ # end
19
+ # end
20
+
21
+ # FIXME TODO verify fallback loss factor
22
+
23
+ end
@@ -19,15 +19,5 @@ EgridRegion.class_eval do
19
19
  key 'name', :static => 'US'
20
20
  store 'loss_factor', :synthesize => lambda { |row| (row['USTNGN05'].to_f + row['USTNFI05'].to_f - row['USTCON05'].to_f) / row['USTNGN05'].to_f }
21
21
  end
22
-
23
- verify "Loss factor should be greater than zero and less than one" do
24
- EgridRegion.all.each do |region|
25
- unless region.loss_factor > 0 and region.loss_factor < 1
26
- raise "Invalid loss factor for EgridRegion #{region.name}: #{region.loss_factor} (should be > 0 and < 1)"
27
- end
28
- end
29
- end
30
-
31
- # FIXME TODO verify fallback loss factor
32
22
  end
33
23
  end
@@ -23,22 +23,75 @@ class EgridSubregion < ActiveRecord::Base
23
23
  :electricity_emission_factor => lambda { weighted_average(:electricity_emission_factor, :weighted_by => :net_generation) }, # DEPRECATED
24
24
  :electricity_emission_factor_units => 'kilograms_co2e_per_kilowatt_hour' # DEPRECATED
25
25
 
26
- force_schema do
27
- string 'abbreviation'
28
- string 'name'
29
- string 'nerc_abbreviation'
30
- string 'egrid_region_name'
31
- float 'net_generation'
32
- string 'net_generation_units'
33
- float 'electricity_co2_emission_factor'
34
- string 'electricity_co2_emission_factor_units'
35
- float 'electricity_co2_biogenic_emission_factor'
36
- string 'electricity_co2_biogenic_emission_factor_units'
37
- float 'electricity_ch4_emission_factor'
38
- string 'electricity_ch4_emission_factor_units'
39
- float 'electricity_n2o_emission_factor'
40
- string 'electricity_n2o_emission_factor_units'
41
- float 'electricity_emission_factor'
42
- string 'electricity_emission_factor_units'
43
- end
26
+ col :abbreviation
27
+ col :name
28
+ col :nerc_abbreviation
29
+ col :egrid_region_name
30
+ col :net_generation, :type => :float
31
+ col :net_generation_units
32
+ col :electricity_co2_emission_factor, :type => :float
33
+ col :electricity_co2_emission_factor_units
34
+ col :electricity_co2_biogenic_emission_factor, :type => :float
35
+ col :electricity_co2_biogenic_emission_factor_units
36
+ col :electricity_ch4_emission_factor, :type => :float
37
+ col :electricity_ch4_emission_factor_units
38
+ col :electricity_n2o_emission_factor, :type => :float
39
+ col :electricity_n2o_emission_factor_units
40
+ col :electricity_emission_factor, :type => :float
41
+ col :electricity_emission_factor_units
42
+
43
+ # FIXME TODO verify egrid_region_name is found in EgridRegions
44
+ # %w{ egrid_region_name }.each do |attribute|
45
+ # verify "#{attribute.humanize} should never be missing" do
46
+ # EgridSubregion.all.each do |subregion|
47
+ # unless subregion.send("#{attribute}").present?
48
+ # raise "Missing #{attribute.humanize.downcase} for EgridSubregion #{subregion.name}"
49
+ # end
50
+ # end
51
+ # end
52
+ # end
53
+ #
54
+ # ["net_generation",
55
+ # "electricity_co2_emission_factor",
56
+ # "electricity_ch4_emission_factor",
57
+ # "electricity_n2o_emission_factor",
58
+ # "electricity_emission_factor" ].each do |attribute|
59
+ # verify "#{attribute.humanize} should be > 0" do
60
+ # EgridSubregion.all.each do |subregion|
61
+ # value = subregion.send(:"#{attribute}")
62
+ # unless value > 0
63
+ # raise "Invalid #{attribute.humanize.downcase} for EgridSubregion #{subregion.name}: #{value} (should be > 0)"
64
+ # end
65
+ # end
66
+ # end
67
+ # end
68
+ #
69
+ # verify "Electricity co2 biogenic emission factor should be 0" do
70
+ # EgridSubregion.all.each do |subregion|
71
+ # value = subregion.electricity_co2_biogenic_emission_factor
72
+ # unless value == 0
73
+ # raise "Invalid electricity co2 biogenic emission factor for EgridSubregion #{subregion.name}: #{value} (should be 0)"
74
+ # end
75
+ # end
76
+ # end
77
+ #
78
+ # [["net_generation_units","megawatt_hours"],
79
+ # ["electricity_co2_emission_factor_units","kilograms_per_kilowatt_hour"],
80
+ # ["electricity_co2_biogenic_emission_factor_units","kilograms_per_kilowatt_hour"],
81
+ # ["electricity_ch4_emission_factor_units","kilograms_co2e_per_kilowatt_hour"],
82
+ # ["electricity_n2o_emission_factor_units","kilograms_co2e_per_kilowatt_hour"],
83
+ # ["electricity_emission_factor_units","kilograms_co2e_per_kilowatt_hour"]].each do |pair|
84
+ # attribute = pair[0]
85
+ # proper_units = pair[1]
86
+ # verify "#{attribute.humanize} should be #{proper_units.humanize.downcase}" do
87
+ # EgridSubregion.all.each do |subregion|
88
+ # units = subregion.send(:"#{attribute}")
89
+ # unless units == proper_units
90
+ # raise "Invalid #{attribute.humanize.downcase} for EgridSubregion #{subregion.name}: #{units} (should be #{proper_units})"
91
+ # end
92
+ # end
93
+ # end
94
+ # end
95
+
96
+ # FIXME TODO verify fallbacks
44
97
  end
@@ -61,64 +61,5 @@ EgridSubregion.class_eval do
61
61
  update_all %{ electricity_emission_factor = electricity_co2_emission_factor + electricity_ch4_emission_factor + electricity_n2o_emission_factor,
62
62
  electricity_emission_factor_units = 'kilograms_co2e_per_kilowatt_hour' }
63
63
  end
64
-
65
- # FIXME TODO verify egrid_region_name is found in EgridRegions
66
- %w{ egrid_region_name }.each do |attribute|
67
- verify "#{attribute.humanize} should never be missing" do
68
- EgridSubregion.all.each do |subregion|
69
- unless subregion.send("#{attribute}").present?
70
- puts "Missing #{attribute.humanize.downcase} for EgridSubregion #{subregion.name}"
71
- fail
72
- end
73
- end
74
- end
75
- end
76
-
77
- ["net_generation",
78
- "electricity_co2_emission_factor",
79
- "electricity_ch4_emission_factor",
80
- "electricity_n2o_emission_factor",
81
- "electricity_emission_factor" ].each do |attribute|
82
- verify "#{attribute.humanize} should be > 0" do
83
- EgridSubregion.all.each do |subregion|
84
- value = subregion.send(:"#{attribute}")
85
- unless value > 0
86
- puts "Invalid #{attribute.humanize.downcase} for EgridSubregion #{subregion.name}: #{value} (should be > 0)"
87
- fail
88
- end
89
- end
90
- end
91
- end
92
-
93
- verify "Electricity co2 biogenic emission factor should be 0" do
94
- EgridSubregion.all.each do |subregion|
95
- value = subregion.electricity_co2_biogenic_emission_factor
96
- unless value == 0
97
- puts "Invalid electricity co2 biogenic emission factor for EgridSubregion #{subregion.name}: #{value} (should be 0)"
98
- fail
99
- end
100
- end
101
- end
102
-
103
- [["net_generation_units","megawatt_hours"],
104
- ["electricity_co2_emission_factor_units","kilograms_per_kilowatt_hour"],
105
- ["electricity_co2_biogenic_emission_factor_units","kilograms_per_kilowatt_hour"],
106
- ["electricity_ch4_emission_factor_units","kilograms_co2e_per_kilowatt_hour"],
107
- ["electricity_n2o_emission_factor_units","kilograms_co2e_per_kilowatt_hour"],
108
- ["electricity_emission_factor_units","kilograms_co2e_per_kilowatt_hour"]].each do |pair|
109
- attribute = pair[0]
110
- proper_units = pair[1]
111
- verify "#{attribute.humanize} should be #{proper_units.humanize.downcase}" do
112
- EgridSubregion.all.each do |subregion|
113
- units = subregion.send(:"#{attribute}")
114
- unless units == proper_units
115
- puts "Invalid #{attribute.humanize.downcase} for EgridSubregion #{subregion.name}: #{units} (should be #{proper_units})"
116
- fail
117
- end
118
- end
119
- end
120
- end
121
-
122
- # FIXME TODO verify fallbacks
123
64
  end
124
65
  end
@@ -8,11 +8,9 @@ class PetroleumAdministrationForDefenseDistrict < ActiveRecord::Base
8
8
  str
9
9
  end
10
10
 
11
- force_schema do
12
- string 'code'
13
- string 'district_code'
14
- string 'district_name'
15
- string 'subdistrict_code'
16
- string 'subdistrict_name'
17
- end
18
- end
11
+ col :code
12
+ col :district_code
13
+ col :district_name
14
+ col :subdistrict_code
15
+ col :subdistrict_name
16
+ end
@@ -11,11 +11,9 @@ class State < ActiveRecord::Base
11
11
  Country.united_states
12
12
  end
13
13
 
14
- force_schema do
15
- string 'postal_abbreviation'
16
- integer 'fips_code'
17
- string 'name'
18
- string 'census_division_number'
19
- string 'petroleum_administration_for_defense_district_code'
20
- end
21
- end
14
+ col :postal_abbreviation
15
+ col :fips_code, :type => :integer
16
+ col :name
17
+ col :census_division_number
18
+ col :petroleum_administration_for_defense_district_code
19
+ end
@@ -3,7 +3,5 @@ class Urbanity < ActiveRecord::Base
3
3
 
4
4
  has_many :residential_energy_consumption_survey_responses
5
5
 
6
- force_schema do
7
- string 'name'
8
- end
9
- end
6
+ col :name
7
+ end