earth 0.11.10 → 0.11.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. data/Gemfile +4 -0
  2. data/Guardfile +35 -0
  3. data/README.markdown +94 -20
  4. data/Rakefile +4 -0
  5. data/earth.gemspec +14 -12
  6. data/lib/earth/air/aircraft.rb +2 -2
  7. data/lib/earth/air/aircraft_instance.rb +2 -2
  8. data/lib/earth/air/aircraft_instance_seat_class.rb +2 -2
  9. data/lib/earth/air/airline.rb +2 -2
  10. data/lib/earth/air/airport.rb +2 -2
  11. data/lib/earth/air/bts_aircraft.rb +2 -2
  12. data/lib/earth/air/flight_distance_class.rb +1 -1
  13. data/lib/earth/air/flight_distance_class_seat_class.rb +1 -1
  14. data/lib/earth/air/flight_seat_class.rb +1 -1
  15. data/lib/earth/air/flight_segment.rb +1 -1
  16. data/lib/earth/automobile/automobile_fuel.rb +1 -1
  17. data/lib/earth/automobile/automobile_make.rb +1 -1
  18. data/lib/earth/automobile/automobile_make_model.rb +1 -1
  19. data/lib/earth/automobile/automobile_make_model_year.rb +1 -1
  20. data/lib/earth/automobile/automobile_make_model_year_variant.rb +1 -1
  21. data/lib/earth/automobile/automobile_make_year.rb +1 -1
  22. data/lib/earth/automobile/automobile_make_year_fleet.rb +1 -1
  23. data/lib/earth/automobile/automobile_model.rb +1 -1
  24. data/lib/earth/automobile/automobile_size_class.rb +1 -1
  25. data/lib/earth/automobile/automobile_size_class_year.rb +1 -1
  26. data/lib/earth/automobile/automobile_type_fuel_control.rb +1 -1
  27. data/lib/earth/automobile/automobile_type_fuel_year.rb +1 -1
  28. data/lib/earth/automobile/automobile_type_fuel_year_age.rb +1 -1
  29. data/lib/earth/automobile/automobile_type_fuel_year_control.rb +1 -1
  30. data/lib/earth/automobile/automobile_type_year.rb +2 -2
  31. data/lib/earth/automobile/automobile_year.rb +1 -1
  32. data/lib/earth/bus/bus_class.rb +1 -1
  33. data/lib/earth/bus/bus_fuel.rb +2 -2
  34. data/lib/earth/bus/bus_fuel_control.rb +2 -2
  35. data/lib/earth/bus/bus_fuel_year_control.rb +2 -2
  36. data/lib/earth/computation/computation_carrier.rb +2 -2
  37. data/lib/earth/computation/computation_carrier_instance_class.rb +2 -2
  38. data/lib/earth/computation/computation_carrier_region.rb +2 -2
  39. data/lib/earth/conversions_ext.rb +26 -7
  40. data/lib/earth/diet/diet_class.rb +2 -2
  41. data/lib/earth/diet/food_group.rb +2 -2
  42. data/lib/earth/eia.rb +13 -13
  43. data/lib/earth/fuel/fuel.rb +22 -13
  44. data/lib/earth/fuel/fuel/data_miner.rb +36 -44
  45. data/lib/earth/fuel/fuel_price.rb +1 -1
  46. data/lib/earth/fuel/fuel_type.rb +2 -2
  47. data/lib/earth/fuel/fuel_year.rb +4 -2
  48. data/lib/earth/fuel/greenhouse_gas.rb +2 -2
  49. data/lib/earth/hospitality/commercial_building_energy_consumption_survey_response.rb +14 -5
  50. data/lib/earth/hospitality/commercial_building_energy_consumption_survey_response/data_miner.rb +22 -1
  51. data/lib/earth/hospitality/country_lodging_class.rb +3 -3
  52. data/lib/earth/hospitality/country_lodging_class/data_miner.rb +7 -5
  53. data/lib/earth/hospitality/lodging_class.rb +1 -1
  54. data/lib/earth/hospitality/lodging_property.rb +8 -8
  55. data/lib/earth/industry/cbecs_energy_intensity.rb +59 -6
  56. data/lib/earth/industry/cbecs_energy_intensity/data_miner.rb +266 -69
  57. data/lib/earth/industry/industry.rb +1 -1
  58. data/lib/earth/industry/industry_product.rb +2 -2
  59. data/lib/earth/industry/industry_product_line.rb +2 -2
  60. data/lib/earth/industry/industry_sector.rb +2 -2
  61. data/lib/earth/industry/mecs_energy.rb +26 -15
  62. data/lib/earth/industry/mecs_energy/data_miner.rb +39 -23
  63. data/lib/earth/industry/mecs_ratio.rb +13 -10
  64. data/lib/earth/industry/mecs_ratio/data_miner.rb +14 -14
  65. data/lib/earth/industry/merchant.rb +2 -2
  66. data/lib/earth/industry/merchant_category.rb +2 -2
  67. data/lib/earth/industry/merchant_category_industry.rb +2 -2
  68. data/lib/earth/industry/product_line.rb +2 -2
  69. data/lib/earth/industry/product_line_industry_product.rb +2 -2
  70. data/lib/earth/industry/sector.rb +2 -2
  71. data/lib/earth/locality/census_division.rb +2 -2
  72. data/lib/earth/locality/census_division/data_miner.rb +4 -14
  73. data/lib/earth/locality/census_region.rb +2 -2
  74. data/lib/earth/locality/climate_division.rb +1 -17
  75. data/lib/earth/locality/country.rb +14 -28
  76. data/lib/earth/locality/country/data_miner.rb +8 -2
  77. data/lib/earth/locality/egrid_country.rb +1 -1
  78. data/lib/earth/locality/egrid_region.rb +4 -1
  79. data/lib/earth/locality/egrid_region/data_miner.rb +4 -1
  80. data/lib/earth/locality/egrid_subregion.rb +1 -1
  81. data/lib/earth/locality/egrid_subregion/data_miner.rb +1 -0
  82. data/lib/earth/locality/petroleum_administration_for_defense_district.rb +3 -3
  83. data/lib/earth/locality/state.rb +2 -7
  84. data/lib/earth/locality/zip_code.rb +1 -1
  85. data/lib/earth/pet/breed.rb +2 -2
  86. data/lib/earth/pet/breed_gender.rb +2 -2
  87. data/lib/earth/pet/gender.rb +2 -2
  88. data/lib/earth/pet/species.rb +2 -2
  89. data/lib/earth/pet/species/data_miner.rb +0 -9
  90. data/lib/earth/rail/country_rail_class.rb +1 -1
  91. data/lib/earth/rail/country_rail_traction.rb +1 -1
  92. data/lib/earth/rail/country_rail_traction_class.rb +1 -1
  93. data/lib/earth/rail/national_transit_database_company.rb +2 -2
  94. data/lib/earth/rail/national_transit_database_mode.rb +2 -2
  95. data/lib/earth/rail/national_transit_database_record.rb +2 -2
  96. data/lib/earth/rail/national_transit_database_record/data_miner.rb +12 -33
  97. data/lib/earth/rail/rail_class.rb +1 -1
  98. data/lib/earth/rail/rail_company.rb +1 -1
  99. data/lib/earth/rail/rail_company_traction.rb +1 -1
  100. data/lib/earth/rail/rail_company_traction_class.rb +1 -1
  101. data/lib/earth/rail/rail_fuel.rb +1 -1
  102. data/lib/earth/rail/rail_traction.rb +1 -1
  103. data/lib/earth/residence/air_conditioner_use.rb +2 -2
  104. data/lib/earth/residence/clothes_machine_use.rb +2 -2
  105. data/lib/earth/residence/dishwasher_use.rb +2 -2
  106. data/lib/earth/residence/residence_appliance.rb +2 -2
  107. data/lib/earth/residence/residence_class.rb +2 -2
  108. data/lib/earth/residence/residence_fuel_price.rb +2 -2
  109. data/lib/earth/residence/residence_fuel_price/data_miner.rb +0 -5
  110. data/lib/earth/residence/residence_fuel_type.rb +2 -2
  111. data/lib/earth/residence/residential_energy_consumption_survey_response.rb +3 -3
  112. data/lib/earth/residence/residential_energy_consumption_survey_response/data_miner.rb +0 -5
  113. data/lib/earth/residence/urbanity.rb +2 -2
  114. data/lib/earth/shipping/carrier.rb +3 -2
  115. data/lib/earth/shipping/carrier/data_miner.rb +1 -0
  116. data/lib/earth/shipping/carrier_mode.rb +2 -2
  117. data/lib/earth/shipping/shipment_mode.rb +2 -2
  118. data/lib/earth/version.rb +1 -1
  119. data/spec/earth/air/aircraft_spec.rb +421 -0
  120. data/spec/earth/fuel/fuel_spec.rb +35 -0
  121. data/spec/earth/hospitality/lodging_fuel_use_equation_spec.rb +96 -0
  122. data/spec/earth/industry/cbecs_energy_intensity_spec.rb +102 -0
  123. data/spec/earth/industry/mecs_energy_spec.rb +36 -44
  124. data/spec/earth/industry/mecs_ratio_spec.rb +24 -17
  125. data/spec/earth/locality/country_spec.rb +0 -9
  126. data/spec/spec_helper.rb +8 -3
  127. data/spec/support/integration.rb +17 -0
  128. data/vendor/geokit-rails/init.rb +2 -1
  129. data/vendor/geokit-rails/lib/geokit-rails.rb +1 -0
  130. metadata +63 -36
  131. data/lib/earth/hospitality/lodging_fuel_use_equation.rb +0 -26
  132. data/lib/earth/hospitality/lodging_fuel_use_equation/data_miner.rb +0 -20
  133. data/test/test_aircraft_match.rb +0 -732
