earth 0.11.7 → 0.11.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. data/README.markdown +30 -0
  2. data/bin/earth_tester.rb +1 -1
  3. data/earth.gemspec +3 -3
  4. data/lib/earth.rb +105 -90
  5. data/lib/earth/air.rb +3 -12
  6. data/lib/earth/air/aircraft.rb +9 -9
  7. data/lib/earth/air/airport.rb +3 -0
  8. data/lib/earth/air/airport/data_miner.rb +2 -0
  9. data/lib/earth/air/data_miner.rb +3 -10
  10. data/lib/earth/air/flight_segment.rb +3 -1
  11. data/lib/earth/air/flight_segment/data_miner.rb +2 -0
  12. data/lib/earth/all.rb +3 -13
  13. data/lib/earth/automobile.rb +3 -18
  14. data/lib/earth/automobile/automobile_fuel.rb +1 -3
  15. data/lib/earth/automobile/automobile_fuel/data_miner.rb +1 -0
  16. data/lib/earth/automobile/automobile_make.rb +1 -0
  17. data/lib/earth/automobile/automobile_make/data_miner.rb +1 -0
  18. data/lib/earth/automobile/automobile_make_model.rb +1 -0
  19. data/lib/earth/automobile/automobile_make_model/data_miner.rb +1 -0
  20. data/lib/earth/automobile/automobile_make_model_year.rb +1 -0
  21. data/lib/earth/automobile/automobile_make_model_year/data_miner.rb +1 -0
  22. data/lib/earth/automobile/automobile_make_model_year_variant.rb +1 -0
  23. data/lib/earth/automobile/automobile_make_model_year_variant/data_miner.rb +1 -0
  24. data/lib/earth/automobile/automobile_make_year.rb +1 -0
  25. data/lib/earth/automobile/automobile_make_year/data_miner.rb +1 -0
  26. data/lib/earth/automobile/automobile_make_year_fleet.rb +1 -0
  27. data/lib/earth/automobile/automobile_make_year_fleet/data_miner.rb +1 -0
  28. data/lib/earth/automobile/automobile_model.rb +1 -0
  29. data/lib/earth/automobile/automobile_model/data_miner.rb +1 -0
  30. data/lib/earth/automobile/automobile_size_class.rb +1 -0
  31. data/lib/earth/automobile/automobile_size_class/data_miner.rb +1 -0
  32. data/lib/earth/automobile/automobile_size_class_year.rb +1 -0
  33. data/lib/earth/automobile/automobile_size_class_year/data_miner.rb +1 -0
  34. data/lib/earth/automobile/automobile_type_fuel_control.rb +1 -0
  35. data/lib/earth/automobile/automobile_type_fuel_control/data_miner.rb +1 -0
  36. data/lib/earth/automobile/automobile_type_fuel_year.rb +1 -0
  37. data/lib/earth/automobile/automobile_type_fuel_year/data_miner.rb +1 -0
  38. data/lib/earth/automobile/automobile_type_fuel_year_age.rb +1 -0
  39. data/lib/earth/automobile/automobile_type_fuel_year_age/data_miner.rb +1 -0
  40. data/lib/earth/automobile/automobile_type_fuel_year_control.rb +1 -0
  41. data/lib/earth/automobile/automobile_type_fuel_year_control/data_miner.rb +1 -0
  42. data/lib/earth/automobile/automobile_type_year.rb +1 -0
  43. data/lib/earth/automobile/automobile_type_year/data_miner.rb +1 -0
  44. data/lib/earth/automobile/automobile_year.rb +1 -0
  45. data/lib/earth/automobile/automobile_year/data_miner.rb +1 -0
  46. data/lib/earth/automobile/data_miner.rb +3 -18
  47. data/lib/earth/bus.rb +3 -6
  48. data/lib/earth/bus/bus_class.rb +1 -0
  49. data/lib/earth/bus/bus_class/data_miner.rb +1 -0
  50. data/lib/earth/bus/bus_fuel.rb +1 -0
  51. data/lib/earth/bus/bus_fuel/data_miner.rb +1 -0
  52. data/lib/earth/bus/bus_fuel_control.rb +1 -0
  53. data/lib/earth/bus/bus_fuel_control/data_miner.rb +1 -0
  54. data/lib/earth/bus/bus_fuel_year_control.rb +1 -0
  55. data/lib/earth/bus/bus_fuel_year_control/data_miner.rb +1 -0
  56. data/lib/earth/bus/data_miner.rb +3 -6
  57. data/lib/earth/computation.rb +3 -5
  58. data/lib/earth/computation/computation_carrier.rb +1 -0
  59. data/lib/earth/computation/computation_carrier/data_miner.rb +1 -1
  60. data/lib/earth/computation/computation_carrier_instance_class.rb +1 -0
  61. data/lib/earth/computation/computation_carrier_instance_class/data_miner.rb +1 -0
  62. data/lib/earth/computation/computation_carrier_region.rb +1 -0
  63. data/lib/earth/computation/computation_carrier_region/data_miner.rb +1 -0
  64. data/lib/earth/computation/data_miner.rb +3 -5
  65. data/lib/earth/data_miner.rb +3 -13
  66. data/lib/earth/diet.rb +3 -2
  67. data/lib/earth/diet/data_miner.rb +3 -2
  68. data/lib/earth/eia.rb +11 -13
  69. data/lib/earth/fuel.rb +3 -5
  70. data/lib/earth/fuel/data_miner.rb +3 -5
  71. data/lib/earth/fuel/fuel_price.rb +1 -1
  72. data/lib/earth/hospitality.rb +3 -5
  73. data/lib/earth/hospitality/commercial_building_energy_consumption_survey_response.rb +2 -0
  74. data/lib/earth/hospitality/commercial_building_energy_consumption_survey_response/data_miner.rb +13 -7
  75. data/lib/earth/hospitality/country_lodging_class.rb +1 -0
  76. data/lib/earth/hospitality/country_lodging_class/data_miner.rb +4 -2
  77. data/lib/earth/hospitality/data_miner.rb +3 -4
  78. data/lib/earth/hospitality/lodging_class.rb +1 -10
  79. data/lib/earth/hospitality/lodging_class/data_miner.rb +7 -30
  80. data/lib/earth/hospitality/lodging_property.rb +1 -0
  81. data/lib/earth/industry.rb +3 -13
  82. data/lib/earth/industry/cbecs_energy_intensity.rb +5 -49
  83. data/lib/earth/industry/cbecs_energy_intensity/data_miner.rb +94 -42
  84. data/lib/earth/industry/data_miner.rb +3 -4
  85. data/lib/earth/industry/industry.rb +1 -0
  86. data/lib/earth/industry/industry/data_miner.rb +1 -0
  87. data/lib/earth/industry/industry_product.rb +1 -0
  88. data/lib/earth/industry/industry_product_line.rb +1 -0
  89. data/lib/earth/industry/industry_sector.rb +1 -0
  90. data/lib/earth/industry/mecs_energy.rb +3 -24
  91. data/lib/earth/industry/mecs_energy/data_miner.rb +34 -11
  92. data/lib/earth/industry/mecs_ratio.rb +6 -24
  93. data/lib/earth/industry/mecs_ratio/data_miner.rb +24 -1
  94. data/lib/earth/locality.rb +3 -15
  95. data/lib/earth/locality/census_division.rb +1 -0
  96. data/lib/earth/locality/census_division/data_miner.rb +1 -0
  97. data/lib/earth/locality/country.rb +3 -0
  98. data/lib/earth/locality/country/data_miner.rb +5 -1
  99. data/lib/earth/locality/data_miner.rb +3 -15
  100. data/lib/earth/locality/egrid_subregion.rb +1 -0
  101. data/lib/earth/locality/egrid_subregion/data_miner.rb +1 -0
  102. data/lib/earth/locality/state/data_miner.rb +11 -11
  103. data/lib/earth/locality/zip_code.rb +6 -0
  104. data/lib/earth/pet.rb +3 -4
  105. data/lib/earth/pet/data_miner.rb +3 -4
  106. data/lib/earth/rail.rb +3 -15
  107. data/lib/earth/rail/country_rail_class.rb +1 -0
  108. data/lib/earth/rail/country_rail_class/data_miner.rb +1 -0
  109. data/lib/earth/rail/country_rail_traction.rb +2 -0
  110. data/lib/earth/rail/country_rail_traction/data_miner.rb +2 -0
  111. data/lib/earth/rail/country_rail_traction_class.rb +2 -0
  112. data/lib/earth/rail/country_rail_traction_class/data_miner.rb +2 -0
  113. data/lib/earth/rail/data_miner.rb +3 -16
  114. data/lib/earth/rail/national_transit_database_company.rb +1 -0
  115. data/lib/earth/rail/national_transit_database_company/data_miner.rb +1 -0
  116. data/lib/earth/rail/national_transit_database_record.rb +1 -0
  117. data/lib/earth/rail/national_transit_database_record/data_miner.rb +1 -0
  118. data/lib/earth/rail/rail_company.rb +2 -0
  119. data/lib/earth/rail/rail_company/data_miner.rb +2 -0
  120. data/lib/earth/rail/rail_company_traction.rb +1 -0
  121. data/lib/earth/rail/rail_company_traction/data_miner.rb +1 -0
  122. data/lib/earth/rail/rail_company_traction_class.rb +1 -0
  123. data/lib/earth/rail/rail_company_traction_class/data_miner.rb +1 -0
  124. data/lib/earth/rail/rail_fuel.rb +1 -0
  125. data/lib/earth/rail/rail_fuel/data_miner.rb +1 -0
  126. data/lib/earth/residence.rb +3 -11
  127. data/lib/earth/residence/data_miner.rb +3 -11
  128. data/lib/earth/residence/residence_fuel_price.rb +1 -0
  129. data/lib/earth/residence/residence_fuel_price/data_miner.rb +1 -0
  130. data/lib/earth/residence/residential_energy_consumption_survey_response.rb +1 -0
  131. data/lib/earth/residence/residential_energy_consumption_survey_response/data_miner.rb +1 -0
  132. data/lib/earth/shipping.rb +3 -3
  133. data/lib/earth/shipping/data_miner.rb +3 -3
  134. data/lib/earth/version.rb +1 -1
  135. data/spec/earth/industry/mecs_energy_spec.rb +18 -0
  136. data/spec/earth_spec.rb +18 -29
  137. data/test/test_aircraft_match.rb +142 -142
  138. data/vendor/geokit-rails/.gitignore +2 -0
  139. data/vendor/geokit-rails/CHANGELOG.rdoc +4 -1
  140. data/vendor/geokit-rails/README.markdown +11 -3
  141. data/vendor/geokit-rails/about.yml +2 -0
  142. data/vendor/geokit-rails/lib/geokit-rails.rb +7 -4
  143. data/vendor/geokit-rails/lib/geokit-rails/acts_as_mappable.rb +15 -2
  144. data/vendor/geokit-rails/lib/geokit-rails/adapters/abstract.rb +1 -1
  145. data/vendor/geokit-rails/lib/geokit-rails/adapters/mysql2.rb +22 -0
  146. data/vendor/geokit-rails/test/database.yml +5 -0
  147. data/vendor/geokit-rails/test/ip_geocode_lookup_test.rb +1 -1
  148. data/vendor/geokit-rails/test/tasks.rake +2 -2
  149. metadata +179 -191
  150. data/lib/earth/hospitality/census_region_lodging_class.rb +0 -16
  151. data/lib/earth/hospitality/census_region_lodging_class/data_miner.rb +0 -40
