earth 0.7.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. data/certification_changelog.markdown +21 -0
  2. data/lib/earth/air.rb +0 -2
  3. data/lib/earth/air/aircraft.rb +77 -27
  4. data/lib/earth/air/aircraft/data_miner.rb +12 -19
  5. data/lib/earth/air/aircraft_instance.rb +2 -0
  6. data/lib/earth/air/aircraft_instance_seat_class.rb +1 -0
  7. data/lib/earth/air/airport/data_miner.rb +1 -1
  8. data/lib/earth/air/data_miner.rb +0 -2
  9. data/lib/earth/air/flight_distance_class.rb +2 -3
  10. data/lib/earth/air/flight_distance_class/data_miner.rb +0 -13
  11. data/lib/earth/air/flight_distance_class_seat_class.rb +3 -2
  12. data/lib/earth/air/flight_seat_class.rb +0 -6
  13. data/lib/earth/air/flight_seat_class/data_miner.rb +0 -7
  14. data/lib/earth/air/flight_segment.rb +47 -53
  15. data/lib/earth/air/flight_segment/data_miner.rb +2 -2
  16. data/lib/earth/automobile.rb +4 -3
  17. data/lib/earth/automobile/automobile_fuel.rb +56 -119
  18. data/lib/earth/automobile/automobile_fuel/data_miner.rb +17 -4
  19. data/lib/earth/automobile/automobile_make.rb +1 -16
  20. data/lib/earth/automobile/automobile_make/data_miner.rb +25 -25
  21. data/lib/earth/automobile/automobile_make_model.rb +0 -26
  22. data/lib/earth/automobile/automobile_make_model/data_miner.rb +12 -13
  23. data/lib/earth/automobile/automobile_make_model_year.rb +6 -37
  24. data/lib/earth/automobile/automobile_make_model_year/data_miner.rb +34 -18
  25. data/lib/earth/automobile/automobile_make_model_year_variant.rb +27 -49
  26. data/lib/earth/automobile/automobile_make_model_year_variant/data_miner.rb +111 -140
  27. data/lib/earth/automobile/automobile_make_year.rb +0 -12
  28. data/lib/earth/automobile/automobile_make_year/data_miner.rb +22 -23
  29. data/lib/earth/automobile/automobile_make_year_fleet.rb +11 -0
  30. data/lib/earth/automobile/{automobile_make_fleet_year → automobile_make_year_fleet}/data_miner.rb +1 -2
  31. data/lib/earth/automobile/automobile_model.rb +5 -0
  32. data/lib/earth/automobile/automobile_model/data_miner.rb +19 -0
  33. data/lib/earth/automobile/automobile_size_class.rb +1 -0
  34. data/lib/earth/automobile/automobile_size_class/data_miner.rb +30 -4
  35. data/lib/earth/automobile/automobile_type_fuel_year.rb +1 -1
  36. data/lib/earth/automobile/automobile_type_fuel_year/data_miner.rb +30 -19
  37. data/lib/earth/automobile/automobile_type_fuel_year_age.rb +0 -3
  38. data/lib/earth/automobile/automobile_type_fuel_year_age/data_miner.rb +13 -15
  39. data/lib/earth/automobile/automobile_type_fuel_year_control.rb +0 -4
  40. data/lib/earth/automobile/automobile_type_fuel_year_control/data_miner.rb +0 -8
  41. data/lib/earth/automobile/automobile_type_year.rb +2 -1
  42. data/lib/earth/automobile/automobile_type_year/data_miner.rb +12 -10
  43. data/lib/earth/automobile/automobile_year.rb +5 -0
  44. data/lib/earth/automobile/automobile_year/data_miner.rb +15 -0
  45. data/lib/earth/automobile/data_miner.rb +5 -3
  46. data/lib/earth/automobile/dependencies.txt +45 -0
  47. data/lib/earth/bus/bus_class.rb +1 -87
  48. data/lib/earth/bus/bus_class/data_miner.rb +0 -1
  49. data/lib/earth/bus/bus_fuel/data_miner.rb +12 -19
  50. data/lib/earth/bus/bus_fuel_control/data_miner.rb +8 -12
  51. data/lib/earth/conversions_ext.rb +1 -0
  52. data/lib/earth/fuel/fuel/data_miner.rb +28 -38
  53. data/lib/earth/fuel/fuel_year/data_miner.rb +36 -47
  54. data/lib/earth/hospitality/lodging_class/data_miner.rb +12 -6
  55. data/lib/earth/locality.rb +1 -0
  56. data/lib/earth/locality/country.rb +1 -1
  57. data/lib/earth/locality/country/data_miner.rb +36 -28
  58. data/lib/earth/locality/data_miner.rb +1 -0
  59. data/lib/earth/locality/egrid_subregion/data_miner.rb +19 -14
  60. data/lib/earth/locality/urbanity/data_miner.rb +1 -3
  61. data/lib/earth/locality/zip_code/data_miner.rb +1 -1
  62. data/lib/earth/rail/national_transit_database_record/data_miner.rb +10 -14
  63. data/lib/earth/rail/rail_fuel.rb +2 -6
  64. data/lib/earth/residence/air_conditioner_use/data_miner.rb +1 -3
  65. data/lib/earth/residence/clothes_machine_use/data_miner.rb +1 -3
  66. data/lib/earth/residence/dishwasher_use/data_miner.rb +1 -3
  67. data/lib/earth/residence/residence_class/data_miner.rb +1 -3
  68. data/lib/earth/residence/residential_energy_consumption_survey_response/data_miner.rb +3 -1
  69. data/lib/earth/utils.rb +15 -5
  70. data/lib/earth/version.rb +1 -1
  71. data/spec/earth_spec.rb +4 -4
  72. metadata +9 -11
  73. data/features/automobile_type_fuel_age.feature +0 -55
  74. data/lib/earth/air/aircraft_class.rb +0 -59
  75. data/lib/earth/air/aircraft_class/data_miner.rb +0 -14
  76. data/lib/earth/air/aircraft_fuel_use_equation.rb +0 -33
  77. data/lib/earth/air/aircraft_fuel_use_equation/data_miner.rb +0 -13
  78. data/lib/earth/automobile/automobile_make_fleet_year.rb +0 -46
  79. data/lib/earth/automobile/automobile_type_fuel_age.rb +0 -65
  80. data/lib/earth/automobile/automobile_type_fuel_age/data_miner.rb +0 -149
