earth 0.11.20 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. data/data/automobile/annual_emission_controls.csv +143 -0
  2. data/data/automobile/annual_fuel_consumption.csv +81 -0
  3. data/data/automobile/annual_sizes.csv +541 -0
  4. data/data/automobile/auto_fuel_data.csv +13 -0
  5. data/data/automobile/auto_fuel_efs.csv +9 -0
  6. data/data/automobile/cafe_data.csv +1449 -0
  7. data/data/automobile/emission_control_techs.csv +21 -0
  8. data/data/automobile/hfc_emissions.csv +31 -0
  9. data/data/automobile/hybridity_multipliers.csv +8 -0
  10. data/data/automobile/sizes.csv +16 -0
  11. data/earth.gemspec +3 -2
  12. data/errata/aircraft/faa_errata.csv +1 -1
  13. data/errata/airline/bts_carrier_codes_errata.csv +44 -0
  14. data/errata/airport/openflights_errata.csv +450 -1
  15. data/errata/automobile_make_model_year_variant/feg_errata.csv +363 -1
  16. data/errata/automobile_make_year_fleet/cafe_errata.csv +69 -1
  17. data/errata/bts_aircraft/bts_errata.csv +1 -1
  18. data/errata/country/wri_errata.csv +1 -1
  19. data/errata/electricity/electric_market/nrel_errata.csv +13 -1
  20. data/errata/electricity/electric_utility/eia_errata.csv +18 -1
  21. data/errata/flight_segment/bts_errata.csv +4 -1
  22. data/lib/earth.rb +1 -0
  23. data/lib/earth/acronyms.rb +12 -0
  24. data/lib/earth/air/aircraft.rb +16 -0
  25. data/lib/earth/air/airline.rb +3 -0
  26. data/lib/earth/air/airline/data_miner.rb +18 -3
  27. data/lib/earth/air/airport.rb +2 -0
  28. data/lib/earth/air/bts_aircraft.rb +2 -0
  29. data/lib/earth/air/flight_distance_class.rb +2 -0
  30. data/lib/earth/air/flight_distance_class_seat_class.rb +2 -0
  31. data/lib/earth/air/flight_seat_class.rb +2 -0
  32. data/lib/earth/air/flight_segment.rb +10 -0
  33. data/lib/earth/air/flight_segment/data_miner.rb +10 -13
  34. data/lib/earth/automobile/automobile_activity_year.rb +21 -0
  35. data/lib/earth/automobile/automobile_activity_year/data_miner.rb +27 -0
  36. data/lib/earth/automobile/automobile_activity_year_type.rb +27 -0
  37. data/lib/earth/automobile/automobile_activity_year_type/data_miner.rb +27 -0
  38. data/lib/earth/automobile/automobile_activity_year_type_fuel.rb +19 -0
  39. data/lib/earth/automobile/automobile_activity_year_type_fuel/data_miner.rb +57 -0
  40. data/lib/earth/automobile/automobile_fuel.rb +93 -86
  41. data/lib/earth/automobile/automobile_fuel/data_miner.rb +64 -70
  42. data/lib/earth/automobile/automobile_make.rb +5 -1
  43. data/lib/earth/automobile/automobile_make/data_miner.rb +10 -37
  44. data/lib/earth/automobile/automobile_make_model.rb +22 -3
  45. data/lib/earth/automobile/automobile_make_model/data_miner.rb +41 -15
  46. data/lib/earth/automobile/automobile_make_model_year.rb +18 -7
  47. data/lib/earth/automobile/automobile_make_model_year/data_miner.rb +43 -27
  48. data/lib/earth/automobile/automobile_make_model_year_variant.rb +44 -8
  49. data/lib/earth/automobile/automobile_make_model_year_variant/data_miner.rb +182 -8
  50. data/lib/earth/automobile/automobile_make_year.rb +4 -2
  51. data/lib/earth/automobile/automobile_make_year/data_miner.rb +16 -15
  52. data/lib/earth/automobile/automobile_make_year_fleet.rb +2 -1
  53. data/lib/earth/automobile/automobile_make_year_fleet/data_miner.rb +5 -2
  54. data/lib/earth/automobile/automobile_model.rb +2 -1
  55. data/lib/earth/automobile/automobile_model/data_miner.rb +1 -2
  56. data/lib/earth/automobile/automobile_size_class.rb +7 -68
  57. data/lib/earth/automobile/automobile_size_class/data_miner.rb +16 -51
  58. data/lib/earth/automobile/automobile_type_fuel.rb +23 -0
  59. data/lib/earth/automobile/automobile_type_fuel/data_miner.rb +52 -0
  60. data/lib/earth/automobile/automobile_type_fuel_control.rb +2 -33
  61. data/lib/earth/automobile/automobile_type_fuel_control/data_miner.rb +19 -4
  62. data/lib/earth/automobile/automobile_type_fuel_year.rb +17 -54
  63. data/lib/earth/automobile/automobile_type_fuel_year/data_miner.rb +40 -94
  64. data/lib/earth/automobile/automobile_type_fuel_year_control.rb +25 -23
  65. data/lib/earth/automobile/automobile_type_fuel_year_control/data_miner.rb +6 -2
  66. data/lib/earth/automobile/automobile_year.rb +38 -1
  67. data/lib/earth/automobile/automobile_year/data_miner.rb +1 -2
  68. data/lib/earth/automobile/dependencies.txt +22 -36
  69. data/lib/earth/bus/bus_class.rb +2 -0
  70. data/lib/earth/bus/bus_fuel.rb +2 -0
  71. data/lib/earth/bus/bus_fuel_control.rb +2 -0
  72. data/lib/earth/bus/bus_fuel_year_control.rb +2 -0
  73. data/lib/earth/computation/computation_carrier.rb +2 -0
  74. data/lib/earth/computation/computation_carrier_instance_class.rb +2 -0
  75. data/lib/earth/computation/computation_carrier_region.rb +2 -0
  76. data/lib/earth/conversions_ext.rb +6 -0
  77. data/lib/earth/diet/diet_class.rb +2 -0
  78. data/lib/earth/diet/food_group.rb +2 -0
  79. data/lib/earth/fuel/fuel.rb +2 -0
  80. data/lib/earth/fuel/fuel/data_miner.rb +15 -0
  81. data/lib/earth/fuel/fuel_price.rb +2 -0
  82. data/lib/earth/fuel/fuel_type.rb +2 -0
  83. data/lib/earth/fuel/fuel_year.rb +2 -0
  84. data/lib/earth/fuel/greenhouse_gas.rb +2 -0
  85. data/lib/earth/hospitality/commercial_building_energy_consumption_survey_response/data_miner.rb +7 -7
  86. data/lib/earth/hospitality/lodging_class.rb +2 -0
  87. data/lib/earth/industry/industry.rb +2 -0
  88. data/lib/earth/industry/mecs_energy/data_miner.rb +1 -1
  89. data/lib/earth/industry/mecs_ratio/data_miner.rb +1 -1
  90. data/lib/earth/locality/census_division.rb +2 -0
  91. data/lib/earth/locality/census_region.rb +2 -0
  92. data/lib/earth/locality/climate_division.rb +2 -0
  93. data/lib/earth/locality/country.rb +4 -0
  94. data/lib/earth/locality/egrid_region.rb +3 -0
  95. data/lib/earth/locality/egrid_subregion.rb +2 -0
  96. data/lib/earth/locality/petroleum_administration_for_defense_district.rb +7 -0
  97. data/lib/earth/locality/state.rb +7 -0
  98. data/lib/earth/locality/zip_code.rb +4 -0
  99. data/lib/earth/pet/breed.rb +7 -0
  100. data/lib/earth/pet/breed/data_miner.rb +1 -1
  101. data/lib/earth/pet/breed_gender.rb +2 -0
  102. data/lib/earth/pet/gender.rb +2 -0
  103. data/lib/earth/pet/species.rb +2 -0
  104. data/lib/earth/rail/country_rail_class.rb +2 -0
  105. data/lib/earth/rail/country_rail_traction.rb +2 -0
  106. data/lib/earth/rail/country_rail_traction_class.rb +2 -0
  107. data/lib/earth/rail/national_transit_database_company.rb +7 -0
  108. data/lib/earth/rail/national_transit_database_mode.rb +2 -0
  109. data/lib/earth/rail/national_transit_database_record.rb +22 -0
  110. data/lib/earth/rail/rail_class.rb +2 -0
  111. data/lib/earth/rail/rail_company.rb +16 -0
  112. data/lib/earth/rail/rail_fuel.rb +2 -0
  113. data/lib/earth/rail/rail_traction.rb +2 -0
  114. data/lib/earth/residence/air_conditioner_use.rb +2 -0
  115. data/lib/earth/residence/clothes_machine_use.rb +2 -0
  116. data/lib/earth/residence/dishwasher_use.rb +2 -0
  117. data/lib/earth/residence/residence_appliance.rb +2 -0
  118. data/lib/earth/residence/residence_class.rb +2 -0
  119. data/lib/earth/residence/residence_fuel_price.rb +2 -0
  120. data/lib/earth/residence/residence_fuel_type.rb +2 -0
  121. data/lib/earth/residence/residential_energy_consumption_survey_response.rb +2 -0
  122. data/lib/earth/residence/urbanity.rb +2 -0
  123. data/lib/earth/shipping/carrier.rb +2 -0
  124. data/lib/earth/shipping/carrier_mode.rb +2 -0
  125. data/lib/earth/shipping/shipment_mode.rb +2 -0
  126. data/lib/earth/version.rb +1 -1
  127. data/spec/earth/air/airline_spec.rb +20 -0
  128. data/spec/earth/air/flight_segment_spec.rb +9 -4
  129. data/spec/earth/automobile/automobile_activity_year_spec.rb +30 -0
  130. data/spec/earth/automobile/automobile_activity_year_type_fuel_spec.rb +25 -0
  131. data/spec/earth/automobile/automobile_activity_year_type_spec.rb +38 -0
  132. data/spec/earth/automobile/automobile_fuel_spec.rb +91 -6
  133. data/spec/earth/automobile/automobile_make_model_spec.rb +74 -0
  134. data/spec/earth/automobile/automobile_make_model_year_spec.rb +90 -0
  135. data/spec/earth/automobile/automobile_make_model_year_variant_spec.rb +139 -90
  136. data/spec/earth/automobile/automobile_make_spec.rb +27 -0
  137. data/spec/earth/automobile/automobile_make_year_fleet_spec.rb +8 -21
  138. data/spec/earth/automobile/automobile_make_year_spec.rb +28 -0
  139. data/spec/earth/automobile/automobile_model_spec.rb +15 -0
  140. data/spec/earth/automobile/automobile_size_class_spec.rb +31 -0
  141. data/spec/earth/automobile/automobile_type_fuel_control_spec.rb +25 -0
  142. data/spec/earth/automobile/automobile_type_fuel_spec.rb +45 -0
  143. data/spec/earth/automobile/automobile_type_fuel_year_control_spec.rb +51 -0
  144. data/spec/earth/automobile/automobile_type_fuel_year_spec.rb +65 -0
  145. data/spec/earth/automobile/automobile_year_spec.rb +23 -0
  146. data/spec/earth/fuel/fuel_spec.rb +1 -1
  147. data/spec/earth/hospitality/commercial_building_energy_consumption_survey_response_spec.rb +11 -3
  148. data/spec/earth_spec.rb +3 -3
  149. data/spec/spec_helper.rb +1 -0
  150. metadata +78 -25
  151. data/lib/earth/automobile/automobile_size_class_year.rb +0 -44
  152. data/lib/earth/automobile/automobile_size_class_year/data_miner.rb +0 -18
  153. data/lib/earth/automobile/automobile_type_fuel_year_age.rb +0 -68
  154. data/lib/earth/automobile/automobile_type_fuel_year_age/data_miner.rb +0 -116
  155. data/lib/earth/automobile/automobile_type_year.rb +0 -58
  156. data/lib/earth/automobile/automobile_type_year/data_miner.rb +0 -30
  157. data/spec/earth/automobile/automobile_type_fuel_year_age_spec.rb +0 -20