@@ -1,18 +1,3 @@
1
- require 'earth/automobile/automobile_fuel'
2
- require 'earth/automobile/automobile_make'
3
- require 'earth/automobile/automobile_make_year'
4
- require 'earth/automobile/automobile_make_year_fleet'
5
- require 'earth/automobile/automobile_make_model'
6
- require 'earth/automobile/automobile_make_model_year'
7
- require 'earth/automobile/automobile_make_model_year_variant'
8
- require 'earth/automobile/automobile_model'
9
- require 'earth/automobile/automobile_size_class'
10
- require 'earth/automobile/automobile_size_class_year'
11
- require 'earth/automobile/automobile_type_year'
12
- require 'earth/automobile/automobile_type_fuel_control'
13
- require 'earth/automobile/automobile_type_fuel_year'
14
- require 'earth/automobile/automobile_type_fuel_year_age'
15
- require 'earth/automobile/automobile_type_fuel_year_control'
16
- require 'earth/automobile/automobile_year'
17
-
18
- require 'earth/fuel'
1
+ # lib/earth/automobile.rb
2
+ require 'earth'
3
+ Earth.require_related __FILE__
@@ -1,6 +1,4 @@
1
- require 'earth/automobile/automobile_type_fuel_year_age'
2
- require 'earth/automobile/automobile_type_fuel_year'
3
- require 'earth/automobile/automobile_type_year'
1
+ require 'earth/fuel'
4
2
 