@@ -14,3 +14,4 @@ require 'earth/locality/zip_code'
14
14
 
15
15
  require 'earth/automobile'
16
16
  require 'earth/residence'
17
+ require 'earth/rail'
@@ -33,7 +33,7 @@ class Country < ActiveRecord::Base
33
33
 
34
34
  col :iso_3166_code
35
35
  col :name
36
- col :automobile_urbanity, :type => :float
36
+ col :automobile_urbanity, :type => :float # float from 0 to 1
37
37
  col :automobile_fuel_efficiency, :type => :float
38
38
  col :automobile_fuel_efficiency_units
39
39
  col :automobile_city_speed, :type => :float
@@ -31,46 +31,35 @@ Country.class_eval do
31
31
 
32
32
  # FIXME TODO eventually need to do this for all countries
33
33
  process "Derive US average automobile fuel efficiency from AutomobileTypeFuelYear" do
34
- scope = AutomobileTypeFuelYear.where(:year => AutomobileTypeFuelYear.maximum(:year))
35
- fe = scope.sum(:total_travel).to_f / scope.sum(:fuel_consumption)
36
- units = scope.first.total_travel_units + '_per_' + scope.first.fuel_consumption_units.singularize
37
-
38
- connection.execute %{
39
- UPDATE countries
40
- SET automobile_fuel_efficiency = #{fe},
41
- automobile_fuel_efficiency_units = '#{units}'
42
- WHERE iso_3166_code = 'US'
43
- }
34
+ fuel_years = AutomobileTypeFuelYear.where(:year => AutomobileTypeFuelYear.maximum(:year))
35
+ where(:iso_3166_code => 'US').update_all(
36
+ :automobile_fuel_efficiency => (fuel_years.sum(:total_travel).to_f / fuel_years.sum(:fuel_consumption)),
37
+ :automobile_fuel_efficiency_units => (fuel_years.first.total_travel_units + '_per_' + fuel_years.first.fuel_consumption_units.singularize)
38
+ )
44
39
  end
