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
@@ -1,5 +1,5 @@
1
1
  require 'earth/eia'
2
- require 'earth/industry'
2
+ require 'earth/industry/industry'
3
3
 
4
4
  CbecsEnergyIntensity.class_eval do
5
5
  const_set(:CBECS, {
@@ -30,7 +30,6 @@ EOS
30
30
  has_many :industry_sectors, :foreign_key => 'naics_code'
31
31
  has_many :sectors, :through => :industry_sectors
32
32
 
33
-
34
33
  class << self
35
34
  def format_naics_code(input)
36
35
  "%d" % input.to_i
@@ -39,7 +38,7 @@ EOS
39
38
 
40
39
  def trade_industry?
41
40
  prefix = naics_code.to_s[0,2]
42
- %w{42 44 45}.include?(prefix)
41
+ %w{42 44 45}.include? prefix
43
42
  end
44
43
 
45
44
  warn_unless_size 2341
@@ -36,20 +36,19 @@ EOS
36
36
 
37
37
  self.primary_key = "name"
38
38
 
39
-
40
39
  FUELS = [:electricity, :residual_fuel_oil, :distillate_fuel_oil,
41
40
  :natural_gas, :lpg_and_ngl, :coal, :coke_and_breeze, :other_fuel]
42
41
 
43
- # Find the first record whose naics_code matches code and that has valid fuel ratios.
44
- # If no record found chop off the last character of code and try again, and so on.
45
- def self.find_by_naics_code(code)
46
- find_by_naics_code_and_census_region_number(code, nil)
47
- end
42
+ # Find the first record whose naics_code matches code and that has valid fuel ratios.
43
+ # If no record found chop off the last character of code and try again, and so on.
44
+ def self.find_by_naics_code(code)
45
+ find_by_naics_code_and_census_region_number(code, nil)
46
+ end
48
47
 
49
- # Find the first record whose census_region_number matches number, whose naics_code matches code, and that has valid fuel ratios.
50
- # If none found and we know census region number, try looking nationwide
51
- # If none found and looking nationwide, chop off the last character of code and try again looking in census region
52
- # And so on
48
+ # Find the first record whose census_region_number matches number, whose naics_code matches code, and that has valid fuel ratios.
49
+ # If none found and we know census region number, try looking nationwide
50
+ # If none found and looking nationwide, chop off the last character of code and try again looking in census region
51
+ # And so on
53
52
  def self.find_by_naics_code_and_census_region_number(code, number, original_number = number)
54
53
  if code.blank?
55
54
  record = nil
@@ -22,7 +22,6 @@ EOS
22
22
 
23
23
  belongs_to :industry
24
24
 
25
-
26
25
  # Find the first record whose naics_code matches code and whose energy per dollar shipment is present.
27
26
  # If no record found chop off the last character of code and try again, and so on.
28
27
  def self.find_by_naics_code(code)
@@ -50,4 +49,6 @@ EOS
50
49
  end
51
50
  record
52
51
  end
52
+
53
+ warn_unless_size 395
53
54
  end
@@ -25,4 +25,5 @@ EOS
25
25
  description
26
26
  end
27
27
 
28
+ warn_unless_size 285
28
29
  end
@@ -29,4 +29,6 @@ EOS
29
29
 
30
30
  has_many :naics_2002_naics_2007_concordances, :foreign_key => :naics_2002_code
31
31
  has_many :naics_2007, :through => :naics_2002_naics_2007_concordances
32
+
33
+ warn_unless_size 2341
32
34
  end
@@ -28,4 +28,5 @@ EOS
28
28
  (note = description.match(/ - (.+)/)) ? note.captures.first : nil
29
29
  end
30
30
 
31
+ warn_unless_size 1200
31
32
  end
@@ -28,4 +28,5 @@ EOS
28
28
  (note = description.match /.+?\((.+)\)/) ? note.captures.first : nil
29
29
  end
30
30
 
31
+ warn_unless_size 2164
31
32
  end
@@ -22,4 +22,5 @@ EOS
22
22
  has_many :naics_2002_naics_2007_concordances, :foreign_key => :naics_2007_code
23
23
  has_many :naics_2002, :through => :naics_2002_naics_2007_concordances
24
24
 
25
+ warn_unless_size 2328
25
26
  end
@@ -27,4 +27,5 @@ EOS
27
27
  (desc = description.match /^(.+?) \(/) ? desc.captures.first : description
28
28
  end
29
29
 
30
+ warn_unless_size 1004
30
31
  end
@@ -1,6 +1,5 @@
1
- require 'falls_back_on'
2
-
3
1
  require 'earth/model'
2
+ require 'falls_back_on'
4
3
 
5
4
  require 'earth/locality/census_region'
6
5
  require 'earth/locality/climate_division'
@@ -46,6 +45,5 @@ EOS
46
45
  :meeting_building_electricity_intensity => 0.0084323684 / 1.square_feet.to(:square_metres),
47
46
  :meeting_building_district_heat_intensity => 0.0004776370.kbtus.to(:megajoules) / 1.square_feet.to(:square_metres)
48
47
 
49
-
50
48
  warn_unless_size 9
51
49
  end
@@ -27,6 +27,5 @@ EOS
27
27
 
28
28
  RADIUS = 750
29
29
 
30
-
31
30
  warn_unless_size 359
32
31
  end
@@ -1,6 +1,5 @@
1
- require 'falls_back_on'
2
-
3
1
  require 'earth/model'
2
+ require 'falls_back_on'
4
3
 
5
4
  require 'earth/locality/electricity_mix'
6
5
  require 'earth/rail/rail_company'
@@ -23,6 +23,10 @@ Country.class_eval do
23
23
  store 'name', :field_number => 5 # romanized version with utf-8 characters
24
24
  end
25
25
 
26
+ process "Add Kosovo using the FIPS code 'KV'" do
27
+ Country.find_or_create_by_iso_3166_code_and_name 'KV', 'Kosovo'
28
+ end
29
+
26
30
  import "heating and cooling degree day data from WRI CAIT",
27
31
  :url => "file://#{Earth::DATA_DIR}/locality/wri_hdd_cdd_data.csv",
28
32
  :select => proc { |record| record['country'] != 'European Union (27)' },
@@ -29,7 +29,6 @@ EOS
29
29
  end
30
30
  end
31
31
 
32
-
33
32
  warn_unless_size 1
34
33
  warn_if_any_nulls
35
34
  end
@@ -1,6 +1,5 @@
1
- require 'falls_back_on'
2
-
3
1
  require 'earth/model'
2
+ require 'falls_back_on'
4
3
 
5
4
  require 'earth/locality/egrid_country'
6
5
  require 'earth/locality/egrid_subregion'
@@ -35,7 +34,6 @@ EOS
35
34
  falls_back_on :name => 'fallback',
36
35
  :loss_factor => lambda { EgridCountry.us.loss_factor }
37
36
 
38
-
39
37
  warn_unless_size 5
40
38
  warn_if_any_nulls
41
39
  end
@@ -1,6 +1,5 @@
1
- require 'falls_back_on'
2
-
3
1
  require 'earth/model'
2
+ require 'falls_back_on'
4
3
 
5
4
  require 'earth/locality/egrid_region'
6
5
  require 'earth/locality/electricity_mix'
@@ -50,7 +49,6 @@ EOS
50
49
  :electricity_emission_factor => lambda { weighted_average(:electricity_emission_factor, :weighted_by => :net_generation) },
51
50
  :electricity_emission_factor_units => 'kilograms_co2e_per_kilowatt_hour'
52
51
 
53
-
54
52
  warn_unless_size 26
55
53
  warn_if_any_nulls
56
54
  end
@@ -1,6 +1,5 @@
1
- require 'falls_back_on'
2
-
3
1
  require 'earth/model'
2
+ require 'falls_back_on'
4
3
 
5
4
  class ElectricityMix < ActiveRecord::Base
6
5
  extend Earth::Model
@@ -45,7 +44,6 @@ EOS
45
44
  :n2o_emission_factor_units => 'kilograms_co2e_per_kilowatt_hour',
46
45
  :loss_factor => 0.096 # from ecometrica paper FIXME TODO calculate this
47
46
 
48
-
49
- warn_unless_size 187
47
+ warn_unless_size 213
50
48
  warn_if_any_nulls
51
49
  end
@@ -25,7 +25,6 @@ EOS
25
25
  str
26
26
  end
27
27
 
28
-
29
28
  warn_if_nulls_except(
30
29
  :subdistrict_code,
31
30
  :subdistrict_name
@@ -48,7 +48,6 @@ EOS
48
48
  Country.united_states
49
49
  end
50
50
 
51
-
52
51
  warn_if_nulls_except(
53
52
  :census_division_number,
54
53
  :petroleum_administration_for_defense_district_code
@@ -58,7 +58,6 @@ EOS
58
58
  :lat_column_name => :latitude,
59
59
  :lng_column_name => :longitude
60
60
 
61
-
62
61
  warn_unless_size 43770
63
62
  warn_if_nonexistent_owner_except :egrid_subregion
64
63
  end
data/lib/earth/model.rb CHANGED
@@ -23,7 +23,7 @@ module Earth
23
23
  require path if File.exist?(path + '.rb')
24
24
  target.data_miner_script.prepend_once :process, :create_table!
25
25
  else
26
- target.data_miner_script.prepend_once :sql, "Brighter Planet's reference data", "http://data.brighterplanet.com/#{to_s.underscore.pluralize}.sql"
26
+ target.data_miner_script.prepend_once :sql, "Brighter Planet's reference data", "http://data.brighterplanet.com/#{target.to_s.underscore.pluralize}.sql"
27
27
  end
28
28
  target.data_miner_script.append_once :process, :run_data_miner_on_parent_associations!
29
29
  end
@@ -23,7 +23,6 @@ EOS
23
23
  has_many :breed_genders, :foreign_key => 'breed_name'
24
24
  belongs_to :species, :foreign_key => 'species_name'
25
25
 
26
-
27
26
  warn_if_nulls_except(
28
27
  :weight,
29
28
  :weight_units
@@ -24,6 +24,5 @@ EOS
24
24
  belongs_to :breed, :foreign_key => 'breed_name'
25
25
  belongs_to :gender, :foreign_key => 'gender_name'
26
26
 
27
-
28
27
  warn_unless_size 586
29
28
  end
@@ -18,6 +18,5 @@ EOS
18
18
 
19
19
  has_many :breed_genders, :foreign_key => 'gender_name'
20
20
 
21
-
22
21
  warn_unless_size 2
23
22
  end
@@ -1,6 +1,5 @@
1
- require 'falls_back_on'
2
-
3
1
  require 'earth/model'
2
+ require 'falls_back_on'
4
3
 
5
4
  require 'earth/pet/breed'
6
5
 
@@ -31,7 +30,6 @@ EOS
31
30
 
32
31
  self.primary_key = "name"
33
32
 
34
-
35
33
  has_many :breeds, :foreign_key => 'species_name'
36
34
 
37
35
  scope :thoroughly_researched, :conditions => 'marginal_dietary_requirement IS NOT NULL'
@@ -27,6 +27,5 @@ EOS
27
27
 
28
28
  self.primary_key = "name"
29
29
 
30
-
31
30
  warn_unless_size 4
32
31
  end
@@ -22,6 +22,5 @@ EOS
22
22
 
23
23
  self.primary_key = "name"
24
24
 
25
-
26
25
  warn_unless_size 50
27
26
  end
@@ -23,6 +23,5 @@ EOS
23
23
 
24
24
  self.primary_key = "name"
25
25
 
26
-
27
26
  warn_unless_size 125
28
27
  end
@@ -35,8 +35,7 @@ EOS
35
35
  # Methods to calculate summary statistics from rail_records
36
36
  [:rail_passengers, :rail_passenger_distance, :rail_vehicle_distance, :rail_vehicle_time, :rail_electricity, :rail_diesel].each do |method|
37
37
  define_method method do
38
- attribute = method.to_s.split('rail_')[1].to_sym
39
- rail_records.sum(attribute) > 0 ? rail_records.sum(attribute) : nil
38
+ (sum = rail_records.sum(method.to_s.split('rail_')[1].to_sym)) > 0 ? sum : nil
40
39
  end
41
40
  end
42
41
 
@@ -50,7 +49,6 @@ EOS
50
49
  end
51
50
  end
52
51
 
53
-
54
52
  warn_if_nulls_except(
55
53
  :acronym,
56
54
  :duns_number
@@ -1,7 +1,7 @@
1
1
  NationalTransitDatabaseCompany.class_eval do
2
2
  data_miner do
3
3
  import "US transit companies from the National Transit Database",
4
- :url => 'https://docs.google.com/spreadsheet/pub?key=0AoQJbWqPrREqdHBTZC1GUzg5VEU4QW9NOUo3V1BJWUE&output=csv' do
4
+ :url => "#{Earth::DATA_DIR}/rail/ntd_companies.csv" do
5
5
  key 'id', :field_name => 'trs_id'
6
6
  store 'name', :nullify => true
7
7
  store 'acronym', :nullify => true
@@ -20,7 +20,6 @@ EOS
20
20
  def self.rail_modes
21
21
  where(:rail_mode => true)
22
22
  end
23
-
24
23
 
25
24
  warn_unless_size 14
26
25
  end
@@ -1,7 +1,7 @@
1
1
  NationalTransitDatabaseMode.class_eval do
2
2
  data_miner do
3
3
  import "National Transit Database modes",
4
- :url => 'https://docs.google.com/spreadsheet/pub?key=0AoQJbWqPrREqdGFTLVpMdFgwSTQzTTFuc2lIVUdfSHc&output=csv' do
4
+ :url => "#{Earth::DATA_DIR}/rail/ntd_modes.csv" do
5
5
  key 'code'
6
6
  store 'name', :nullify => true
7
7
  store 'rail_mode', :nullify => true
@@ -53,7 +53,6 @@ EOS
53
53
  where(:mode_code => NationalTransitDatabaseMode.rail_modes)
54
54
  end
55
55
 
56
-
57
56
  warn_if_nulls_except(
58
57
  :passenger_distance,
59
58
  :passenger_distance_units,
@@ -1,7 +1,7 @@
1
1
  NationalTransitDatabaseRecord.class_eval do
2
2
  data_miner do
3
3
  import "US National Transit Database service data",
4
- :url => 'https://docs.google.com/spreadsheet/pub?key=0AoQJbWqPrREqdF9Hbktvc3BMNDRWZHhDRU9uMVZfWVE&output=csv' do
4
+ :url => "#{Earth::DATA_DIR}/rail/ntd_service.csv" do
5
5
  key 'name', :synthesize => proc { |row| [row['trs_id'], row['mode_code'], row['service_code']].join(' ') }
6
6
  store 'company_id', :field_name => 'trs_id'
7
7
  store 'mode_code'
@@ -13,7 +13,7 @@ NationalTransitDatabaseRecord.class_eval do
13
13
  end
14
14
 
15
15
  import "US National Transit Database fuel consumption data",
16
- :url => 'https://docs.google.com/spreadsheet/pub?key=0AoQJbWqPrREqdDItVVR5NjA2Y3FCVjgza25Ccy0zS2c&output=csv' do
16
+ :url => "#{Earth::DATA_DIR}/rail/ntd_fuel_consumption.csv" do
17
17
  key 'name', :synthesize => proc { |row| [row['trs_id'], row['mode_code'], row['service_code']].join(' ') }
18
18
  store 'company_id', :field_name => 'trs_id'
19
19
  store 'mode_code'
@@ -14,6 +14,5 @@ EOS
14
14
 
15
15
  self.primary_key = "name"
16
16
 
17
-
18
17
  warn_unless_size 6
19
18
  end
@@ -1,16 +1,17 @@
1
+ require 'earth/rail/country_rail_class'
2
+ require 'earth/rail/country_rail_traction_class'
3
+
1
4
  RailClass.class_eval do
2
5
  data_miner do
3
- process "Ensure CountryRailClass, CountryRailTractionClass, and RailCompanyTractionClass are populated" do
6
+ process "Ensure CountryRailClass, and CountryRailTractionClass are populated" do
4
7
  CountryRailTractionClass.run_data_miner!
5
8
  CountryRailClass.run_data_miner!
6
- RailCompanyTractionClass.run_data_miner!
7
9
  end
8
10
 
9
- process "Derive rail class names from CountryRailClass, CountryRailTractionClass, and RailCompanyTractionClass" do
11
+ process "Derive rail class names from CountryRailClass and CountryRailTractionClass" do
10
12
  names = []
11
13
  names += CountryRailTractionClass.select("DISTINCT rail_class_name").map(&:rail_class_name)
12
14
  names += CountryRailClass.select("DISTINCT rail_class_name").map(&:rail_class_name)
13
- names += RailCompanyTractionClass.select("DISTINCT rail_class_name").map(&:rail_class_name)
14
15
  names.uniq.each do |name|
15
16
  RailClass.find_or_create_by_name(name)
16
17
  end
@@ -37,7 +37,6 @@ EOS
37
37
 
38
38
  belongs_to :country, :foreign_key => 'country_iso_3166_code'
39
39
 
40
-
41
40
  warn_if_nulls_except(
42
41
  :duns_number,
43
42
  :train_time,
@@ -25,6 +25,5 @@ EOS
25
25
 
26
26
  delegate :density, :density_units, :co2_emission_factor, :co2_emission_factor_units, :co2_biogenic_emission_factor, :co2_biogenic_emission_factor_units, :to => :fuel, :allow_nil => true
27
27
 
28
-
29
28
  warn_unless_size 1
30
29
  end