5
3
  class AutomobileFuel < ActiveRecord::Base
6
4
  set_primary_key :name
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel/data_miner'
1
2
  AutomobileFuel.class_eval do
2
3
  data_miner do
3
4
  import "a list of pure automobile fuels",
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel'
1
2
  class AutomobileMake < ActiveRecord::Base
2
3
  set_primary_key :name
3
4
 
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel/data_miner'
1
2
  AutomobileMake.class_eval do
2
3
  data_miner do
3
4
  process "Start from scratch" do
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel'
1
2
  class AutomobileMakeModel < ActiveRecord::Base
2
3
  set_primary_key :name
3
4
 
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel/data_miner'
1
2
  AutomobileMakeModel.class_eval do
2
3
  data_miner do
3
4
  process "Start from scratch" do
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel'
1
2
  class AutomobileMakeModelYear < ActiveRecord::Base
2
3
  set_primary_key :name
3
4
 
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel/data_miner'
1
2
  AutomobileMakeModelYear.class_eval do
2
3
  data_miner do
3
4
  process "Start from scratch" do
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel'
1
2
  class AutomobileMakeModelYearVariant < ActiveRecord::Base
2
3
  set_primary_key :row_hash
3
4
 
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel/data_miner'
1
2
  AutomobileMakeModelYearVariant.class_eval do