45
40
 
46
41
  process "Convert automobile city speed from miles per hour to kilometres per hour" do
47
42
  conversion_factor = 1.miles.to(:kilometres)
48
- connection.execute %{
49
- UPDATE countries
50
- SET automobile_city_speed = 1.0 * automobile_city_speed * #{conversion_factor},
51
- automobile_city_speed_units = 'kilometres_per_hour'
52
- WHERE automobile_city_speed_units = 'miles_per_hour'
53
- }
43
+ where(:automobile_city_speed_units => 'miles_per_hour').update_all(%{
44
+ automobile_city_speed = 1.0 * automobile_city_speed * #{conversion_factor},
45
+ automobile_city_speed_units = 'kilometres_per_hour'
46
+ })
54
47
  end
55
48
 
56
49
  process "Convert automobile highway speed from miles per hour to kilometres per hour" do
57
50
  conversion_factor = 1.miles.to(:kilometres)
58
- connection.execute %{
59
- UPDATE countries
60
- SET automobile_highway_speed = 1.0 * automobile_highway_speed * #{conversion_factor},
61
- automobile_highway_speed_units = 'kilometres_per_hour'
62
- WHERE automobile_highway_speed_units = 'miles_per_hour'
63
- }
51
+ where(:automobile_highway_speed_units => 'miles_per_hour').update_all(%{
52
+ automobile_highway_speed = 1.0 * automobile_highway_speed * #{conversion_factor},
53
+ automobile_highway_speed_units = 'kilometres_per_hour'
54
+ })
64
55
  end
65
56
 
66
57
  process "Convert automobile trip distance from miles to kilometres" do
67
58
  conversion_factor = 1.miles.to(:kilometres)
68
- connection.execute %{
69
- UPDATE countries
70
- SET automobile_trip_distance = 1.0 * automobile_trip_distance * #{conversion_factor},
71
- automobile_trip_distance_units = 'kilometres'
72
- WHERE automobile_trip_distance_units = 'miles'
73
- }
59
+ where(:automobile_trip_distance_units => 'miles').update_all(%{
60
+ automobile_trip_distance = 1.0 * automobile_trip_distance * #{conversion_factor},
61
+ automobile_trip_distance_units = 'kilometres'
62
+ })
74
63
  end
75
64
 
76
65
  process "Ensure RailCompany is populated" do
@@ -98,6 +87,25 @@ Country.class_eval do
98
87
  store 'rail_trip_co2_emission_factor', :units_field_name => 'rail_trip_co2_emission_factor_units'
99
88
  end
100
89
 
90
+ process "Ensure RailFuel is populated" do
91
+ RailFuel.run_data_miner!
92
+ end
93
+
94
+ process "Unit conversion for European rail diesel intensity" do
95
+ diesel = RailFuel.find_by_name("diesel")
96
+ where(:rail_trip_diesel_intensity_units => 'grams_per_passenger_kilometre').update_all(%{
97
+ rail_trip_diesel_intensity = 1.0 * rail_trip_diesel_intensity / 1000.0 / #{diesel.density},
98
+ rail_trip_diesel_intensity_units = 'litres_per_passenger_kilometre'
99
+ })
100
+ end
101
+
102
+ process "Unit conversion for European rail co2 emission factor" do
103
+ where(:rail_trip_co2_emission_factor_units => 'grams_per_passenger_kilometre').update_all(%{
104
+ rail_trip_co2_emission_factor = 1.0 * rail_trip_co2_emission_factor / 1000.0,
105
+ rail_trip_co2_emission_factor_units = 'kilograms_per_passenger_kilometre'
106
+ })
107
+ end
108
+
101
109
  process "Derive US rail fuel and emission data from RailCompany" do
102
110
  country = Country.united_states
103
111
  country.rail_trip_electricity_intensity = country.rail_companies.weighted_average(:electricity_intensity, :weighted_by => :passengers)