@@ -9,4 +9,6 @@ class CensusRegion < ActiveRecord::Base
9
9
 
10
10
  col :number, :type => :integer
11
11
  col :name
12
+
13
+ warn_unless_size 4
12
14
  end
@@ -12,4 +12,6 @@ class ClimateDivision < ActiveRecord::Base
12
12
  col :cooling_degree_days, :type => :float
13
13
  col :cooling_degree_days_units
14
14
  col :state_postal_abbreviation
15
+
16
+ warn_unless_size 359
15
17
  end
@@ -91,4 +91,8 @@ class Country < ActiveRecord::Base
91
91
  col :rail_trip_diesel_intensity_units
92
92
  col :rail_trip_co2_emission_factor, :type => :float
93
93
  col :rail_trip_co2_emission_factor_units
94
+
95
+ warn_if_nulls_except /heating/, /cooling/
96
+
97
+ warn_unless_size 249
94
98
  end
@@ -11,4 +11,7 @@ class EgridRegion < ActiveRecord::Base
11
11
  col :name
12
12
  col :country_name
13
13
  col :loss_factor, :type => :float
14
+
15
+ warn_unless_size 6
16
+ warn_if_blanks_except :country_name, :conditions => { :name => 'US' }
14
17
  end
@@ -34,4 +34,6 @@ class EgridSubregion < ActiveRecord::Base
34
34
  col :electricity_n2o_emission_factor_units