2
3
  # For errata
3
4
  class AutomobileMakeModelYearVariant::Guru
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel'
1
2
  class AutomobileMakeYear < ActiveRecord::Base
2
3
  set_primary_key :name
3
4
 
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel/data_miner'
1
2
  AutomobileMakeYear.class_eval do
2
3
  data_miner do
3
4
  process "Start from scratch" do
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel'
1
2
  class AutomobileMakeYearFleet < ActiveRecord::Base
2
3
  set_primary_key :name
3
4
 
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel/data_miner'
1
2
  AutomobileMakeYearFleet.class_eval do
2
3
  data_miner do
3
4
  import "annual corporate average fuel economy data for domestic and imported vehicle fleets from the NHTSA",
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel'
1
2
  class AutomobileModel < ActiveRecord::Base
2
3
  set_primary_key :name
3
4
 
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel/data_miner'
1
2
  AutomobileModel.class_eval do
2
3
  data_miner do
3
4
  process "Start from scratch" do
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel'
1
2
  class AutomobileSizeClass < ActiveRecord::Base
2
3
  set_primary_key :name
3
4
 
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel/data_miner'
1
2
  AutomobileSizeClass.class_eval do
2
3
  data_miner do
3
4
  import "a list of size classes and pre-calculated fuel efficiencies",
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel'
1
2
  # Not yet in use - for if we want to autocaculate size class stuf - November 10, 2011
2
3
  class AutomobileSizeClassYear < ActiveRecord::Base
3
4
  set_primary_key :name
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel/data_miner'
1
2
  # Not yet in use - for if we want to autocaculate size class stuf - November 10, 2011
2
3
  AutomobileSizeClassYear.class_eval do
3
4
  data_miner do
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel'
1
2
  class AutomobileTypeFuelControl < ActiveRecord::Base
2
3
  set_primary_key :name
3
4
  col :name
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel/data_miner'
1
2
  AutomobileTypeFuelControl.class_eval do
2
3
  data_miner do
3
4
  import "automobile type fuel control data derived from the 2010 EPA GHG Inventory",
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel'
1
2
  class AutomobileTypeFuelYear < ActiveRecord::Base
2
3
  set_primary_key :name
3
4
 
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel/data_miner'
1
2
  AutomobileTypeFuelYear.class_eval do
2
3
  data_miner do
3
4
  import "total vehicle miles travelled by gasoline passenger cars from the 2010 EPA GHG Inventory",
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel'
1
2
  class AutomobileTypeFuelYearAge < ActiveRecord::Base
2
3
  set_primary_key :name
3
4
 
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel/data_miner'
1
2
  AutomobileTypeFuelYearAge.class_eval do
2
3
  data_miner do
3
4
  import "total travel distribution of gasoline passenger cars from the 2010 EPA GHG Inventory",
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel'
1
2
  class AutomobileTypeFuelYearControl < ActiveRecord::Base
2
3
  set_primary_key :name
3
4
 
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel/data_miner'
1
2
  AutomobileTypeFuelYearControl.class_eval do
2
3
  data_miner do