data/Gemfile CHANGED
@@ -2,6 +2,10 @@ source :rubygems
2
2
 
3
3
  gemspec :path => '.'
4
4
 
5
+ group :development do
6
+ gem 'guard'
7
+ end
8
+
5
9
  if RUBY_VERSION < "1.9"
6
10
  gem 'fastercsv'
7
11
  end
data/Guardfile ADDED
@@ -0,0 +1,35 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', :version => 2 do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+
9
+ # Rails example
10
+ watch(%r{^spec/.+_spec\.rb$})
11
+ watch(%r{^app/models/(.+)\.rb$}) { |m| "spec/models/#{m[1]}_spec.rb" }
12
+ watch(%r{^app/controllers(.+)\.rb$}) { |m| "spec/controllers/#{m[1]}_spec.rb" }
13
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
14
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
15
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
16
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
17
+ watch('spec/spec_helper.rb') { "spec" }
18
+ watch('config/routes.rb') { "spec/routing" }
19
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
20
+ # Capybara request specs
21
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
22
+ end
23
+
24
+
25
+ guard 'bundler' do
26
+ watch('Gemfile')
27
+ # Uncomment next line if Gemfile contain `gemspec' command
28
+ # watch(/^.+\.gemspec/)
29
+ end
30
+
31
+ guard 'cucumber' do
32
+ watch(%r{^features/.+\.feature$})
33
+ watch(%r{^features/support/.+$}) { 'features' }
34
+ watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
35
+ end
data/README.markdown CHANGED
@@ -2,47 +2,121 @@
2
2
 