35
35
  col :electricity_emission_factor, :type => :float
36
36
  col :electricity_emission_factor_units
37
+
38
+ warn_unless_size 27
37
39
  end
@@ -13,4 +13,11 @@ class PetroleumAdministrationForDefenseDistrict < ActiveRecord::Base
13
13
  col :district_name
14
14
  col :subdistrict_code
15
15
  col :subdistrict_name
16
+
17
+ warn_if_nulls_except(
18
+ :subdistrict_code,
19
+ :subdistrict_name
20
+ )
21
+
22
+ warn_unless_size 7
16
23
  end
@@ -20,4 +20,11 @@ class State < ActiveRecord::Base
20
20
  col :electricity_emission_factor, :type => :float
21
21
  col :electricity_emission_factor_units
22
22
  col :electricity_loss_factor, :type => :float
23
+
24
+ warn_if_nulls_except(
25
+ :census_division_number,
26
+ :petroleum_administration_for_defense_district_code
27
+ )
28
+
29
+ warn_unless_size 57
23
30
  end
@@ -29,4 +29,8 @@ class ZipCode < ActiveRecord::Base
29
29
  col :egrid_subregion_abbreviation
30
30
  col :climate_division_name
31
31
  col :population, :type => :integer
32
+
33
+ warn_if_nonexistent_owner_except :egrid_subregion
34
+
35
+ warn_unless_size 43770
32
36
  end