3
4
  import "automobile type fuel year control data derived from the 2010 EPA GHG Inventory",
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel'
1
2
  class AutomobileTypeYear < ActiveRecord::Base
2
3
  set_primary_key :name
3
4
 
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel/data_miner'
1
2
  AutomobileTypeYear.class_eval do
2
3
  data_miner do
3
4
  import "automobile type year air conditioning emissions derived from the 2010 EPA GHG Inventory",
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel'
1
2
  class AutomobileYear < ActiveRecord::Base
2
3
  set_primary_key :year
3
4
 
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel/data_miner'
1
2
  AutomobileYear.class_eval do
2
3
  data_miner do
3
4
  process "Ensure AutomobileMakeModelYearVariant is populated" do
@@ -1,18 +1,3 @@
1
- require 'earth/automobile/automobile_fuel/data_miner'
2
- require 'earth/automobile/automobile_make/data_miner'
3
- require 'earth/automobile/automobile_make_year/data_miner'
4
- require 'earth/automobile/automobile_make_year_fleet/data_miner'
5
- require 'earth/automobile/automobile_make_model/data_miner'
6
- require 'earth/automobile/automobile_make_model_year/data_miner'
7
- require 'earth/automobile/automobile_make_model_year_variant/data_miner'
8
- require 'earth/automobile/automobile_size_class/data_miner'
9
- require 'earth/automobile/automobile_size_class_year/data_miner'
10
- require 'earth/automobile/automobile_type_year/data_miner'
11
- require 'earth/automobile/automobile_type_fuel_control/data_miner'
12
- require 'earth/automobile/automobile_type_fuel_year/data_miner'
13
- require 'earth/automobile/automobile_type_fuel_year_age/data_miner'
14
- require 'earth/automobile/automobile_type_fuel_year_control/data_miner'
15
- require 'earth/automobile/automobile_model/data_miner'
16
- require 'earth/automobile/automobile_year/data_miner'
17
-
18
- require 'earth/fuel/data_miner'
1
+ # lib/earth/automobile/data_miner.rb
2
+ require 'earth'
3
+ Earth.require_related __FILE__
data/lib/earth/bus.rb CHANGED
@@ -1,6 +1,3 @@
1
- require 'earth/bus/bus_class'
2
- require 'earth/bus/bus_fuel'
3
- require 'earth/bus/bus_fuel_control'
4
- require 'earth/bus/bus_fuel_year_control'
5
-
6
- require 'earth/fuel'
1
+ # lib/earth/bus.rb
2
+ require 'earth'
3
+ Earth.require_related __FILE__
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel'
1
2
  class BusClass < ActiveRecord::Base
2
3
  set_primary_key :name
3
4
 
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel/data_miner'
1
2
  BusClass.class_eval do
2
3
  data_miner do
3
4
  import "a list of bus classes and pre-calculated trip and fuel use characteristics",
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel'
1
2
  class BusFuel < ActiveRecord::Base
2
3
  set_primary_key :name
3
4
 
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel/data_miner'
1
2
  BusFuel.class_eval do
2
3
  data_miner do
3
4
  process "Ensure Fuel, GreenhouseGas, and BusFuelYearControl are populated" do
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel'
1
2
  class BusFuelControl < ActiveRecord::Base
2
3
  set_primary_key :name
3
4
  col :name
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel/data_miner'
1
2
  BusFuelControl.class_eval do
2
3
  data_miner do
3
4
  import "a list of bus fuel controls",
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel'
1
2
  class BusFuelYearControl < ActiveRecord::Base
2
3
  set_primary_key :name
3
4
 
@@ -1,3 +1,4 @@
1
+ require 'earth/fuel/data_miner'
1
2
  BusFuelYearControl.class_eval do
2
3
  data_miner do
3
4
  process "Ensure BusFuelControl is populated" do
@@ -1,6 +1,3 @@
1
- require 'earth/bus/bus_class/data_miner'
2
- require 'earth/bus/bus_fuel/data_miner'
3
- require 'earth/bus/bus_fuel_control/data_miner'
4
- require 'earth/bus/bus_fuel_year_control/data_miner'
5
-
6
- require 'earth/fuel/data_miner'
1
+ # lib/earth/bus/data_miner.rb
2
+ require 'earth'
3
+ Earth.require_related __FILE__
@@ -1,5 +1,3 @@
1
- require 'earth/computation/computation_carrier'
2
- require 'earth/computation/computation_carrier_region'
3
- require 'earth/computation/computation_carrier_instance_class'
4
-
5
- require 'earth/locality'
1
+ # lib/earth/computation.rb
2
+ require 'earth'
3
+ Earth.require_related __FILE__
@@ -1,3 +1,4 @@
1
+ require 'earth/locality'
1
2
  class ComputationCarrier < ActiveRecord::Base