3
3
  Earth is a collection of data models that represent various things found here on Earth, such as pet breeds, kinds of rail travel, zip codes, and Petroleum Administration for Defense Districts.
4
4
 
5
- The data that these models represent can be pulled from http://data.brighterplanet.com
5
+ The data that these models represent can be pulled from preconfigured authoritative sources.
6
6
 
7
7
  ## Usage
8
8
 
9
- require 'earth'
10
- Earth.init :automobile, :locality
11
- ft = AutomobileFuel.first
12
- ...
9
+ ``` ruby
10
+ require 'earth'
11
+ Earth.init :automobile, :locality
12
+ ft = AutomobileFuel.first
13
+ # ...
14
+ ```
13
15
 
14
16
  `Earth.init` loads desired "data domains" as well as any supporting classes and plugins that each data model needs. A "data domain" is a grouping of related data models. For instance, all automobile-related data is in the `:automobile` domain.
15
17
 
18
+ ### Domains
19
+
20
+ <table>
21
+ <thead>
22
+ <tr>
23
+ <th>Domain</th>
24
+ <th>Models</th>
25
+ </tr>
26
+ </thead>
27
+ <tbody>
28
+ <tr>
29
+ <td><a href="https://github.com/brighterplanet/earth/tree/master/lib/earth/air"><code>:air</code></a></td>
30
+ <td>Aircraft, Airline, Airport ...</td>
31
+ </tr>
32
+ <tr>
33
+ <td><a href="https://github.com/brighterplanet/earth/tree/master/lib/earth/automobile"><code>:automobile</code></a></td>
34
+ <td>AutomobileFuel, AutomobileMake, AutomobileModel ...</td>
35
+ </tr>
36
+ <tr>
37
+ <td><a href="https://github.com/brighterplanet/earth/tree/master/lib/earth/bus"><code>:bus</code></a></td>
38
+ <td>BusClass, BusFuel ...</td>
39
+ </tr>
40
+ <tr>
41
+ <td><a href="https://github.com/brighterplanet/earth/tree/master/lib/earth/computation"><code>:computation</code></a></td>
42
+ <td>ComputationCarrier, ComputationCarrierInstanceClass ...</td>
43
+ </tr>
44
+ <tr>
45
+ <td><a href="https://github.com/brighterplanet/earth/tree/master/lib/earth/diet"><code>:diet</code></a></td>
46
+ <td>DietClass, FoodGroup ...</td>
47
+ </tr>
48
+ <tr>
49
+ <td><a href="https://github.com/brighterplanet/earth/tree/master/lib/earth/fuel"><code>:fuel</code></a></td>
50
+ <td>Fuel, FuelPrice, GreenhouseGas ...</td>
51
+ </tr>
52
+ <tr>
53
+ <td><a href="https://github.com/brighterplanet/earth/tree/master/lib/earth/hospitality"><code>:hospitality</code></a></td>
54
+ <td>LodgingClass, CommercialBuildingEnergyConsumptionSurveyResponse ...</td>
55
+ </tr>
56
+ <tr>
57
+ <td><a href="https://github.com/brighterplanet/earth/tree/master/lib/earth/industry"><code>:industry</code></a></td>
58
+ <td>Industry, CbecsEnergyIntensity ...</td>
59
+ </tr>
60
+ <tr>
61
+ <td><a href="https://github.com/brighterplanet/earth/tree/master/lib/earth/locality"><code>:locality</code></a></td>
62
+ <td>CensusDivision, Country, ZipCode ...</td>
63
+ </tr>
64
+ <tr>
65
+ <td><a href="https://github.com/brighterplanet/earth/tree/master/lib/earth/pet"><code>:pet</code></a></td>
66
+ <td>Breed, Gender, Species ...</td>
67
+ </tr>
68
+ <tr>
69
+ <td><a href="https://github.com/brighterplanet/earth/tree/master/lib/earth/rail"><code>:rail</code></a></td>
70
+ <td>RailClass, RailFuel, RailCompany ...</td>
71
+ </tr>
72
+ <tr>
73
+ <td><a href="https://github.com/brighterplanet/earth/tree/master/lib/earth/residence"><code>:residence</code></a></td>
74
+ <td>Urbanity, ResidenceClass, AirConditionerUse</td>
75
+ </tr>
76
+ <tr>
77
+ <td><a href="https://github.com/brighterplanet/earth/tree/master/lib/earth/shipping"><code>:shipping</code></a></td>
78
+ <td>Carrier, ShipmentMode ...</td>
79
+ </tr>
80
+ </tbody>
81
+ </table>
82
+
83
+
16
84
  ### Data storage