@@ -8,4 +8,11 @@ class Breed < ActiveRecord::Base
8
8
  col :species_name
9
9
  col :weight, :type => :float
10
10
  col :weight_units
11
+
12
+ warn_if_nulls_except(
13
+ :weight,
14
+ :weight_units
15
+ )
16
+
17
+ warn_unless_size 522
11
18
  end
@@ -10,7 +10,7 @@ Breed.class_eval do
10
10
  end
11
11
 
12
12
  import "a list of horse breeds", :url => 'http://www.freebase.com/type/exporttypeinstances/base/horses/horse_breed?page=0&filter_mode=type&filter_view=table&show%01p%3D%2Ftype%2Fobject%2Fname%01index=0&show%01p%3D%2Fcommon%2Ftopic%2Fimage%01index=1&show%01p%3D%2Fcommon%2Ftopic%2Farticle%01index=2&sort%01p%3D%2Ftype%2Fobject%2Ftype%01p%3Dlink%01p%3D%2Ftype%2Flink%2Ftimestamp%01index=false&=&exporttype=csv-8' do
13
- key 'name'
13
+ key 'name', :field_name => 'Name'
14
14
  store 'species_name', :static => 'horse'
15
15
  end
16
16
  end
@@ -9,4 +9,6 @@ class BreedGender < ActiveRecord::Base
9
9
  col :gender_name