@@ -14,3 +14,4 @@ require 'earth/locality/zip_code/data_miner'
14
14
 
15
15
  require 'earth/automobile/data_miner'
16
16
  require 'earth/residence/data_miner'
17
+ require 'earth/rail/data_miner'
@@ -31,10 +31,11 @@ EgridSubregion.class_eval do
31
31
  end
32
32
 
33
33
  process "Convert co2 emission factor to metric units" do
34
- conversion_factor = 1.pounds.to(:kilograms) * 1.0 / 1_000.0 # kg / lbs * MWh / kWh
35
- update_all %{ electricity_co2_emission_factor = electricity_co2_emission_factor * #{conversion_factor},
36
- electricity_co2_emission_factor_units = 'kilograms_per_kilowatt_hour'
37
- WHERE electricity_co2_emission_factor_units = 'pounds_per_megawatt_hour' }
34
+ conversion_factor = 1.pounds.to(:kilograms) / 1_000.0 # kg / lbs * MWh / kWh
35
+ where(:electricity_co2_emission_factor_units => 'pounds_per_megawatt_hour').update_all(%{
36
+ electricity_co2_emission_factor = 1.0 * electricity_co2_emission_factor * #{conversion_factor},
37
+ electricity_co2_emission_factor_units = 'kilograms_per_kilowatt_hour'
38
+ })
38
39
  end
39
40
 
40
41
  process "Insure GreenhouseGas is populated" do
@@ -42,24 +43,28 @@ EgridSubregion.class_eval do
42
43
  end
43
44
 
44
45
  process "Convert ch4 emission factor to metric units and co2e" do
45
- conversion_factor = 1.pounds.to(:kilograms) * 1.0 / 1_000_000.0 # kg / lbs * GWh / kWh
46
+ conversion_factor = 1.pounds.to(:kilograms) / 1_000_000.0 # kg / lbs * GWh / kWh
46
47
  gwp = GreenhouseGas[:ch4].global_warming_potential
47
- update_all %{ electricity_ch4_emission_factor = electricity_ch4_emission_factor * #{conversion_factor} * #{gwp},
48
- electricity_ch4_emission_factor_units = 'kilograms_co2e_per_kilowatt_hour'
49
- WHERE electricity_ch4_emission_factor_units = 'pounds_per_gigawatt_hour' }
48
+ where(:electricity_ch4_emission_factor_units => 'pounds_per_gigawatt_hour').update_all(%{
49
+ electricity_ch4_emission_factor = 1.0 * electricity_ch4_emission_factor * #{conversion_factor} * #{gwp},
50
+ electricity_ch4_emission_factor_units = 'kilograms_co2e_per_kilowatt_hour'
51
+ })
50
52
  end
51
53
 
52
54
  process "Convert n2o emission factor to metric units and co2e" do
53
- conversion_factor = 1.pounds.to(:kilograms) * 1.0 / 1_000_000.0 # kg / lbs * GWh / kWh
55
+ conversion_factor = 1.pounds.to(:kilograms) / 1_000_000.0 # kg / lbs * GWh / kWh
54
56
  gwp = GreenhouseGas[:n2o].global_warming_potential
55
- update_all %{ electricity_n2o_emission_factor = electricity_n2o_emission_factor * #{conversion_factor} * #{gwp},
56
- electricity_n2o_emission_factor_units = 'kilograms_co2e_per_kilowatt_hour'
57
- WHERE electricity_n2o_emission_factor_units = 'pounds_per_gigawatt_hour' }
57
+ where(:electricity_n2o_emission_factor_units => 'pounds_per_gigawatt_hour').update_all(%{
58
+ electricity_n2o_emission_factor = 1.0 * electricity_n2o_emission_factor * #{conversion_factor} * #{gwp},
59
+ electricity_n2o_emission_factor_units = 'kilograms_co2e_per_kilowatt_hour'
60
+ })
58
61
  end
59
62
 
60
63
  process "Calculate combined emission factor" do