17
85
 
18
86
  You can store Earth data in any relational database. On your very first run, you will need to create the tables for data each model. This is done using minirecord with the `apply_schemas` option:
19
87
 
20
- require 'activerecord'
21
- ActiveRecord::Base.establish_connection :adapter => ... # Not needed if using Rails
88
+ ``` ruby
89
+ require 'activerecord'
90
+ ActiveRecord::Base.establish_connection :adapter => ... # Not needed if using Rails
22
91
 
23
- require 'earth'
24
- Earth.init :all, :apply_schemas => true
92
+ require 'earth'
93
+ Earth.init :all, :apply_schemas => true
94
+ ```
25
95
 
26
96
  ### Pulling data from data.brighterplanet.com
27
97
 
28
- By default, Earth will pull data from data.brighterplanet.com. Simply call `run_data_miner!` on whichever data model class you need. If there are any Earth classes that the chosen class depends on, they will be downloaded as well automatically:
98
+ By default, Earth will pull data from [data.brighterplanet.com](http://data.brighterplanet.com), which continuously (and transparently) refreshes its data from authoritative sources. Simply call `#run_data_miner!` on whichever data model class you need. If there are any Earth classes that the chosen class depends on, they will be downloaded as well automatically:
29
99
 
30
- require 'earth'
31
- Earth.init :locality
32
- ZipCode.run_data_miner!
100
+ ``` ruby
101
+ require 'earth'
102
+ Earth.init :locality
103
+ ZipCode.run_data_miner!
104
+ ```
33
105
 
34
106
  ### Pulling data from the original sources
35
107
 
36
- If you'd like to pull data directly from the source, e.g. Automobile data from EPA's sources, simply require the data\_miner file for the desired domain:
108
+ If you'd like to bypass the [data.brighterplanet.com](http://data.brighterplanet.com) proxy and pull data directly from authoritative sources (*e.g.,* automobile data from EPA), simply require the `data\_miner` file for the desired domain:
37
109
 
38
- require 'earth'
39
- Earth.init :automobile
110
+ ``` ruby
111
+ require 'earth'
112
+ Earth.init :automobile
40
113
 
41
- require 'earth/automobile/data_miner'
42
- AutomobileMake.run_data_miner!
114
+ require 'earth/automobile/data_miner'
115
+ AutomobileMake.run_data_miner!
116
+ ```
43
117
 
44
118
  ## Collaboration cycle
45
- Brighter Planet vigorously encourages collaborative improvement of its emitter libraries. Collaboration requires a (free) GitHub account.
119
+ Brighter Planet vigorously encourages collaborative improvement.
46
120
 
47
121
  ### You
48
122
  1. Fork the earth repository on GitHub.
@@ -57,4 +131,4 @@ Brighter Planet vigorously encourages collaborative improvement of its emitter l
57
131
  1. Ensure tests pass.
58
132
  1. Review changes for scientific accuracy.
59
133
  1. Merge changes to master repository and publish.
60
- 1. Direct production environment to use new emitter version.
134
+ 1. Direct production environment to use new library version.
data/Rakefile CHANGED
@@ -6,6 +6,10 @@ require 'bueller'
6
6
  Bueller::Tasks.new
7
7
 
8
8
  task :console do
9
+ require 'earth'
10
+ logger = Logger.new('log/test.log')
11
+ DataMiner.logger = ActiveRecord::Base.logger = logger
12
+ ActiveRecord::Base.establish_connection :adapter => 'postgresql', :database => 'test_earth'
9
13
  Earth.init :all
10
14
 
11
15
  require 'irb'
data/earth.gemspec CHANGED
@@ -5,7 +5,7 @@ require "earth/version"
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "earth"
7
7
  s.version = Earth::VERSION
8
- s.date = "2012-01-26"
8
+ s.date = "2012-02-15"
9
9
  s.platform = Gem::Platform::RUBY
10
10
  s.authors = ["Seamus Abshere", "Derek Kastner", "Andy Rossmeissl"]
11
11
  s.email = %q{andy@rossmeissl.net}
@@ -27,26 +27,28 @@ Gem::Specification.new do |s|
27
27
  s.require_paths = ["lib"]
28
28
  s.rubygems_version = %q{1.3.7}
29
29
 
30
- s.add_runtime_dependency 'data_miner', '>=1.3'
31
- s.add_runtime_dependency 'to_regexp'
30
+ s.add_runtime_dependency 'activerecord'
31
+ s.add_runtime_dependency 'activesupport'
32
32
  s.add_runtime_dependency 'cohort_scope'
33
- s.add_runtime_dependency 'table_warnings', '>=0.0.6'
34
- s.add_runtime_dependency 'remote_table', '>=1.3.0'
33
+ s.add_runtime_dependency 'conversions'
34
+ s.add_runtime_dependency 'data_miner', '>=1.3'
35
35
  s.add_runtime_dependency 'falls_back_on'
36
36
  s.add_runtime_dependency 'fixed_width-multibyte'
37
- s.add_runtime_dependency 'geokit'
38
37
  s.add_runtime_dependency 'fuzzy_match', '>=1.1.0'
39
- s.add_runtime_dependency 'weighted_average', '>=1.0.2'
38
+ s.add_runtime_dependency 'geokit'
40
39
  s.add_runtime_dependency 'mini_record-compat' # need https://github.com/DAddYE/mini_record/pull/7
41
- s.add_runtime_dependency 'activesupport'
42
- s.add_runtime_dependency 'activerecord'
43
- s.add_development_dependency 'bundler'
40
+ s.add_runtime_dependency 'remote_table', '>=1.3.0'
41
+ s.add_runtime_dependency 'table_warnings', '>=0.0.6'
42
+ s.add_runtime_dependency 'to_regexp'
43
+ s.add_runtime_dependency 'weighted_average', '>=1.0.2'
44
44
  s.add_development_dependency 'bueller'
45
+ s.add_development_dependency 'bundler'
46
+ s.add_development_dependency 'charisma'
45
47
  s.add_development_dependency 'cucumber'
48
+ s.add_development_dependency 'mysql' # for bin/earth_tester.rb
49
+ s.add_development_dependency 'pg'
46
50
  s.add_development_dependency 'rake'
47
51
  s.add_development_dependency 'rdoc'
48
52
  s.add_development_dependency 'rspec'
49
53
  s.add_development_dependency 'sqlite3-ruby'
50
- s.add_development_dependency 'mysql' # for bin/earth_tester.rb
51
- s.add_development_dependency 'pg'
52
54
  end
@@ -1,5 +1,5 @@
1
1
  class Aircraft < ActiveRecord::Base
2
- set_primary_key :icao_code
2
+ self.primary_key = "icao_code"
3
3
 
4
4
  # Fuzzy association with FlightSegment
5
5
  cache_fuzzy_match_with :flight_segments, :primary_key => :description, :foreign_key => :aircraft_description
@@ -141,4 +141,4 @@ class Aircraft < ActiveRecord::Base
141
141
  col :b, :type => :float
142
142
  col :b_units
143
143
  col :fuel_use_specificity
144
- end
144
+ end
@@ -1,5 +1,5 @@
1
1
  class AircraftInstance < ActiveRecord::Base
2
- set_primary_key :id
2
+ self.primary_key = "id"
3
3
 
4
4
  col :id
5
5
  col :registration
@@ -8,4 +8,4 @@ class AircraftInstance < ActiveRecord::Base
8
8
  col :airline_name
9
9
  add_index :registration
10
10
  add_index :serial_number
11
- end
11
+ end
@@ -1,5 +1,5 @@
1
1
  class AircraftInstanceSeatClass < ActiveRecord::Base
2
- set_primary_key :row_hash
2
+ self.primary_key = "row_hash"
3
3
 
4
4
  col :row_hash
5
5
  col :seat_class_name
@@ -10,4 +10,4 @@ class AircraftInstanceSeatClass < ActiveRecord::Base
10
10
  col :seat_width, :type => :float
11
11
  col :seat_width_units
12
12
  add_index :aircraft_instance_id
13
- end
13
+ end
@@ -1,8 +1,8 @@
1
1
  class Airline < ActiveRecord::Base
2
- set_primary_key :name
2
+ self.primary_key = "name"
3
3
 
4
4
  col :name
5
5
  col :bts_code
6
6
  col :iata_code
7
7
  col :icao_code
8
- end
8
+ end
@@ -2,7 +2,7 @@ require ::File.join(Earth.vendor_dir, 'geokit-rails', 'lib', 'geokit-rails')
2
2
  require 'earth/locality'
3
3
 
4
4
  class Airport < ActiveRecord::Base
5
- set_primary_key :iata_code
5
+ self.primary_key = "iata_code"
6
6
 
7
7
  belongs_to :country, :foreign_key => 'country_iso_3166_code', :primary_key => 'iso_3166_code'
8
8
 
@@ -17,4 +17,4 @@ class Airport < ActiveRecord::Base
17
17
  col :country_iso_3166_code
18
18
  col :latitude, :type => :float
19
19
  col :longitude, :type => :float
20
- end
20
+ end
@@ -1,5 +1,5 @@
1
1
  class BtsAircraft < ActiveRecord::Base
2
- set_primary_key :bts_code
2
+ self.primary_key = "bts_code"
3
3
  col :bts_code
4
4
  col :description
5
- end
5
+ end
@@ -1,5 +1,5 @@
1
1
  class FlightDistanceClass < ActiveRecord::Base
2
- set_primary_key :name
2
+ self.primary_key = "name"
3
3
 
4
4
  def self.find_by_distance(distance)
5
5
  first :conditions => arel_table[:min_distance].lteq(distance.to_f).and(arel_table[:max_distance].gt(distance.to_f))
@@ -1,5 +1,5 @@
1
1
  class FlightDistanceClassSeatClass < ActiveRecord::Base
2
- set_primary_key :name
2
+ self.primary_key = "name"
3
3
 
4
4
  falls_back_on :name => 'fallback',
5
5
  :multiplier => 1.0
@@ -1,5 +1,5 @@
1
1
  class FlightSeatClass < ActiveRecord::Base
2
- set_primary_key :name
2
+ self.primary_key = "name"
3
3
 
4
4
  col :name
5
5
  end
@@ -1,7 +1,7 @@
1
1
  require 'earth/locality'
2
2
 
3
3
  class FlightSegment < ActiveRecord::Base
4
- set_primary_key :row_hash
4
+ self.primary_key = "row_hash"
5
5
 
6
6
  extend CohortScope
7
7
  self.minimum_cohort_size = 1
@@ -1,7 +1,7 @@
1
1
  require 'earth/fuel'
2
2
 
3
3
  class AutomobileFuel < ActiveRecord::Base
4
- set_primary_key :name
4
+ self.primary_key = "name"
5
5
 
6
6
  has_many :type_fuel_year_ages, :class_name => 'AutomobileTypeFuelYearAge', :foreign_key => 'fuel_common_name', :primary_key => 'distance_key'
7
7
  has_many :type_fuel_years, :class_name => 'AutomobileTypeFuelYear', :foreign_key => 'fuel_common_name', :primary_key => 'ef_key'
@@ -1,6 +1,6 @@
1
1
  require 'earth/fuel'
2
2
  class AutomobileMake < ActiveRecord::Base
3
- set_primary_key :name
3
+ self.primary_key = "name"
4
4
 
5
5
  col :name
6
6
  col :fuel_efficiency, :type => :float
@@ -1,6 +1,6 @@
1
1
  require 'earth/fuel'
2
2
  class AutomobileMakeModel < ActiveRecord::Base
3
- set_primary_key :name
3
+ self.primary_key = "name"
4
4
 
5
5
  col :name # make + model
6
6
  col :make_name
@@ -1,6 +1,6 @@
1
1
  require 'earth/fuel'
2
2
  class AutomobileMakeModelYear < ActiveRecord::Base
3
- set_primary_key :name
3
+ self.primary_key = "name"
4
4
 
5
5
  # Need this so Automobile and AutomobileTrip can do characteristics[:make_model_year].automobile_fuel
6
6
  belongs_to :automobile_fuel, :foreign_key => 'fuel_code', :primary_key => 'code'
@@ -1,6 +1,6 @@
1
1
  require 'earth/fuel'
2
2
  class AutomobileMakeModelYearVariant < ActiveRecord::Base
3
- set_primary_key :row_hash
3
+ self.primary_key = "row_hash"
4
4
 
5
5
  # It looks like synthesizing a unique name would require including pretty much every column from the FEGs
6
6
  # (e.g. creeper gear, automatic vs automatic with lockup, feedback fuel system, etc.)
@@ -1,6 +1,6 @@
1
1
  require 'earth/fuel'
2
2
  class AutomobileMakeYear < ActiveRecord::Base
3
- set_primary_key :name
3
+ self.primary_key = "name"
4
4
 
5
5
  col :name
6
6
  col :make_name
@@ -1,6 +1,6 @@
1
1
  require 'earth/fuel'
2
2
  class AutomobileMakeYearFleet < ActiveRecord::Base
3
- set_primary_key :name
3
+ self.primary_key = "name"
4
4
 
5
5
  col :name
6
6
  col :make_name
@@ -1,6 +1,6 @@
1
1
  require 'earth/fuel'
2
2
  class AutomobileModel < ActiveRecord::Base
3
- set_primary_key :name
3
+ self.primary_key = "name"
4
4
 
5
5
  col :name
6
6
  end
@@ -1,6 +1,6 @@
1
1
  require 'earth/fuel'
2
2
  class AutomobileSizeClass < ActiveRecord::Base
3
- set_primary_key :name
3
+ self.primary_key = "name"
4
4
 
5
5
  # FIXME TODO clean up size class in MakeModelYearVariant, derive size class for MakeModelYear, and calculate this from MakeModelYear
6
6
  falls_back_on :hybrid_fuel_efficiency_city_multiplier => 1.651, # https://brighterplanet.sifterapp.com/issue/667