10
10
  col :weight, :type => :float
11
11
  col :weight_units
12
+
13
+ warn_unless_size 586
12
14
  end
@@ -4,4 +4,6 @@ class Gender < ActiveRecord::Base
4
4
  has_many :breed_genders, :foreign_key => 'gender_name'
5
5
 
6
6
  col :name
7
+
8
+ warn_unless_size 2
7
9
  end
@@ -57,4 +57,6 @@ class Species < ActiveRecord::Base
57
57
  def cat?
58
58
  eql? self.class[:cat]
59
59
  end
60
+
61
+ warn_unless_size 18
60
62
  end
@@ -16,4 +16,6 @@ class CountryRailClass < ActiveRecord::Base
16
16
  col :diesel_intensity_units
17
17
  col :co2_emission_factor, :type => :float
18
18
  col :co2_emission_factor_units
19
+
20
+ warn_unless_size 4
19
21
  end
@@ -12,4 +12,6 @@ class CountryRailTraction < ActiveRecord::Base
12
12
  col :diesel_intensity_units
13
13
  col :co2_emission_factor, :type => :float
14
14
  col :co2_emission_factor_units
15
+
16
+ warn_unless_size 50
15
17
  end
@@ -13,4 +13,6 @@ class CountryRailTractionClass < ActiveRecord::Base
13
13
  col :diesel_intensity_units
14
14
  col :co2_emission_factor, :type => :float
15
15
  col :co2_emission_factor_units
16
+
17
+ warn_unless_size 125
16
18
  end
@@ -36,4 +36,11 @@ class NationalTransitDatabaseCompany < ActiveRecord::Base
36
36
  col :acronym
37
37
  col :zip_code_name
38
38
  col :duns_number
39
+
40
+ warn_if_nulls_except(
41
+ :acronym,
42
+ :duns_number
43
+ )
44
+
45
+ warn_unless_size 710
39
46
  end
@@ -9,4 +9,6 @@ class NationalTransitDatabaseMode < ActiveRecord::Base
9
9
  col :code
10
10
  col :name
11
11
  col :rail_mode, :type => :boolean
12
+
13
+ warn_unless_size 14
12
14
  end
@@ -39,4 +39,26 @@ class NationalTransitDatabaseRecord < ActiveRecord::Base
39
39
  col :other_fuel, :type => :float
40
40
  col :other_fuel_units
41
41
  col :other_fuel_description
42
+
43
+ warn_if_nulls_except(
44
+ :electricity,
45
+ :electricity_units,
46
+ :diesel,
47
+ :diesel_units,
48
+ :lpg,
49
+ :lpg_units,
50
+ :lng,
51
+ :lng_units,
52
+ :cng,
53
+ :cng_units,
54
+ :kerosene,
55
+ :kerosene_units,
56
+ :biodiesel,
57
+ :biodiesel_units,
58
+ :other_fuel,
59
+ :other_fuel_units,
60
+ :other_fuel_description
61
+ )
62
+
63
+ warn_unless_size 1310
42
64
  end
@@ -2,4 +2,6 @@ class RailClass < ActiveRecord::Base
2
2
  self.primary_key = "name"
3
3
 
4
4
  col :name
5
+
6
+ warn_unless_size 6
5
7
  end
@@ -25,4 +25,20 @@ class RailCompany < ActiveRecord::Base
25
25
  col :diesel_intensity_units
26
26
  col :co2_emission_factor, :type => :float
27
27
  col :co2_emission_factor_units