2
3
  set_primary_key :name
3
4
 
@@ -1,3 +1,4 @@
1
+ require 'earth/locality/data_miner'
1
2
  ComputationCarrier.class_eval do
2
3
  data_miner do
3
4
  import "a list of computation carriers and their power usage effectiveness",
@@ -5,6 +6,5 @@ ComputationCarrier.class_eval do
5
6
  key 'name'
6
7
  store 'power_usage_effectiveness'
7
8
  end
8
-
9
9
  end
10
10
  end
@@ -1,3 +1,4 @@
1
+ require 'earth/locality'
1
2
  class ComputationCarrierInstanceClass < ActiveRecord::Base
2
3
  set_primary_key :name
3
4
 
@@ -1,3 +1,4 @@
1
+ require 'earth/locality/data_miner'
1
2
  ComputationCarrierInstanceClass.class_eval do
2
3
  data_miner do
3
4
  import "a list of computation carrier instance classes and their characteristics",
@@ -1,3 +1,4 @@
1
+ require 'earth/locality'
1
2
  class ComputationCarrierRegion < ActiveRecord::Base
2
3
  set_primary_key :name
3
4
 
@@ -1,3 +1,4 @@
1
+ require 'earth/locality/data_miner'
1
2
  ComputationCarrierRegion.class_eval do
2
3
  data_miner do
3
4
  import "a list of computation carrier regions",
@@ -1,5 +1,3 @@
1
- require 'earth/computation/computation_carrier/data_miner'
2
- require 'earth/computation/computation_carrier_region/data_miner'
3
- require 'earth/computation/computation_carrier_instance_class/data_miner'
4
-
5
- require 'earth/locality/data_miner'
1
+ # lib/earth/computation/data_miner.rb
2
+ require 'earth'
3
+ Earth.require_related __FILE__
@@ -1,13 +1,3 @@
1
- require 'earth/air/data_miner'
2
- require 'earth/automobile/data_miner'
3
- require 'earth/bus/data_miner'
4
- require 'earth/computation/data_miner'
5
- require 'earth/diet/data_miner'
6
- require 'earth/fuel/data_miner'
7
- require 'earth/hospitality/data_miner'
8
- require 'earth/locality/data_miner'
9
- require 'earth/pet/data_miner'
10
- require 'earth/rail/data_miner'
11
- require 'earth/residence/data_miner'
12
- require 'earth/shipping/data_miner'
13
- require 'earth/industry/data_miner'
1
+ # lib/earth/data_miner.rb
2
+ require 'earth'
3
+ Earth.require_all :load_data_miner => true
data/lib/earth/diet.rb CHANGED
@@ -1,2 +1,3 @@
1
- require 'earth/diet/diet_class'
2
- require 'earth/diet/food_group'
1
+ # lib/earth/diet.rb
2
+ require 'earth'
3
+ Earth.require_related __FILE__
@@ -1,2 +1,3 @@
1
- require 'earth/diet/diet_class/data_miner'
2
- require 'earth/diet/food_group/data_miner'
1
+ # lib/earth/diet/data_miner.rb
2
+ require 'earth'
3
+ Earth.require_related __FILE__
data/lib/earth/eia.rb CHANGED
@@ -1,23 +1,21 @@
1
+ require 'earth'
1
2
  module Earth
2
3
  module EIA
3
4
  extend self
4
5
 
5
6
  def normalize(model, fields)
6
7
  model.all.each do |record|
7
- fields.each do |field|
8
- value = record.send field
9
- normalized_value = if value == 'Q'
10
- 0
11
- elsif value == 'W'
12
- 0
13
- elsif value == '*'
14
- 0
15
- else
16
- value
17
- end
18
- record.send "#{field}=", normalized_value
8
+ fields.each do |k|
9
+ v = record.send k
10
+ normalized_v = case v
11
+ when 'Q', 'W', '*'
12
+ 0
13
+ else
14
+ v
15
+ end
16
+ record.send "#{k}=", normalized_v
19
17
  end
20
- record.save
18
+ record.save!
21
19
  end
22
20
  end
23
21
  end