61
- update_all %{ electricity_emission_factor = electricity_co2_emission_factor + electricity_ch4_emission_factor + electricity_n2o_emission_factor,
62
- electricity_emission_factor_units = 'kilograms_co2e_per_kilowatt_hour' }
64
+ update_all(%{
65
+ electricity_emission_factor = 1.0 * electricity_co2_emission_factor + electricity_ch4_emission_factor + electricity_n2o_emission_factor,
66
+ electricity_emission_factor_units = 'kilograms_co2e_per_kilowatt_hour'
67
+ })
63
68
  end
64
69
  end
65
70
  end
@@ -8,9 +8,7 @@ Urbanity.class_eval do
8
8
  ::Earth::Utils.insert_ignore(
9
9
  :src => ResidentialEnergyConsumptionSurveyResponse,
10
10
  :dest => Urbanity,
11
- :cols => {
12
- :urbanity_id => :name
13
- }
11
+ :cols => { :urbanity_id => :name }
14
12
  )
15
13
  end
16
14
  end
@@ -18,7 +18,7 @@ ZipCode.class_eval do
18
18
  end
19
19
 
20
20
  import 'a list of zipcode states and eGRID Subregions from the US EPA',
21
- :url => 'http://www.epa.gov/cleanenergy/documents/egridzips/Power_Profiler_Zipcode_Tool_v3-1.xls',
21
+ :url => 'http://www.epa.gov/cleanenergy/documents/egridzips/Power_Profiler_Zipcode_Tool_v3-2.xlsx',
22
22
  :sheet => 'Zip-subregion' do
23
23
  key 'name', :field_name => 'ZIP (character)'
24
24
  store 'state_postal_abbreviation', :field_name => 'State'
@@ -32,25 +32,21 @@ NationalTransitDatabaseRecord.class_eval do
32
32
 
33
33
  process "Convert miles to kilometres" do
34
34
  conversion_factor = 1.miles.to(:kilometres)
35
- %{ vehicle_distance passenger_distance }.split.each do |field|
36
- connection.execute %{
37
- UPDATE #{table_name}
38
- SET #{field} = #{field} * #{conversion_factor},
39
- #{field}_units = 'kilometres'
40
- WHERE #{field}_units = 'miles'
41
- }
35
+ %w{ vehicle_distance passenger_distance }.each do |field|
36
+ where("#{field}_units" => 'miles').update_all(%{
37
+ #{field} = 1.0 * #{field} * #{conversion_factor},
38
+ #{field}_units = 'kilometres'
39
+ })
42
40
  end
43
41
  end
44
42
 
45
43
  process "Convert gallons to litres" do
46
44
  conversion_factor = 1.gallons.to(:litres)
47
- %{ diesel gasoline lpg lng cng kerosene biodiesel }.split.each do |fuel|
48
- connection.execute %{
49
- UPDATE #{table_name}
50
- SET #{fuel} = #{fuel} * #{conversion_factor},
51
- #{fuel}_units = 'litres'
52
- WHERE #{fuel}_units = 'gallons'
53
- }
45
+ %w{ diesel gasoline lpg lng cng kerosene biodiesel }.each do |fuel|
46
+ where("#{fuel}_units" => 'gallons').update_all(%{
47
+ #{fuel} = 1.0 * #{fuel} * #{conversion_factor},
48
+ #{fuel}_units = 'litres'
49
+ })
54
50
  end
55
51
  end
56
52
  end
@@ -3,11 +3,7 @@ class RailFuel < ActiveRecord::Base
3
3
 
4
4
  belongs_to :fuel, :foreign_key => 'fuel_name'
5
5
 
6
- [:density, :density_units, :co2_emission_factor, :co2_emission_factor_units, :co2_biogenic_emission_factor, :co2_biogenic_emission_factor_units].each do |method|
7
- define_method method do
8
- fuel.send(method)
9
- end
10
- end
6
+ 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
11
7
 
12
8
  col :name
13
9
  col :fuel_name
@@ -15,4 +11,4 @@ class RailFuel < ActiveRecord::Base
15
11
  col :ch4_emission_factor_units
16
12
  col :n2o_emission_factor, :type => :float