28
+
29
+ warn_if_nulls_except(
30
+ :duns_number,
31
+ :train_time,
32
+ :train_time_units,
33
+ :speed,
34
+ :speed_units,
35
+ :electricity_intensity,
36
+ :electricity_intensity_units,
37
+ :diesel_intensity,
38
+ :diesel_intensity_units,
39
+ :co2_emission_factor,
40
+ :co2_emission_factor_units
41
+ )
42
+
43
+ warn_unless_size 97
28
44
  end
@@ -12,4 +12,6 @@ class RailFuel < ActiveRecord::Base
12
12
  col :ch4_emission_factor_units
13
13
  col :n2o_emission_factor, :type => :float
14
14
  col :n2o_emission_factor_units
15
+
16
+ warn_unless_size 1
15
17
  end
@@ -2,4 +2,6 @@ class RailTraction < ActiveRecord::Base
2
2
  self.primary_key = "name"
3
3
 
4
4
  col :name
5
+
6
+ warn_unless_size 2
5
7
  end
@@ -9,4 +9,6 @@ class AirConditionerUse < ActiveRecord::Base
9
9
  col :name
10
10
  col :fugitive_emission, :type => :float
11
11
  col :fugitive_emission_units
12
+
13
+ warn_unless_size 4
12
14
  end
@@ -6,4 +6,6 @@ class ClothesMachineUse < ActiveRecord::Base
6
6
  col :name
7
7
  col :annual_energy_from_electricity_for_clothes_driers, :type => :float
8
8
  col :annual_energy_from_electricity_for_clothes_driers_units
9
+
10
+ warn_unless_size 5
9
11
  end
@@ -6,4 +6,6 @@ class DishwasherUse < ActiveRecord::Base
6
6
  col :name
7
7
  col :annual_energy_from_electricity_for_dishwashers, :type => :float
8
8
  col :annual_energy_from_electricity_for_dishwashers_units
9
+
10
+ warn_unless_size 5
9
11
  end
@@ -13,4 +13,6 @@ class ResidenceAppliance < ActiveRecord::Base
13
13
  col :name
14
14
  col :annual_energy_from_electricity, :type => :float
15
15
  col :annual_energy_from_electricity_units
16
+
17
+ warn_unless_size 2
16
18
  end
@@ -10,4 +10,6 @@ class ResidenceClass < ActiveRecord::Base
10
10
  end
11
11
 
12
12
  col :name
13
+
14
+ warn_unless_size 5
13
15
  end
@@ -16,4 +16,6 @@ class ResidenceFuelPrice < ActiveRecord::Base
16
16
  col :locatable_type
17
17
  add_index [:price, :residence_fuel_type_name, :month, :year, :locatable_type, :locatable_id]
18
18
  add_index [:price, :residence_fuel_type_name]
19
+
20
+ warn_unless_size 13005
19
21
  end
@@ -34,4 +34,6 @@ class ResidenceFuelType < ActiveRecord::Base
34
34
  find_by_name fuel.to_s.humanize.downcase
35
35
  end
36
36
  end
37
+
38
+ warn_unless_size 7
37
39
  end
@@ -118,4 +118,6 @@ class ResidentialEnergyConsumptionSurveyResponse < ActiveRecord::Base
118
118
  col :urbanity_id
119
119
  col :weighting, :type => :float
120
120
  col :window_ac_use
121
+
122
+ warn_unless_size 4382
121
123
  end
@@ -4,4 +4,6 @@ class Urbanity < ActiveRecord::Base
4
4
  has_many :residential_energy_consumption_survey_responses
5
5
 
6
6
  col :name
7
+
8
+ warn_unless_size 4
7
9
  end
@@ -65,4 +65,6 @@ class Carrier < ActiveRecord::Base
65
65
  # end
66
66
  # end
67
67
 
68
+
69
+ warn_unless_size 3
68
70
  end
@@ -44,4 +44,6 @@ class CarrierMode < ActiveRecord::Base
44
44
  # end
45
45
  # end
46
46
  # end
47
+
48
+ warn_unless_size 9
47
49
  end
@@ -32,4 +32,6 @@ class ShipmentMode < ActiveRecord::Base
32
32
  # end
33
33
  # end
34
34
 
