earth 0.4.12 → 0.5.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.
- data/.gitignore +1 -0
- data/Gemfile +1 -1
- data/earth.gemspec +7 -3
- data/features/automobile_make_model_year_variant.feature +10 -10
- data/features/step_definitions/data_steps.rb +1 -1
- data/features/support/env.rb +2 -2
- data/features/support/imports/automobile_fuel_good.csv +3 -3
- data/features/support/imports/automobile_make_model_year_variant_bad.csv +2 -2
- data/features/support/imports/automobile_make_model_year_variant_good.csv +2 -2
- data/lib/earth/air.rb +2 -1
- data/lib/earth/air/aircraft.rb +21 -8
- data/lib/earth/air/aircraft/data_miner.rb +85 -180
- data/lib/earth/air/aircraft_class.rb +9 -1
- data/lib/earth/air/aircraft_class/data_miner.rb +57 -20
- data/lib/earth/air/aircraft_fuel_use_equation.rb +26 -0
- data/lib/earth/air/aircraft_fuel_use_equation/data_miner.rb +26 -0
- data/lib/earth/air/aircraft_manufacturer.rb +0 -2
- data/lib/earth/air/aircraft_manufacturer/data_miner.rb +4 -1
- data/lib/earth/air/airline.rb +2 -11
- data/lib/earth/air/airline/data_miner.rb +10 -51
- data/lib/earth/air/airport.rb +2 -29
- data/lib/earth/air/airport/data_miner.rb +61 -56
- data/lib/earth/air/bts_aircraft.rb +7 -0
- data/lib/earth/air/bts_aircraft/data_miner.rb +15 -0
- data/lib/earth/air/data_miner.rb +2 -1
- data/lib/earth/air/flight_seat_class.rb +1 -4
- data/lib/earth/air/flight_segment.rb +16 -10
- data/lib/earth/air/flight_segment/data_miner.rb +170 -129
- data/lib/earth/automobile/automobile_make/data_miner.rb +12 -3
- data/lib/earth/automobile/automobile_make_model/data_miner.rb +4 -1
- data/lib/earth/automobile/automobile_make_model_year/data_miner.rb +4 -1
- data/lib/earth/automobile/automobile_make_model_year_variant/data_miner.rb +29 -16
- data/lib/earth/automobile/automobile_make_year/data_miner.rb +8 -2
- data/lib/earth/automobile/automobile_size_class/data_miner.rb +4 -1
- data/lib/earth/automobile/automobile_type_fuel_age/data_miner.rb +4 -1
- data/lib/earth/automobile/automobile_type_fuel_year/data_miner.rb +4 -2
- data/lib/earth/automobile/automobile_type_fuel_year_age/data_miner.rb +4 -1
- data/lib/earth/automobile/automobile_type_year/data_miner.rb +4 -1
- data/lib/earth/fuel/fuel/data_miner.rb +4 -1
- data/lib/earth/hospitality/lodging_class.rb +0 -16
- data/lib/earth/hospitality/lodging_class/data_miner.rb +11 -1
- data/lib/earth/inflectors.rb +1 -1
- data/lib/earth/locality/country/data_miner.rb +14 -14
- data/lib/earth/locality/urbanity/data_miner.rb +4 -1
- data/lib/earth/residence/air_conditioner_use/data_miner.rb +4 -1
- data/lib/earth/residence/clothes_machine_use/data_miner.rb +4 -1
- data/lib/earth/residence/dishwasher_use/data_miner.rb +4 -1
- data/lib/earth/residence/residence_appliance/data_miner.rb +5 -2
- data/lib/earth/residence/residence_class/data_miner.rb +4 -1
- data/lib/earth/version.rb +1 -1
- data/spec/earth_spec.rb +2 -2
- data/test/test_aircraft_match.rb +732 -0
- metadata +87 -51
- data/features/flight_segment.feature +0 -14
- data/features/support/imports/flight_segment_bad.csv +0 -8
- data/features/support/imports/flight_segment_good.csv +0 -8
- data/lib/earth/air/flight_fuel_type.rb +0 -12
- data/lib/earth/air/flight_fuel_type/data_miner.rb +0 -12
@@ -14,8 +14,11 @@ AutomobileMakeModel.class_eval do
|
|
14
14
|
string 'fuel_efficiency_highway_units'
|
15
15
|
end
|
16
16
|
|
17
|
-
process "
|
17
|
+
process "Ensure AutomobileMakeModelYearVariant is populated" do
|
18
18
|
AutomobileMakeModelYearVariant.run_data_miner!
|
19
|
+
end
|
20
|
+
|
21
|
+
process "Derive model names from automobile make model year variants" do
|
19
22
|
INSERT_IGNORE %{INTO automobile_make_models(name, make_name, model_name)
|
20
23
|
SELECT automobile_make_model_year_variants.make_model_name, automobile_make_model_year_variants.make_name, automobile_make_model_year_variants.name FROM automobile_make_model_year_variants WHERE LENGTH(automobile_make_model_year_variants.make_name) > 0 AND LENGTH(automobile_make_model_year_variants.name) > 0
|
21
24
|
}
|
@@ -17,8 +17,11 @@ AutomobileMakeModelYear.class_eval do
|
|
17
17
|
string 'fuel_efficiency_highway_units'
|
18
18
|
end
|
19
19
|
|
20
|
-
process "
|
20
|
+
process "Ensure AutomobileMakeModelYearVariant is populated" do
|
21
21
|
AutomobileMakeModelYearVariant.run_data_miner!
|
22
|
+
end
|
23
|
+
|
24
|
+
process "Derive model year names from automobile make model year variants" do
|
22
25
|
INSERT_IGNORE %{INTO automobile_make_model_years(name, make_name, model_name, make_model_name, year, make_year_name)
|
23
26
|
SELECT automobile_make_model_year_variants.make_model_year_name, automobile_make_model_year_variants.make_name, automobile_make_model_year_variants.name, automobile_make_model_year_variants.make_model_name, automobile_make_model_year_variants.year, automobile_make_model_year_variants.make_year_name FROM automobile_make_model_year_variants WHERE LENGTH(automobile_make_model_year_variants.make_name) > 0 AND LENGTH(automobile_make_model_year_variants.make_model_name) > 0
|
24
27
|
}
|
@@ -232,7 +232,10 @@ AutomobileMakeModelYearVariant.class_eval do
|
|
232
232
|
'DU' => 'D',
|
233
233
|
'G' => 'R',
|
234
234
|
'GP' => 'P',
|
235
|
-
'GPR' => 'P'
|
235
|
+
'GPR' => 'P',
|
236
|
+
'GM' => 'P',
|
237
|
+
'BE' => 'BE',
|
238
|
+
'H' => 'H'
|
236
239
|
}
|
237
240
|
attr_reader :year
|
238
241
|
def initialize(options = {})
|
@@ -468,32 +471,42 @@ AutomobileMakeModelYearVariant.class_eval do
|
|
468
471
|
end
|
469
472
|
|
470
473
|
verify "Year should be from 1985 to 2011" do
|
471
|
-
AutomobileMakeModelYearVariant.
|
472
|
-
unless
|
473
|
-
raise "Invalid year
|
474
|
+
AutomobileMakeModelYearVariant.find_by_sql("SELECT DISTINCT year FROM automobile_make_model_year_variants").map(&:year).each do |year|
|
475
|
+
unless year > 1984 and year < 2012
|
476
|
+
raise "Invalid year in automobile_make_model_year_variants: #{year} is not from 1985 to 2011"
|
474
477
|
end
|
475
478
|
end
|
476
479
|
end
|
477
480
|
|
478
|
-
|
481
|
+
process "Ensure AutomobileFuel is populated" do
|
482
|
+
AutomobileFuel.run_data_miner!
|
483
|
+
end
|
484
|
+
|
485
|
+
verify "Fuel code should appear in AutomobileFuel" do
|
486
|
+
valid_codes = AutomobileFuel.find_by_sql("SELECT DISTINCT code FROM automobile_fuels").map(&:code)
|
487
|
+
AutomobileMakeModelYearVariant.find_by_sql("SELECT DISTINCT fuel_code FROM automobile_make_model_year_variants").map(&:fuel_code).each do |fuel_code|
|
488
|
+
unless valid_codes.include?(fuel_code)
|
489
|
+
raise "Invalide fuel code in automobile_make_model_year_variants: #{fuel_code} is not in #{valid_codes}"
|
490
|
+
end
|
491
|
+
end
|
492
|
+
end
|
479
493
|
|
480
494
|
verify "Fuel efficiencies should be greater than zero" do
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
495
|
+
[:fuel_efficiency, :fuel_efficiency_city, :fuel_efficiency_highway].each do |field|
|
496
|
+
unless AutomobileMakeModelYearVariant.where(field => nil).count == 0
|
497
|
+
raise "Invalid fuel efficiency in automobile_make_model_year_variants: nil is not > 0"
|
498
|
+
end
|
499
|
+
unless AutomobileMakeModelYearVariant.where(field => 0).count == 0
|
500
|
+
raise "Invalid fuel efficiency in automobile_make_model_year_variants: 0 is not > 0"
|
487
501
|
end
|
488
502
|
end
|
489
503
|
end
|
490
504
|
|
491
505
|
verify "Fuel efficiency units should be kilometres per litre" do
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
raise "Invalid fuel efficiency #{type} units for AutomobileMakeModelYearVariant #{variant.row_hash}: #{units} (should be kilometres_per_litre)"
|
506
|
+
%w{ fuel_efficiency_units fuel_efficiency_city_units fuel_efficiency_highway_units }.each do |field|
|
507
|
+
AutomobileMakeModelYearVariant.find_by_sql("SELECT DISTINCT #{field} FROM automobile_make_model_year_variants").map(&:"#{field}").each do |value|
|
508
|
+
unless value == 'kilometres_per_litre'
|
509
|
+
raise "Invalid #{field} in automobile_make_model_year_variants: #{value} is not 'kilometres_per_litre'"
|
497
510
|
end
|
498
511
|
end
|
499
512
|
end
|
@@ -13,8 +13,11 @@ AutomobileMakeYear.class_eval do
|
|
13
13
|
integer 'volume' # This will sometimes be null because not all make_years have CAFE data
|
14
14
|
end
|
15
15
|
|
16
|
-
process "
|
16
|
+
process "Ensure AutomobileMakeModelYearVariant is populated" do
|
17
17
|
AutomobileMakeModelYearVariant.run_data_miner!
|
18
|
+
end
|
19
|
+
|
20
|
+
process "Derive manufacturer names and years from automobile make model year variants" do
|
18
21
|
INSERT_IGNORE %{INTO automobile_make_years(name, make_name, year)
|
19
22
|
SELECT
|
20
23
|
automobile_make_model_year_variants.make_year_name,
|
@@ -30,9 +33,12 @@ AutomobileMakeYear.class_eval do
|
|
30
33
|
}
|
31
34
|
end
|
32
35
|
|
36
|
+
process "Ensure AutomobileMakeFleetYear is populated" do
|
37
|
+
AutomobileMakeFleetYear.run_data_miner!
|
38
|
+
end
|
39
|
+
|
33
40
|
# FIXME TODO make this a method on AutomobileMakeYear?
|
34
41
|
process "Calculate fuel efficiency from make fleet years for makes with CAFE data" do
|
35
|
-
AutomobileMakeFleetYear.run_data_miner!
|
36
42
|
make_fleet_years = AutomobileMakeFleetYear.arel_table
|
37
43
|
make_years = AutomobileMakeYear.arel_table
|
38
44
|
conditional_relation = make_years[:name].eq(make_fleet_years[:make_year_name])
|
@@ -24,9 +24,12 @@ AutomobileSizeClass.class_eval do
|
|
24
24
|
store 'fuel_efficiency_highway', :units_field_name => 'fuel_efficiency_highway_units'
|
25
25
|
end
|
26
26
|
|
27
|
+
process "Ensure AutomobileTypeFuelYearAge is populated" do
|
28
|
+
AutomobileTypeFuelYearAge.run_data_miner!
|
29
|
+
end
|
30
|
+
|
27
31
|
# FIXME TODO make this a method on AutomobileSizeClass?
|
28
32
|
process "Calculate annual distance from AutomobileTypeFuelYearAge" do
|
29
|
-
AutomobileTypeFuelYearAge.run_data_miner!
|
30
33
|
ages = AutomobileTypeFuelYearAge.arel_table
|
31
34
|
classes = AutomobileSizeClass.arel_table
|
32
35
|
conditional_relation = ages[:type_name].eq(classes[:type_name])
|
@@ -139,9 +139,12 @@ AutomobileTypeFuelAge.class_eval do
|
|
139
139
|
update_all "annual_distance_units = 'kilometres'"
|
140
140
|
end
|
141
141
|
|
142
|
+
process "Ensure AutomobileTypeFuelYear is populated" do
|
143
|
+
AutomobileTypeFuelYear.run_data_miner!
|
144
|
+
end
|
145
|
+
|
142
146
|
# FIXME TODO maybe make this a method on AutomobileTypeFuelAge?
|
143
147
|
process "Calculate number of vehicles from total travel percent and AutomobileTypeFuelYear" do
|
144
|
-
AutomobileTypeFuelYear.run_data_miner!
|
145
148
|
connection.execute %{
|
146
149
|
UPDATE automobile_type_fuel_ages
|
147
150
|
SET vehicles =
|
@@ -88,10 +88,12 @@ AutomobileTypeFuelYear.class_eval do
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
-
process "
|
91
|
+
process "Ensure necessary tables are populated" do
|
92
92
|
AutomobileTypeFuelYearControl.run_data_miner!
|
93
93
|
AutomobileTypeFuelControl.run_data_miner!
|
94
|
-
|
94
|
+
end
|
95
|
+
|
96
|
+
process "Calculate CH4 and N2O emision factors from AutomobileTypeFuelYearControl and AutomobileTypeFuelControl" do
|
95
97
|
AutomobileTypeFuelYear.all.each do |record|
|
96
98
|
record.ch4_emission_factor = record.year_controls.map do |year_control|
|
97
99
|
year_control.total_travel_percent * year_control.control.ch4_emission_factor
|
@@ -119,8 +119,11 @@ AutomobileTypeFuelYearAge.class_eval do
|
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
|
-
process "
|
122
|
+
process "Ensure AutomobileTypeFuelYear is populated" do
|
123
123
|
AutomobileTypeFuelYear.run_data_miner!
|
124
|
+
end
|
125
|
+
|
126
|
+
process "Calculate number of vehicles from total travel percent and AutomobileTypeFuelYear" do
|
124
127
|
AutomobileTypeFuelYearAge.all.each do |record|
|
125
128
|
record.vehicles = record.total_travel_percent * record.type_fuel_year.total_travel / record.annual_distance
|
126
129
|
record.save
|
@@ -18,8 +18,11 @@ AutomobileTypeYear.class_eval do
|
|
18
18
|
store 'hfc_emissions', :units_field_name => 'hfc_emissions_units'
|
19
19
|
end
|
20
20
|
|
21
|
-
process "
|
21
|
+
process "Ensure AutomobileTypeFuelYear is populated" do
|
22
22
|
AutomobileTypeFuelYear.run_data_miner!
|
23
|
+
end
|
24
|
+
|
25
|
+
process "Calculate HFC emission factor from AutomobileTypeFuelYear" do
|
23
26
|
AutomobileTypeYear.all.each do |record|
|
24
27
|
record.hfc_emission_factor = record.hfc_emissions / record.type_fuel_years.sum('fuel_consumption')
|
25
28
|
record.hfc_emission_factor_units = "kilograms_co2e_per_litre"
|
@@ -16,8 +16,11 @@ Fuel.class_eval do
|
|
16
16
|
string 'co2_biogenic_emission_factor_units'
|
17
17
|
end
|
18
18
|
|
19
|
-
process "
|
19
|
+
process "Ensure FuelYear is populated" do
|
20
20
|
FuelYear.run_data_miner!
|
21
|
+
end
|
22
|
+
|
23
|
+
process "Derive fuel names from FuelYear" do
|
21
24
|
INSERT_IGNORE %{INTO fuels(name)
|
22
25
|
SELECT DISTINCT fuel_years.fuel_name FROM fuel_years
|
23
26
|
}
|
@@ -1,22 +1,6 @@
|
|
1
1
|
class LodgingClass < ActiveRecord::Base
|
2
|
-
extend Earth::Base
|
3
|
-
|
4
2
|
set_primary_key :name
|
5
3
|
|
6
|
-
def self.schema_definition
|
7
|
-
lambda do
|
8
|
-
string 'name'
|
9
|
-
float 'natural_gas_intensity'
|
10
|
-
string 'natural_gas_intensity_units'
|
11
|
-
float 'fuel_oil_intensity'
|
12
|
-
string 'fuel_oil_intensity_units'
|
13
|
-
float 'electricity_intensity'
|
14
|
-
string 'electricity_intensity_units'
|
15
|
-
float 'district_heat_intensity'
|
16
|
-
string 'district_heat_intensity_units'
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
4
|
data_miner do
|
21
5
|
tap "Brighter Planet's lodging class data", Earth.taps_server
|
22
6
|
end
|
@@ -1,6 +1,16 @@
|
|
1
1
|
LodgingClass.class_eval do
|
2
2
|
data_miner do
|
3
|
-
|
3
|
+
schema Earth.database_options do
|
4
|
+
string 'name'
|
5
|
+
float 'electricity_intensity'
|
6
|
+
string 'electricity_intensity'
|
7
|
+
float 'natural_gas_intensity'
|
8
|
+
string 'natural_gas_intensity'
|
9
|
+
float 'fuel_oil_intensity'
|
10
|
+
string 'fuel_oil_intensity'
|
11
|
+
float 'district_heat_intensity'
|
12
|
+
string 'district_heat_intensity'
|
13
|
+
end
|
4
14
|
|
5
15
|
import "a list of lodging classes and pre-calculated emission factors",
|
6
16
|
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGZZWmZtWEJlYzhRNXlPdWpBTldlcUE&hl=en&gid=0&output=csv' do
|
data/lib/earth/inflectors.rb
CHANGED
@@ -41,20 +41,20 @@ Country.class_eval do
|
|
41
41
|
end
|
42
42
|
|
43
43
|
# FIXME TODO eventually need to do this for all countries
|
44
|
-
process "Derive US average automobile fuel efficiency from AutomobileTypeFuelYear" do
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
44
|
+
# process "Derive US average automobile fuel efficiency from AutomobileTypeFuelYear" do
|
45
|
+
# AutomobileTypeFuelYear.run_data_miner!
|
46
|
+
#
|
47
|
+
# scope = AutomobileTypeFuelYear.where(:year => AutomobileTypeFuelYear.maximum(:year))
|
48
|
+
# fe = scope.sum(:total_travel) / scope.sum(:fuel_consumption)
|
49
|
+
# units = scope.first.total_travel_units + '_per_' + scope.first.fuel_consumption_units.singularize
|
50
|
+
#
|
51
|
+
# connection.execute %{
|
52
|
+
# UPDATE countries
|
53
|
+
# SET automobile_fuel_efficiency = #{fe},
|
54
|
+
# automobile_fuel_efficiency_units = '#{units}'
|
55
|
+
# WHERE iso_3166_code = 'US'
|
56
|
+
# }
|
57
|
+
# end
|
58
58
|
|
59
59
|
process "Convert automobile city speed from miles per hour to kilometres per hour" do
|
60
60
|
conversion_factor = 1.miles.to(:kilometres)
|
@@ -4,8 +4,11 @@ Urbanity.class_eval do
|
|
4
4
|
string 'name'
|
5
5
|
end
|
6
6
|
|
7
|
-
process "
|
7
|
+
process "Ensure ResidentialEnergyConsumptionSurveyResponse is populated" do
|
8
8
|
ResidentialEnergyConsumptionSurveyResponse.run_data_miner!
|
9
|
+
end
|
10
|
+
|
11
|
+
process "Derive from ResidentialEnergyConsumptionSurveyResponse" do
|
9
12
|
INSERT_IGNORE %{INTO urbanities(name)
|
10
13
|
SELECT DISTINCT recs_responses.urbanity_id FROM recs_responses WHERE LENGTH(recs_responses.urbanity_id) > 0
|
11
14
|
}
|
@@ -6,8 +6,11 @@ AirConditionerUse.class_eval do
|
|
6
6
|
string 'fugitive_emission_units'
|
7
7
|
end
|
8
8
|
|
9
|
-
process "
|
9
|
+
process "Ensure ResidentialEnergyConsumptionSurveyResponse is populated" do
|
10
10
|
ResidentialEnergyConsumptionSurveyResponse.run_data_miner!
|
11
|
+
end
|
12
|
+
|
13
|
+
process "Derive from ResidentialEnergyConsumptionSurveyResponse" do
|
11
14
|
INSERT_IGNORE %{INTO air_conditioner_uses(name)
|
12
15
|
SELECT DISTINCT recs_responses.central_ac_use FROM recs_responses WHERE LENGTH(recs_responses.central_ac_use) > 0
|
13
16
|
}
|
@@ -6,8 +6,11 @@ ClothesMachineUse.class_eval do
|
|
6
6
|
string 'annual_energy_from_electricity_for_clothes_driers_units'
|
7
7
|
end
|
8
8
|
|
9
|
-
process "
|
9
|
+
process "Ensure ResidentialEnergyConsumptionSurveyResponse is populated" do
|
10
10
|
ResidentialEnergyConsumptionSurveyResponse.run_data_miner!
|
11
|
+
end
|
12
|
+
|
13
|
+
process "Derive from ResidentialEnergyConsumptionSurveyResponse" do
|
11
14
|
INSERT_IGNORE %{INTO clothes_machine_uses(name)
|
12
15
|
SELECT DISTINCT recs_responses.clothes_washer_use FROM recs_responses WHERE LENGTH(recs_responses.clothes_washer_use) > 0
|
13
16
|
}
|
@@ -6,8 +6,11 @@ DishwasherUse.class_eval do
|
|
6
6
|
string 'annual_energy_from_electricity_for_dishwashers_units'
|
7
7
|
end
|
8
8
|
|
9
|
-
process "
|
9
|
+
process "Ensure ResidentialEnergyConsumptionSurveyResponse is populated" do
|
10
10
|
ResidentialEnergyConsumptionSurveyResponse.run_data_miner!
|
11
|
+
end
|
12
|
+
|
13
|
+
process "Derive from ResidentialEnergyConsumptionSurveyResponse" do
|
11
14
|
INSERT_IGNORE %{INTO dishwasher_uses(name)
|
12
15
|
SELECT DISTINCT recs_responses.dishwasher_use_id FROM recs_responses WHERE LENGTH(recs_responses.dishwasher_use_id) > 0
|
13
16
|
}
|
@@ -5,9 +5,12 @@ ResidenceAppliance.class_eval do
|
|
5
5
|
float 'annual_energy_from_electricity'
|
6
6
|
string 'annual_energy_from_electricity_units'
|
7
7
|
end
|
8
|
-
|
9
|
-
process "
|
8
|
+
|
9
|
+
process "Ensure ResidentialEnergyConsumptionSurveyResponse is populated" do
|
10
10
|
ResidentialEnergyConsumptionSurveyResponse.run_data_miner!
|
11
|
+
end
|
12
|
+
|
13
|
+
process "Derive from ResidentialEnergyConsumptionSurveyResponse" do
|
11
14
|
ResidentialEnergyConsumptionSurveyResponse.column_names.grep(/_count$/).each do |column_name|
|
12
15
|
appliance_name = column_name.sub '_count', ''
|
13
16
|
appliance = find_or_create_by_name appliance_name
|
@@ -4,8 +4,11 @@ ResidenceClass.class_eval do
|
|
4
4
|
string :name
|
5
5
|
end
|
6
6
|
|
7
|
-
process "
|
7
|
+
process "Ensure ResidentialEnergyConsumptionSurveyResponse is populated" do
|
8
8
|
ResidentialEnergyConsumptionSurveyResponse.run_data_miner!
|
9
|
+
end
|
10
|
+
|
11
|
+
process "Derive from ResidentialEnergyConsumptionSurveyResponse" do
|
9
12
|
INSERT_IGNORE %{INTO residence_classes(name)
|
10
13
|
SELECT DISTINCT recs_responses.residence_class_id FROM recs_responses WHERE LENGTH(recs_responses.residence_class_id) > 0
|
11
14
|
}
|
data/lib/earth/version.rb
CHANGED
data/spec/earth_spec.rb
CHANGED
@@ -23,7 +23,7 @@ describe Earth do
|
|
23
23
|
describe '.resources' do
|
24
24
|
it 'should get a list of resources' do
|
25
25
|
resources = Earth.resources
|
26
|
-
resources.keys.count.should ==
|
26
|
+
resources.keys.count.should == 76
|
27
27
|
resources['FuelType'][:domain].should == 'fuel'
|
28
28
|
end
|
29
29
|
it 'should exclude data_miner files' do
|
@@ -33,7 +33,7 @@ describe Earth do
|
|
33
33
|
|
34
34
|
describe '.resource_names' do
|
35
35
|
it 'should get a list of all resource names' do
|
36
|
-
Earth.resource_names.count.should ==
|
36
|
+
Earth.resource_names.count.should == 76
|
37
37
|
Earth.resource_names.should include('Aircraft')
|
38
38
|
Earth.resource_names.should include('Industry')
|
39
39
|
end
|
@@ -0,0 +1,732 @@
|
|
1
|
+
class TestAircraftMatch < Test::Unit::TestCase
|
2
|
+
def test_014_user_input_matches_icao_codes
|
3
|
+
user_input = "Boeing 727-100RE"
|
4
|
+
assert_equal ["R721"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
5
|
+
end
|
6
|
+
|
7
|
+
def test_015_user_input_matches_icao_codes
|
8
|
+
user_input = "Boeing 727 200RE"
|
9
|
+
assert_equal ["R722"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_006_user_input_matches_icao_codes
|
13
|
+
user_input = "Boeing 747400 domestic"
|
14
|
+
assert_equal ["B74D"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_006_user_input_matches_icao_codes
|
18
|
+
user_input = "Boeing 777-200lr"
|
19
|
+
assert_equal ["B77L"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_006_user_input_matches_icao_codes
|
23
|
+
user_input = "Boeing 707-100"
|
24
|
+
assert_equal ["B701"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_006_user_input_matches_icao_codes
|
28
|
+
user_input = "Boeing 707-200"
|
29
|
+
assert_equal ["B701", "B703"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_006_user_input_matches_icao_codes
|
33
|
+
user_input = "Boeing 717-200"
|
34
|
+
assert_equal ["B712"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_006_user_input_matches_icao_codes
|
38
|
+
user_input = "Boeing 717-100"
|
39
|
+
assert_equal ["B712"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_006_user_input_matches_icao_codes
|
43
|
+
user_input = "Boeing 727-100"
|
44
|
+
assert_equal ["B721"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_006_user_input_matches_icao_codes
|
48
|
+
user_input = "Boeing 727-300"
|
49
|
+
assert_equal ["B721", "B722"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_006_user_input_matches_icao_codes
|
53
|
+
user_input = "Boeing 737-900"
|
54
|
+
assert_equal ["B739"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_002_user_input_matches_icao_codes
|
58
|
+
user_input = "Boeing 747-100"
|
59
|
+
assert_equal ["B741"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_002_user_input_matches_icao_codes
|
63
|
+
user_input = "Boeing 747-500"
|
64
|
+
assert_equal ["B741", "B742", "B743", "B744", "B74D", "B74R", "B74S"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_003_user_input_matches_icao_codes
|
68
|
+
user_input = "Boeing 757-200"
|
69
|
+
assert_equal ["B752"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_003_user_input_matches_icao_codes
|
73
|
+
user_input = "Boeing 757-100"
|
74
|
+
assert_equal ["B752", "B753"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_003_user_input_matches_icao_codes
|
78
|
+
user_input = "Boeing 767-200"
|
79
|
+
assert_equal ["B762"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_003_user_input_matches_icao_codes
|
83
|
+
user_input = "Boeing 767-100"
|
84
|
+
assert_equal ["B762", "B763", "B764"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_003_user_input_matches_icao_codes
|
88
|
+
user_input = "Boeing 777-200"
|
89
|
+
assert_equal ["B772", "B77L"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_003_user_input_matches_icao_codes
|
93
|
+
user_input = "Boeing 777-100"
|
94
|
+
assert_equal ["B772", "B773", "B77L"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_003_user_input_matches_icao_codes
|
98
|
+
user_input = "Boeing 727 Stage 3"
|
99
|
+
assert_equal ["B72Q"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_003_user_input_matches_icao_codes
|
103
|
+
user_input = "Boeing 737 Stage 3"
|
104
|
+
assert_equal ["B73Q"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_003_user_input_matches_icao_codes
|
108
|
+
user_input = "Boeing 737 Stage 4"
|
109
|
+
assert_equal ["B731", "B732", "B733", "B734", "B735", "B736", "B737", "B738", "B739", "B73Q"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_003_user_input_matches_icao_codes
|
113
|
+
user_input = "Boeing 747SP"
|
114
|
+
assert_equal ["B74S"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
115
|
+
end
|
116
|
+
|
117
|
+
def test_003_user_input_matches_icao_codes
|
118
|
+
user_input = "Boeing 747 SR"
|
119
|
+
assert_equal ["B74R"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_003_user_input_matches_icao_codes
|
123
|
+
user_input = "Boeing 747SCA"
|
124
|
+
assert_equal ["BSCA"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_003_user_input_matches_icao_codes
|
128
|
+
user_input = "Boeing 747S"
|
129
|
+
assert_equal ["B741", "B742", "B743", "B744", "B74D", "B74R", "B74S"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_003_user_input_matches_icao_codes
|
133
|
+
user_input = "Boeing 720"
|
134
|
+
assert_equal ["B720"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_003_user_input_matches_icao_codes
|
138
|
+
user_input = "Boeing 707"
|
139
|
+
assert_equal ["B701", "B703"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_003_user_input_matches_icao_codes
|
143
|
+
user_input = "Boeing 787"
|
144
|
+
assert_equal [], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
145
|
+
end
|
146
|
+
|
147
|
+
def test_003_user_input_matches_icao_codes
|
148
|
+
user_input = "Airbus A300600"
|
149
|
+
assert_equal ["A306"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_003_user_input_matches_icao_codes
|
153
|
+
user_input = "Airbus A300 100"
|
154
|
+
assert_equal ["A306", "A30B"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
155
|
+
end
|
156
|
+
|
157
|
+
def test_003_user_input_matches_icao_codes
|
158
|
+
user_input = "Airbus A300-600st"
|
159
|
+
assert_equal ["A3ST"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
160
|
+
end
|
161
|
+
|
162
|
+
def test_003_user_input_matches_icao_codes
|
163
|
+
user_input = "Airbus Beluga"
|
164
|
+
assert_equal ["A3ST"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
165
|
+
end
|
166
|
+
|
167
|
+
def test_003_user_input_matches_icao_codes
|
168
|
+
user_input = "Airbus A330-200"
|
169
|
+
assert_equal ["A332"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
170
|
+
end
|
171
|
+
|
172
|
+
def test_003_user_input_matches_icao_codes
|
173
|
+
user_input = "Airbus A330-100"
|
174
|
+
assert_equal ["A332", "A333"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
175
|
+
end
|
176
|
+
|
177
|
+
def test_003_user_input_matches_icao_codes
|
178
|
+
user_input = "Airbus A340-200"
|
179
|
+
assert_equal ["A342"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_003_user_input_matches_icao_codes
|
183
|
+
user_input = "Airbus A340-100"
|
184
|
+
assert_equal ["A342", "A343", "A345", "A346"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
185
|
+
end
|
186
|
+
|
187
|
+
def test_003_user_input_matches_icao_codes
|
188
|
+
user_input = "Airbus A380-800"
|
189
|
+
assert_equal ["A388"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
190
|
+
end
|
191
|
+
|
192
|
+
def test_003_user_input_matches_icao_codes
|
193
|
+
user_input = "Airbus A380-100"
|
194
|
+
assert_equal ["A388"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
195
|
+
end
|
196
|
+
|
197
|
+
def test_003_user_input_matches_icao_codes
|
198
|
+
user_input = "Airbus A300C"
|
199
|
+
assert_equal ["A30B"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
200
|
+
end
|
201
|
+
|
202
|
+
def test_003_user_input_matches_icao_codes
|
203
|
+
user_input = "Airbus A300X"
|
204
|
+
assert_equal ["A306", "A30B"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
205
|
+
end
|
206
|
+
|
207
|
+
def test_003_user_input_matches_icao_codes
|
208
|
+
user_input = "Airbus A318"
|
209
|
+
assert_equal ["A318"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
210
|
+
end
|
211
|
+
|
212
|
+
def test_003_user_input_matches_icao_codes
|
213
|
+
user_input = "Airbus A311"
|
214
|
+
assert_equal [], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
215
|
+
end
|
216
|
+
|
217
|
+
def test_003_user_input_matches_icao_codes
|
218
|
+
user_input = "Airbus A321"
|
219
|
+
assert_equal ["A321"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
220
|
+
end
|
221
|
+
|
222
|
+
def test_003_user_input_matches_icao_codes
|
223
|
+
user_input = "Airbus A322"
|
224
|
+
assert_equal [], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
225
|
+
end
|
226
|
+
|
227
|
+
def test_003_user_input_matches_icao_codes
|
228
|
+
user_input = "Airbus A350"
|
229
|
+
assert_equal [], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
230
|
+
end
|
231
|
+
|
232
|
+
def test_003_user_input_matches_icao_codes
|
233
|
+
user_input = "Canadair CL601"
|
234
|
+
assert_equal ["CL60"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
235
|
+
end
|
236
|
+
|
237
|
+
def test_003_user_input_matches_icao_codes
|
238
|
+
user_input = "Canadair CL215"
|
239
|
+
assert_equal ["CL2P"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
240
|
+
end
|
241
|
+
|
242
|
+
def test_003_user_input_matches_icao_codes
|
243
|
+
user_input = "Canadair CL215 turbine"
|
244
|
+
assert_equal ["CL2T"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
245
|
+
end
|
246
|
+
|
247
|
+
def test_003_user_input_matches_icao_codes
|
248
|
+
user_input = "Canadair CL44O"
|
249
|
+
assert_equal ["CL4G"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
250
|
+
end
|
251
|
+
|
252
|
+
def test_003_user_input_matches_icao_codes
|
253
|
+
user_input = "Canadair CRJ440"
|
254
|
+
assert_equal ["CRJ2"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
255
|
+
end
|
256
|
+
|
257
|
+
def test_003_user_input_matches_icao_codes
|
258
|
+
user_input = "Canadair CRJ111"
|
259
|
+
assert_equal ["CRJ1"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
260
|
+
end
|
261
|
+
|
262
|
+
def test_003_user_input_matches_icao_codes
|
263
|
+
user_input = "Embraer ERJ130"
|
264
|
+
assert_equal ["E135"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
265
|
+
end
|
266
|
+
|
267
|
+
def test_003_user_input_matches_icao_codes
|
268
|
+
user_input = "Embraer ERJ145XR"
|
269
|
+
assert_equal ["E45X"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
270
|
+
end
|
271
|
+
|
272
|
+
def test_003_user_input_matches_icao_codes
|
273
|
+
user_input = "Embraer EMB110"
|
274
|
+
assert_equal ["E110"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
275
|
+
end
|
276
|
+
|
277
|
+
def test_003_user_input_matches_icao_codes
|
278
|
+
user_input = "Embraer Bandeirante"
|
279
|
+
assert_equal ["E110"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
280
|
+
end
|
281
|
+
|
282
|
+
def test_003_user_input_matches_icao_codes
|
283
|
+
user_input = "Embraer EMB120"
|
284
|
+
assert_equal ["E120"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
285
|
+
end
|
286
|
+
|
287
|
+
def test_003_user_input_matches_icao_codes
|
288
|
+
user_input = "Embraer Brasilia"
|
289
|
+
assert_equal ["E120"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
290
|
+
end
|
291
|
+
|
292
|
+
def test_003_user_input_matches_icao_codes
|
293
|
+
user_input = "Embraer EMB121"
|
294
|
+
assert_equal ["E121"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
295
|
+
end
|
296
|
+
|
297
|
+
def test_003_user_input_matches_icao_codes
|
298
|
+
user_input = "Embraer Xingu"
|
299
|
+
assert_equal ["E121"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
300
|
+
end
|
301
|
+
|
302
|
+
def test_003_user_input_matches_icao_codes
|
303
|
+
user_input = "Embraer EMB201"
|
304
|
+
assert_equal ["IPAN"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
305
|
+
end
|
306
|
+
|
307
|
+
def test_003_user_input_matches_icao_codes
|
308
|
+
user_input = "Embraer Ipanema"
|
309
|
+
assert_equal ["IPAN"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
310
|
+
end
|
311
|
+
|
312
|
+
def test_003_user_input_matches_icao_codes
|
313
|
+
user_input = "McDonnell Douglas DC3"
|
314
|
+
assert_equal ["DC3", "DC3S"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
315
|
+
end
|
316
|
+
|
317
|
+
def test_003_user_input_matches_icao_codes
|
318
|
+
user_input = "McDonnell Douglas DC3S"
|
319
|
+
assert_equal ["DC3S"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
320
|
+
end
|
321
|
+
|
322
|
+
def test_003_user_input_matches_icao_codes
|
323
|
+
user_input = "McDonnell Douglas DC8-50"
|
324
|
+
assert_equal ["DC85"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
325
|
+
end
|
326
|
+
|
327
|
+
def test_003_user_input_matches_icao_codes
|
328
|
+
user_input = "McDonnell Douglas DC8-40"
|
329
|
+
assert_equal ["DC85", "DC86", "DC87", "DC8Q"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
330
|
+
end
|
331
|
+
|
332
|
+
def test_003_user_input_matches_icao_codes
|
333
|
+
user_input = "McDonnell Douglas DC8 Stage 3"
|
334
|
+
assert_equal ["DC8Q"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
335
|
+
end
|
336
|
+
|
337
|
+
def test_003_user_input_matches_icao_codes
|
338
|
+
user_input = "McDonnell Douglas DC9-10"
|
339
|
+
assert_equal ["DC91"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
340
|
+
end
|
341
|
+
|
342
|
+
def test_003_user_input_matches_icao_codes
|
343
|
+
user_input = "McDonnell Douglas DC9-60"
|
344
|
+
assert_equal ["DC91", "DC92", "DC93", "DC94", "DC95", "DC9Q"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
345
|
+
end
|
346
|
+
|
347
|
+
def test_003_user_input_matches_icao_codes
|
348
|
+
user_input = "McDonnell Douglas DC9 Stage 3"
|
349
|
+
assert_equal ["DC9Q"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
350
|
+
end
|
351
|
+
|
352
|
+
def test_003_user_input_matches_icao_codes
|
353
|
+
user_input = "McDonnell Douglas DC10-10"
|
354
|
+
assert_equal ["DC10"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
355
|
+
end
|
356
|
+
|
357
|
+
def test_003_user_input_matches_icao_codes
|
358
|
+
user_input = "McDonnell Douglas DC4"
|
359
|
+
assert_equal ["DC4"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
360
|
+
end
|
361
|
+
|
362
|
+
def test_003_user_input_matches_icao_codes
|
363
|
+
user_input = "McDonnell Douglas DC5"
|
364
|
+
assert_equal [], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
365
|
+
end
|
366
|
+
|
367
|
+
def test_003_user_input_matches_icao_codes
|
368
|
+
user_input = "McDonnell Douglas MD81"
|
369
|
+
assert_equal ["MD81"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
370
|
+
end
|
371
|
+
|
372
|
+
def test_003_user_input_matches_icao_codes
|
373
|
+
user_input = "McDonnell Douglas MD84"
|
374
|
+
assert_equal ["MD81", "MD82", "MD83", "MD87", "MD88"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
375
|
+
end
|
376
|
+
|
377
|
+
def test_003_user_input_matches_icao_codes
|
378
|
+
user_input = "McDonnell Douglas MD11"
|
379
|
+
assert_equal ["MD11"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
380
|
+
end
|
381
|
+
|
382
|
+
def test_003_user_input_matches_icao_codes
|
383
|
+
user_input = "McDonnell Douglas MD90"
|
384
|
+
assert_equal ["MD90"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
385
|
+
end
|
386
|
+
|
387
|
+
def test_003_user_input_matches_icao_codes
|
388
|
+
user_input = "McDonnell Douglas C133"
|
389
|
+
assert_equal ["C133"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
390
|
+
end
|
391
|
+
|
392
|
+
def test_003_user_input_matches_icao_codes
|
393
|
+
user_input = "McDonnell Douglas Cargomaster"
|
394
|
+
assert_equal ["C133"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
395
|
+
end
|
396
|
+
|
397
|
+
def test_003_user_input_matches_icao_codes
|
398
|
+
user_input = "de Havilland DHC8-100"
|
399
|
+
assert_equal ["DH8A"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
400
|
+
end
|
401
|
+
|
402
|
+
def test_003_user_input_matches_icao_codes
|
403
|
+
user_input = "de Havilland DHC8-500"
|
404
|
+
assert_equal ["DH8A", "DH8B", "DH8C", "DH8D"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
405
|
+
end
|
406
|
+
|
407
|
+
def test_003_user_input_matches_icao_codes
|
408
|
+
user_input = "de Havilland DHC1"
|
409
|
+
assert_equal ["DHC1"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
410
|
+
end
|
411
|
+
|
412
|
+
def test_003_user_input_matches_icao_codes
|
413
|
+
user_input = "de Havilland Chipmunk"
|
414
|
+
assert_equal ["DHC1"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
415
|
+
end
|
416
|
+
|
417
|
+
def test_003_user_input_matches_icao_codes
|
418
|
+
user_input = "de Havilland DHC2 mk1"
|
419
|
+
assert_equal ["DHC2"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
420
|
+
end
|
421
|
+
|
422
|
+
def test_003_user_input_matches_icao_codes
|
423
|
+
user_input = "de Havilland DHC2 mk3"
|
424
|
+
assert_equal ["DH2T"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
425
|
+
end
|
426
|
+
|
427
|
+
def test_003_user_input_matches_icao_codes
|
428
|
+
user_input = "de Havilland Beaver"
|
429
|
+
assert_equal ["DHC2"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
430
|
+
end
|
431
|
+
|
432
|
+
def test_003_user_input_matches_icao_codes
|
433
|
+
user_input = "de Havilland Turbo Beaver"
|
434
|
+
assert_equal ["DH2T"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
435
|
+
end
|
436
|
+
|
437
|
+
def test_003_user_input_matches_icao_codes
|
438
|
+
user_input = "de Havilland DHC2"
|
439
|
+
assert_equal ["DHC2", "DH2T"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
440
|
+
end
|
441
|
+
|
442
|
+
def test_003_user_input_matches_icao_codes
|
443
|
+
user_input = "de Havilland DHC3"
|
444
|
+
assert_equal ["DHC3", "DH3T"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
445
|
+
end
|
446
|
+
|
447
|
+
def test_003_user_input_matches_icao_codes
|
448
|
+
user_input = "de Havilland Otter"
|
449
|
+
assert_equal ["DHC3"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
450
|
+
end
|
451
|
+
|
452
|
+
def test_003_user_input_matches_icao_codes
|
453
|
+
user_input = "de Havilland Turbo Otter"
|
454
|
+
assert_equal ["DH3T"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
455
|
+
end
|
456
|
+
|
457
|
+
def test_003_user_input_matches_icao_codes
|
458
|
+
user_input = "de Havilland DHC4"
|
459
|
+
assert_equal ["DHC4"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
460
|
+
end
|
461
|
+
|
462
|
+
def test_003_user_input_matches_icao_codes
|
463
|
+
user_input = "de Havilland Caribou"
|
464
|
+
assert_equal ["DHC4"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
465
|
+
end
|
466
|
+
|
467
|
+
def test_003_user_input_matches_icao_codes
|
468
|
+
user_input = "de Havilland DHC5"
|
469
|
+
assert_equal ["DHC5"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
470
|
+
end
|
471
|
+
|
472
|
+
def test_003_user_input_matches_icao_codes
|
473
|
+
user_input = "de Havilland Buffalo"
|
474
|
+
assert_equal ["DHC5"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
475
|
+
end
|
476
|
+
|
477
|
+
def test_003_user_input_matches_icao_codes
|
478
|
+
user_input = "de Havilland DHC6"
|
479
|
+
assert_equal ["DHC6"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
480
|
+
end
|
481
|
+
|
482
|
+
def test_003_user_input_matches_icao_codes
|
483
|
+
user_input = "de Havilland Twin"
|
484
|
+
assert_equal ["DHC6"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
485
|
+
end
|
486
|
+
|
487
|
+
def test_003_user_input_matches_icao_codes
|
488
|
+
user_input = "de Havilland DHC7"
|
489
|
+
assert_equal ["DHC7"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
490
|
+
end
|
491
|
+
|
492
|
+
def test_003_user_input_matches_icao_codes
|
493
|
+
user_input = "de Havilland Dash 7"
|
494
|
+
assert_equal ["DHC7"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
495
|
+
end
|
496
|
+
|
497
|
+
def test_003_user_input_matches_icao_codes
|
498
|
+
user_input = "aerospatiale atr42"
|
499
|
+
assert_equal ["AT43", "AT44", "AT45"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
500
|
+
end
|
501
|
+
|
502
|
+
def test_003_user_input_matches_icao_codes
|
503
|
+
user_input = "aerospatiale atr72"
|
504
|
+
assert_equal ["AT72"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
505
|
+
end
|
506
|
+
|
507
|
+
def test_003_user_input_matches_icao_codes
|
508
|
+
user_input = "bae bae 146 100"
|
509
|
+
assert_equal ["B461"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
510
|
+
end
|
511
|
+
|
512
|
+
def test_003_user_input_matches_icao_codes
|
513
|
+
user_input = "bae bae146-400"
|
514
|
+
assert_equal ["B461", "B462", "B463"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
515
|
+
end
|
516
|
+
|
517
|
+
def test_003_user_input_matches_icao_codes
|
518
|
+
user_input = "bae jetstream 32"
|
519
|
+
assert_equal ["JS32"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
520
|
+
end
|
521
|
+
|
522
|
+
def test_003_user_input_matches_icao_codes
|
523
|
+
user_input = "bae jetstream super 31"
|
524
|
+
assert_equal ["JS32"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
525
|
+
end
|
526
|
+
|
527
|
+
def test_003_user_input_matches_icao_codes
|
528
|
+
user_input = "bae jetstream 31"
|
529
|
+
assert_equal ["JS31"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
530
|
+
end
|
531
|
+
|
532
|
+
def test_003_user_input_matches_icao_codes
|
533
|
+
user_input = "bae jetstream 41"
|
534
|
+
assert_equal ["JS41"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
535
|
+
end
|
536
|
+
|
537
|
+
def test_003_user_input_matches_icao_codes
|
538
|
+
user_input = "bae atp"
|
539
|
+
assert_equal ["atp"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
540
|
+
end
|
541
|
+
|
542
|
+
def test_003_user_input_matches_icao_codes
|
543
|
+
user_input = "bae bac one-eleven"
|
544
|
+
assert_equal ["BA11"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
545
|
+
end
|
546
|
+
|
547
|
+
def test_003_user_input_matches_icao_codes
|
548
|
+
user_input = "bae bac111"
|
549
|
+
assert_equal ["BA11"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
550
|
+
end
|
551
|
+
|
552
|
+
def test_003_user_input_matches_icao_codes
|
553
|
+
user_input = "bae bae125-1000"
|
554
|
+
assert_equal ["H25C"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
555
|
+
end
|
556
|
+
|
557
|
+
def test_003_user_input_matches_icao_codes
|
558
|
+
user_input = "bae bae125-70"
|
559
|
+
assert_equal ["H25B"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
560
|
+
end
|
561
|
+
|
562
|
+
def test_003_user_input_matches_icao_codes
|
563
|
+
user_input = "bae bae125-75"
|
564
|
+
assert_equal ["H25B"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
565
|
+
end
|
566
|
+
|
567
|
+
def test_003_user_input_matches_icao_codes
|
568
|
+
user_input = "bae bae125-80"
|
569
|
+
assert_equal ["H25B"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
570
|
+
end
|
571
|
+
|
572
|
+
def test_003_user_input_matches_icao_codes
|
573
|
+
user_input = "bae bae125-85"
|
574
|
+
assert_equal ["H25B"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
575
|
+
end
|
576
|
+
|
577
|
+
def test_003_user_input_matches_icao_codes
|
578
|
+
user_input = "bae bae125-90"
|
579
|
+
assert_equal ["H25B"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
580
|
+
end
|
581
|
+
|
582
|
+
def test_003_user_input_matches_icao_codes
|
583
|
+
user_input = "bae bae125-95"
|
584
|
+
assert_equal [], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
585
|
+
end
|
586
|
+
|
587
|
+
def test_003_user_input_matches_icao_codes
|
588
|
+
user_input = "bae bae125"
|
589
|
+
assert_equal [], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
590
|
+
end
|
591
|
+
|
592
|
+
def test_003_user_input_matches_icao_codes
|
593
|
+
user_input = "fokker 50"
|
594
|
+
assert_equal ["F50"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
595
|
+
end
|
596
|
+
|
597
|
+
def test_003_user_input_matches_icao_codes
|
598
|
+
user_input = "fokker 61"
|
599
|
+
assert_equal ["F60"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
600
|
+
end
|
601
|
+
|
602
|
+
def test_003_user_input_matches_icao_codes
|
603
|
+
user_input = "fokker 72"
|
604
|
+
assert_equal ["F70"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
605
|
+
end
|
606
|
+
|
607
|
+
def test_003_user_input_matches_icao_codes
|
608
|
+
user_input = "fokker 103"
|
609
|
+
assert_equal ["F100"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
610
|
+
end
|
611
|
+
|
612
|
+
def test_003_user_input_matches_icao_codes
|
613
|
+
user_input = "fokker 80"
|
614
|
+
assert_equal [], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
615
|
+
end
|
616
|
+
|
617
|
+
def test_003_user_input_matches_icao_codes
|
618
|
+
user_input = "fokker F27"
|
619
|
+
assert_equal ["F27"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
620
|
+
end
|
621
|
+
|
622
|
+
def test_003_user_input_matches_icao_codes
|
623
|
+
user_input = "fokker Friendship"
|
624
|
+
assert_equal ["F27"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
625
|
+
end
|
626
|
+
|
627
|
+
def test_003_user_input_matches_icao_codes
|
628
|
+
user_input = "fokker F28"
|
629
|
+
assert_equal ["F28"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
630
|
+
end
|
631
|
+
|
632
|
+
def test_003_user_input_matches_icao_codes
|
633
|
+
user_input = "fokker Fellowship"
|
634
|
+
assert_equal ["F28"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
635
|
+
end
|
636
|
+
|
637
|
+
def test_003_user_input_matches_icao_codes
|
638
|
+
user_input = "fokker super"
|
639
|
+
assert_equal ["SUNV"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
640
|
+
end
|
641
|
+
|
642
|
+
def test_003_user_input_matches_icao_codes
|
643
|
+
user_input = "saab 2000"
|
644
|
+
assert_equal ["SB20"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
645
|
+
end
|
646
|
+
|
647
|
+
def test_003_user_input_matches_icao_codes
|
648
|
+
user_input = "saab 340"
|
649
|
+
assert_equal ["SF34"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
650
|
+
end
|
651
|
+
|
652
|
+
def test_003_user_input_matches_icao_codes
|
653
|
+
user_input = "saab 91"
|
654
|
+
assert_equal ["SB91"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
655
|
+
end
|
656
|
+
|
657
|
+
def test_003_user_input_matches_icao_codes
|
658
|
+
user_input = "saab safir"
|
659
|
+
assert_equal ["SB91"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
660
|
+
end
|
661
|
+
|
662
|
+
def test_003_user_input_matches_icao_codes
|
663
|
+
user_input = "hawker beechcraft 1900"
|
664
|
+
assert_equal ["B190"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
665
|
+
end
|
666
|
+
|
667
|
+
def test_003_user_input_matches_icao_codes
|
668
|
+
user_input = "cessna 401"
|
669
|
+
assert_equal ["C402"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
670
|
+
end
|
671
|
+
|
672
|
+
def test_003_user_input_matches_icao_codes
|
673
|
+
user_input = "cessna 402"
|
674
|
+
assert_equal ["C402"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
675
|
+
end
|
676
|
+
|
677
|
+
def test_003_user_input_matches_icao_codes
|
678
|
+
user_input = "cessna 208"
|
679
|
+
assert_equal ["C208"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
680
|
+
end
|
681
|
+
|
682
|
+
def test_003_user_input_matches_icao_codes
|
683
|
+
user_input = "cessna caravan"
|
684
|
+
assert_equal ["C208"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
685
|
+
end
|
686
|
+
|
687
|
+
def test_003_user_input_matches_icao_codes
|
688
|
+
user_input = "cessna cargomaster"
|
689
|
+
assert_equal ["C208"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
690
|
+
end
|
691
|
+
|
692
|
+
def test_003_user_input_matches_icao_codes
|
693
|
+
user_input = "cessna grand caravan"
|
694
|
+
assert_equal ["C208"], Aircraft.loose_tight_dictionary.find_all(user_input).map(&:icao_code)
|
695
|
+
end
|
696
|
+
|
697
|
+
|
698
|
+
|
699
|
+
# def test_001_flight_segments_match_icao_codes
|
700
|
+
# flight_segment_bts_aircraft_type_description = 'BOEING 747-100' # aka type 816
|
701
|
+
# assert_equal %w{ B741 B742 B743 B744 B74D B74R B74S }, Aircraft.loose_tight_dictionary(flight_segment_bts_aircraft_type_description).map(&:icao_code)
|
702
|
+
# end
|
703
|
+
#
|
704
|
+
# def test_003_user_input_matches_flight_segments
|
705
|
+
# user_input = '747'
|
706
|
+
# aircraft_suggested_by_user_input = Aircraft.loose_tight_dictionary(user_input)
|
707
|
+
#
|
708
|
+
# # this is why the following query should work...
|
709
|
+
# # FlightSegment.cohort(:aircraft => [ B731, B732 ])
|
710
|
+
# # FlightSegment => FuzzyAircraftMatch <= Aircraft
|
711
|
+
# # select * from flight_segments
|
712
|
+
# # inner join
|
713
|
+
# # fuzzy_aircraft_matches on
|
714
|
+
# # flight_segments.aircraft_description = fuzzy_aircraft_matches.bbb # FlightSegment.has_many :aircraft [...] :foreign_key => :bbb
|
715
|
+
# # where
|
716
|
+
# # fuzzy_aircraft_matches.aaa in ('B731', 'B732') # Aircraft.has_many :aircraft [...] :foreign_key => :aaa
|
717
|
+
#
|
718
|
+
# assert_equal [...flight segments...], FlightSegment.cohort(:aircraft => aircraft_suggested_by_user_input)
|
719
|
+
# end
|
720
|
+
#
|
721
|
+
# def test_004_user_input_matches_fuel_use_equations
|
722
|
+
# user_input = '747'
|
723
|
+
# aircraft_suggested_by_user_input = Aircraft.loose_tight_dictionary(user_input)
|
724
|
+
#
|
725
|
+
# # see above for why this would work
|
726
|
+
# # ...
|
727
|
+
# # fuel_use_equations.aircraft_description = fuzzy_aircraft_matches.bbb # FuelUseEquation.has_many :aircraft [...] :foreign_key => :bbb
|
728
|
+
# # ...
|
729
|
+
#
|
730
|
+
# assert_equal [...flight segments...], FuelUseEquation.cohort(:aircraft => aircraft_suggested_by_user_input)
|
731
|
+
# end
|
732
|
+
end
|