17
13
  col :n2o_emission_factor_units
18
- end
14
+ end
@@ -8,9 +8,7 @@ AirConditionerUse.class_eval do
8
8
  ::Earth::Utils.insert_ignore(
9
9
  :src => ResidentialEnergyConsumptionSurveyResponse,
10
10
  :dest => AirConditionerUse,
11
- :cols => {
12
- :central_ac_use => :name
13
- }
11
+ :cols => { :central_ac_use => :name }
14
12
  )
15
13
  end
16
14
 
@@ -8,9 +8,7 @@ ClothesMachineUse.class_eval do
8
8
  ::Earth::Utils.insert_ignore(
9
9
  :src => ResidentialEnergyConsumptionSurveyResponse,
10
10
  :dest => ClothesMachineUse,
11
- :cols => {
12
- :clothes_washer_use => :name
13
- }
11
+ :cols => { :clothes_washer_use => :name }
14
12
  )
15
13
  end
16
14
 
@@ -8,9 +8,7 @@ DishwasherUse.class_eval do
8
8
  ::Earth::Utils.insert_ignore(
9
9
  :src => ResidentialEnergyConsumptionSurveyResponse,
10
10
  :dest => DishwasherUse,
11
- :cols => {
12
- :dishwasher_use_id => :name
13
- }
11
+ :cols => { :dishwasher_use_id => :name }
14
12
  )
15
13
  end
16
14
 
@@ -8,9 +8,7 @@ ResidenceClass.class_eval do
8
8
  ::Earth::Utils.insert_ignore(
9
9
  :src => ResidentialEnergyConsumptionSurveyResponse,
10
10
  :dest => ResidenceClass,
11
- :cols => {
12
- :residence_class_id => :name
13
- }
11
+ :cols => { :residence_class_id => :name }
14
12
  )
15
13
  end
16
14
  end
@@ -114,7 +114,7 @@ ResidentialEnergyConsumptionSurveyResponse.class_eval do
114
114
  max = maximum attr_name, :select => "CONVERT(#{attr_name}, UNSIGNED INTEGER)"
115
115
  # if the maximum value of a row is all 999's, then it's a LEGITIMATE SKIP and we should set it to zero
116
116
  if /^9+$/.match(max.to_i.to_s)
117
- update_all "#{attr_name} = 0", "#{attr_name} = #{max}"
117
+ where(attr_name => max).update_all attr_name => 0
118
118
  end
119
119
  end
120
120
  end
@@ -163,6 +163,7 @@ ResidentialEnergyConsumptionSurveyResponse.class_eval do
163
163
  end
164
164
 
165
165
  process "synthesize air conditioner use from central AC and window AC use" do
166
+ # SET WHERE
166
167
  update_all "air_conditioner_use_id = 'Turned on just about all summer'", " central_ac_use = 'Turned on just about all summer' OR window_ac_use = 'Turned on just about all summer'"
167
168
  update_all "air_conditioner_use_id = 'Turned on quite a bit'", "(central_ac_use = 'Turned on quite a bit' OR window_ac_use = 'Turned on quite a bit') AND air_conditioner_use_id IS NULL"
168
169
  update_all "air_conditioner_use_id = 'Turned on only a few days or nights when really needed'", "(central_ac_use = 'Turned on only a few days or nights when really needed' OR window_ac_use = 'Turned on only a few days or nights when really needed') AND air_conditioner_use_id IS NULL"
@@ -170,6 +171,7 @@ ResidentialEnergyConsumptionSurveyResponse.class_eval do
170
171
  end
171
172
 
172
173
  process "synthesize clothes machine use from washer and dryer use" do
174
+ # SET WHERE
173
175
  update_all "clothes_machine_use_id = clothes_washer_use", " clothes_dryer_use = 'Use it every time you wash clothes'"
174
176
  update_all "clothes_machine_use_id = NULL", "clothes_washer_use IS NULL AND clothes_dryer_use = 'Use it for some, but not all, loads of wash'"
175
177
  update_all "clothes_machine_use_id = '1 load or less each week'", "clothes_washer_use = '1 load or less each week' AND clothes_dryer_use = 'Use it for some, but not all, loads of wash'"