35
+
36
+ warn_unless_size 3
35
37
  end
data/lib/earth/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Earth
2
- VERSION = "0.11.20"
2
+ VERSION = "0.12.0"
3
3
  end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+ require 'earth/air/airline'
3
+
4
+ describe Airline do
5
+ before :all do
6
+ Earth.init :air, :load_data_miner => true, :skip_parent_associations => :true
7
+ end
8
+
9
+ describe 'import', :data_miner => true do
10
+ it 'should import data' do
11
+ Airline.run_data_miner!
12
+ end
13
+ end
14
+
15
+ describe "verify imported data", :sanity => true do
16
+ it "should have all the data" do
17
+ Airline.count.should == 1522
18
+ end
19
+ end
20
+ end
@@ -23,6 +23,12 @@ describe FlightSegment do
23
23
  FlightSegment.where("year IS NULL OR year < 2009 OR year > #{::Time.now.year}").count.should == 0
24
24
  end
25
25
 
26
+ it "should have data through 7 months ago" do
27
+ latest = Date.today << 7
28
+ FlightSegment.maximum(:year).should == latest.year
29
+ FlightSegment.where(:year => latest.year).maximum(:month).should == latest.month
30
+ end
31
+
26
32
  it "should have origin airport in airports" do
27
33
  # FIXME TODO
28
34
  end
@@ -39,10 +45,9 @@ describe FlightSegment do
39
45
  # FIXME TODO
40
46
  end
41
47
 
42
- # FIXME TODO fix this
43
- # it "should have airline name" do
44
- # FlightSegment.where(:airline_name => nil).count.should == 0
45
- # end
48
+ it "should have airline name" do
49
+ FlightSegment.where(:airline_name => nil).count.should == 0
50
+ end
46
51
 
47
52
  it "should have aircraft description" do
48
53
  FlightSegment.where(:aircraft_description => nil).count.should == 0
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+ require 'earth/automobile/automobile_activity_year'
3
+
4
+ describe AutomobileActivityYear do
5
+ before :all do
6
+ Earth.init :automobile, :load_data_miner => true
7
+ require 'earth/acronyms'
8
+ end
9
+
10
+ describe 'import', :data_miner => true do
11
+ it 'should import data' do
12
+ AAY.run_data_miner!
13
+ end
14
+ end
15
+
16
+ describe 'verify', :sanity => true do
17
+ it { AAY.count.should == 15 }
18
+ it { AAY.where("hfc_emission_factor > 0").count.should == AAY.count }
19
+
20
+ # spot check
21
+ it { AAY.first.hfc_emission_factor.should be_within(1e-5).of(0.01656) }
22
+ it { AAY.first.hfc_emission_factor_units.should == 'kilograms_co2e_per_kilometre' }
23
+ end
24
+
25
+ describe '.find_by_closest_year' do
26
+ it { AAY.find_by_closest_year(1994).should == AAY.find(1995) }
27
+ it { AAY.find_by_closest_year(2005).should == AAY.find(2005) }
28
+ it { AAY.find_by_closest_year(2010).should == AAY.find(2009) }
29
+ end
30
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+ require 'earth/automobile/automobile_activity_year_type_fuel'
3
+
4
+ describe AutomobileActivityYearTypeFuel do
5
+ before :all do
6
+ Earth.init :automobile, :load_data_miner => true
7
+ require 'earth/acronyms'
8
+ end
9
+
10
+ describe 'import', :data_miner => true do
11
+ it 'should import data' do
12
+ AAYTF.run_data_miner!
13
+ end
14
+ end
15
+
16
+ describe 'verify', :sanity => true do
17
+ it { AAYTF.count.should == 120 }
18
+ it { AAYTF.where(:distance => nil).count.should == 0 }
19
+ it { AAYTF.where("fuel_common_name != 'alternative' AND fuel_consumption IS NULL").count.should == 0 }
20
+ end
21
+
22
+ describe '.latest' do
23
+ it { AAYTF.latest.should == AAYTF.where(:activity_year => 2009) }
24
+ end
25
+ end