@@ -28,16 +28,26 @@ module Earth
28
28
  dest_cols = args[:cols].values
29
29
  dest_primary_key = args[:dest].primary_key.to_sym
30
30
  dest_primary_key_in_src = args[:cols].key(dest_primary_key)
31
+
32
+ sql_items = {}
33
+ args[:cols].each do |src_col, dest_col|
34
+ if src_col.class == Symbol
35
+ sql_items[dest_col] = 'src.' + src_col.to_s
36
+ else
37
+ sql_items[dest_col] = src_col.map { |col| 'src.' + col.to_s }.join(" || ' ' || ")
38
+ end
39
+ end
40
+
31
41
  sql = %{
32
42
  INSERT INTO #{args[:dest].table_name}(#{dest_cols.join(',')})
33
- SELECT #{dest_cols.map { |dest_col| 'MAX(src.' + args[:cols].key(dest_col).to_s + ')' }.join(',')}
43
+ SELECT #{dest_cols.map { |dest_col| 'MAX(' + sql_items[dest_col] + ')' }.join(',')}
34
44
  FROM #{args[:src].table_name} AS src
35
45
  WHERE
36
- src.#{dest_primary_key_in_src} IS NOT NULL
37
- AND LENGTH(TRIM(CAST(src.#{dest_primary_key_in_src} AS CHAR))) > 0
38
- AND src.#{dest_primary_key_in_src} NOT IN (SELECT dest.#{dest_primary_key} FROM #{args[:dest].table_name} AS dest)
46
+ (#{sql_items[dest_primary_key]}) IS NOT NULL
47
+ AND LENGTH(TRIM(CAST((#{sql_items[dest_primary_key]}) AS CHAR))) > 0
48
+ AND (#{sql_items[dest_primary_key]}) NOT IN (SELECT dest.#{dest_primary_key} FROM #{args[:dest].table_name} AS dest)
39
49
  AND (#{args[:where] || '1=1'})
40
- GROUP BY src.#{dest_primary_key_in_src}
50
+ GROUP BY #{sql_items[dest_primary_key]}
41
51
  }
42
52
  ::ActiveRecord::Base.connection.execute sql
43
53
  end
@@ -1,3 +1,3 @@
1
1
  module Earth
2
- VERSION = "0.7.0"
2
+ VERSION = "0.11.0"
3
3
  end
@@ -23,7 +23,7 @@ describe Earth do
23
23
  describe '.resource_map' do
24
24
  it 'should get a list of resource_map' do
25
25
  resource_map = Earth.resource_map
26
- resource_map.keys.count.should == 89
26
+ resource_map.keys.count.should == 88
27
27
  resource_map['FuelType'].should == 'fuel'
28
28
  end
29
29
  it 'should exclude data_miner files' do
@@ -33,13 +33,13 @@ describe Earth do
33
33
 
34
34
  describe '.search' do
35
35
  it 'should get a list of all resource names' do
36
- Earth.search.length.should == 89
36
+ Earth.search.length.should == 88
37
37
  Earth.search.should include('Aircraft')
38
38
  Earth.search.should include('Industry')
39
39
  end
40
40
  it 'should filter resource_map by domain' do
41
- Earth.search('air').length.should == 12
42
- Earth.search('automobile').length.should == 15
41
+ Earth.search('air').length.should == 10
42
+ Earth.search('automobile').length.should == 16
43
43
  Earth.search('bus').length.should == 4
44
44
  Earth.search('computation').length.should == 3
45
45
  Earth.search('diet').length.should == 2
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: earth
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.7.0
5
+ version: 0.11.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Seamus Abshere
@@ -277,6 +277,7 @@ files:
277
277
  - Rakefile
278
278
  - TODO
279
279
  - bin/earth_tester.rb
280
+ - certification_changelog.markdown
280
281
  - earth.gemspec
281
282
  - features/automobile_fuel.feature
282
283
  - features/automobile_make.feature
@@ -287,7 +288,6 @@ files:
287
288
  - features/automobile_make_year.feature
288
289
  - features/automobile_size_class.feature
289
290
  - features/automobile_size_class_year.feature
290
- - features/automobile_type_fuel_age.feature
291
291
  - features/automobile_type_fuel_control.feature
292
292
  - features/automobile_type_fuel_year.feature
293
293
  - features/automobile_type_fuel_year_age.feature
@@ -365,10 +365,6 @@ files:
365
365
  - lib/earth/air.rb
366
366
  - lib/earth/air/aircraft.rb
367
367
  - lib/earth/air/aircraft/data_miner.rb
368
- - lib/earth/air/aircraft_class.rb
369
- - lib/earth/air/aircraft_class/data_miner.rb
370
- - lib/earth/air/aircraft_fuel_use_equation.rb
371
- - lib/earth/air/aircraft_fuel_use_equation/data_miner.rb
372
368
  - lib/earth/air/aircraft_instance.rb
373
369
  - lib/earth/air/aircraft_instance_seat_class.rb
374
370
  - lib/earth/air/airline.rb
@@ -392,8 +388,6 @@ files:
392
388
  - lib/earth/automobile/automobile_fuel/data_miner.rb
393
389
  - lib/earth/automobile/automobile_make.rb
394
390
  - lib/earth/automobile/automobile_make/data_miner.rb
395
- - lib/earth/automobile/automobile_make_fleet_year.rb
396
- - lib/earth/automobile/automobile_make_fleet_year/data_miner.rb
397
391
  - lib/earth/automobile/automobile_make_model.rb
398
392
  - lib/earth/automobile/automobile_make_model/data_miner.rb
399
393
  - lib/earth/automobile/automobile_make_model_year.rb
@@ -402,12 +396,14 @@ files:
402
396
  - lib/earth/automobile/automobile_make_model_year_variant/data_miner.rb
403
397
  - lib/earth/automobile/automobile_make_year.rb
404
398
  - lib/earth/automobile/automobile_make_year/data_miner.rb
399
+ - lib/earth/automobile/automobile_make_year_fleet.rb
400
+ - lib/earth/automobile/automobile_make_year_fleet/data_miner.rb
401
+ - lib/earth/automobile/automobile_model.rb
402
+ - lib/earth/automobile/automobile_model/data_miner.rb
405
403
  - lib/earth/automobile/automobile_size_class.rb
406
404
  - lib/earth/automobile/automobile_size_class/data_miner.rb
407
405
  - lib/earth/automobile/automobile_size_class_year.rb
408
406
  - lib/earth/automobile/automobile_size_class_year/data_miner.rb
409
- - lib/earth/automobile/automobile_type_fuel_age.rb
410
- - lib/earth/automobile/automobile_type_fuel_age/data_miner.rb
411
407
  - lib/earth/automobile/automobile_type_fuel_control.rb
412
408
  - lib/earth/automobile/automobile_type_fuel_control/data_miner.rb
413
409
  - lib/earth/automobile/automobile_type_fuel_year.rb
@@ -418,7 +414,10 @@ files:
418
414
  - lib/earth/automobile/automobile_type_fuel_year_control/data_miner.rb
419
415
  - lib/earth/automobile/automobile_type_year.rb
420
416
  - lib/earth/automobile/automobile_type_year/data_miner.rb
417
+ - lib/earth/automobile/automobile_year.rb
418
+ - lib/earth/automobile/automobile_year/data_miner.rb
421
419
  - lib/earth/automobile/data_miner.rb
420
+ - lib/earth/automobile/dependencies.txt
422
421
  - lib/earth/bus.rb
423
422
  - lib/earth/bus/bus_class.rb
424
423
  - lib/earth/bus/bus_class/data_miner.rb
@@ -651,7 +650,6 @@ test_files:
651
650
  - features/automobile_make_year.feature
652
651
  - features/automobile_size_class.feature
653
652
  - features/automobile_size_class_year.feature
654
- - features/automobile_type_fuel_age.feature
655
653
  - features/automobile_type_fuel_control.feature
656
654
  - features/automobile_type_fuel_year.feature
657
655
  - features/automobile_type_fuel_year_age.feature