earth 0.4.4 → 0.4.5
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/README.markdown +1 -1
- data/Rakefile +44 -16
- data/earth.gemspec +4 -8
- data/features/automobile_make_model_year_variant.feature +4 -4
- data/features/step_definitions/data_steps.rb +32 -0
- data/features/support/env.rb +6 -3
- data/features/support/imports/automobile_make_model_year_variant_bad.csv +1 -1
- data/features/support/imports/automobile_make_model_year_variant_good.csv +1 -1
- data/lib/earth/air/aircraft/data_miner.rb +1 -1
- data/lib/earth/air/aircraft_class/data_miner.rb +1 -1
- data/lib/earth/air/flight_distance_class/data_miner.rb +1 -1
- data/lib/earth/air/flight_seat_class/data_miner.rb +2 -2
- data/lib/earth/automobile/automobile_fuel/data_miner.rb +9 -2
- data/lib/earth/automobile/automobile_make/data_miner.rb +1 -1
- data/lib/earth/automobile/automobile_make_fleet_year/data_miner.rb +1 -1
- data/lib/earth/automobile/automobile_make_model_year_variant/data_miner.rb +2 -16
- data/lib/earth/automobile/automobile_make_model_year_variant.rb +0 -1
- data/lib/earth/automobile/automobile_size_class/data_miner.rb +2 -2
- data/lib/earth/automobile/automobile_size_class_year/data_miner.rb +1 -1
- data/lib/earth/automobile/automobile_type_fuel_control/data_miner.rb +1 -1
- data/lib/earth/automobile/automobile_type_fuel_year/data_miner.rb +1 -1
- data/lib/earth/automobile/automobile_type_fuel_year_control/data_miner.rb +1 -1
- data/lib/earth/automobile/automobile_type_year/data_miner.rb +1 -1
- data/lib/earth/automobile/data_miner.rb +0 -1
- data/lib/earth/automobile.rb +0 -1
- data/lib/earth/bus/bus_class/data_miner.rb +1 -1
- data/lib/earth/bus/bus_fuel/data_miner.rb +3 -3
- data/lib/earth/bus/bus_fuel_control/data_miner.rb +1 -1
- data/lib/earth/bus/bus_fuel_year_control/data_miner.rb +1 -1
- data/lib/earth/computation/computation_platform/data_miner.rb +1 -1
- data/lib/earth/computation/data_center_company/data_miner.rb +1 -1
- data/lib/earth/computation/server_type/data_miner.rb +1 -1
- data/lib/earth/computation/server_type_alias/data_miner.rb +1 -1
- data/lib/earth/diet/food_group/data_miner.rb +1 -1
- data/lib/earth/fuel/fuel/data_miner.rb +2 -2
- data/lib/earth/fuel/fuel_price/data_miner.rb +1 -1
- data/lib/earth/fuel/fuel_type/data_miner.rb +1 -1
- data/lib/earth/fuel/fuel_year/data_miner.rb +1 -1
- data/lib/earth/fuel/greenhouse_gas/data_miner.rb +1 -1
- data/lib/earth/hospitality/lodging_class/data_miner.rb +1 -1
- data/lib/earth/locality/census_division/data_miner.rb +2 -2
- data/lib/earth/locality/country/data_miner.rb +1 -1
- data/lib/earth/locality/egrid_subregion/data_miner.rb +1 -1
- data/lib/earth/locality/petroleum_administration_for_defense_district/data_miner.rb +1 -1
- data/lib/earth/locality/state/data_miner.rb +1 -1
- data/lib/earth/rail/rail_class/data_miner.rb +1 -1
- data/lib/earth/residence/air_conditioner_use/data_miner.rb +1 -1
- data/lib/earth/residence/residence_fuel_type/data_miner.rb +1 -1
- data/lib/earth/shipping/carrier/data_miner.rb +1 -1
- data/lib/earth/shipping/carrier_mode/data_miner.rb +1 -1
- data/lib/earth/shipping/shipment_mode/data_miner.rb +1 -1
- data/lib/earth/version.rb +1 -1
- data/spec/earth_spec.rb +2 -2
- metadata +38 -116
- data/features/automobile_fuel_type.feature +0 -34
- data/features/support/imports/automobile_fuel_type_bad.csv +0 -3
- data/features/support/imports/automobile_fuel_type_good.csv +0 -3
- data/lib/earth/automobile/automobile_fuel_type/data_miner.rb +0 -115
- data/lib/earth/automobile/automobile_fuel_type.rb +0 -17
data/README.markdown
CHANGED
@@ -8,7 +8,7 @@ The data that these models represent can be pulled from http://data.brighterplan
|
|
8
8
|
|
9
9
|
require 'earth'
|
10
10
|
Earth.init :automobile, :locality
|
11
|
-
ft =
|
11
|
+
ft = AutomobileFuel.first
|
12
12
|
...
|
13
13
|
|
14
14
|
You can also run data imports via the data_miner gem.
|
data/Rakefile
CHANGED
@@ -5,23 +5,51 @@ Bundler::GemHelper.install_tasks
|
|
5
5
|
require 'bueller'
|
6
6
|
Bueller::Tasks.new
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
8
|
+
task :console do
|
9
|
+
Earth.init :all
|
10
|
+
|
11
|
+
require 'irb'
|
12
|
+
ARGV.clear
|
13
|
+
IRB.start
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Run all cucumber tests'
|
17
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
18
|
+
if ENV['CUCUMBER_FORMAT']
|
19
|
+
t.cucumber_opts = "features --format #{ENV['CUCUMBER_FORMAT']}"
|
20
|
+
else
|
21
|
+
t.cucumber_opts = 'features --format pretty'
|
16
22
|
end
|
17
|
-
rescue LoadError
|
18
|
-
puts "Rdoc is not available"
|
19
23
|
end
|
20
24
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
t.
|
25
|
-
t.
|
26
|
-
|
25
|
+
desc "Run cucumber tests with RCov"
|
26
|
+
Cucumber::Rake::Task.new(:features_with_coverage) do |t|
|
27
|
+
t.cucumber_opts = "features --format pretty"
|
28
|
+
t.rcov = true
|
29
|
+
t.rcov_opts = ['--exclude', 'features']
|
30
|
+
end
|
31
|
+
|
32
|
+
require 'rspec/core/rake_task'
|
33
|
+
|
34
|
+
desc "Run all examples"
|
35
|
+
RSpec::Core::RakeTask.new(:examples) do |c|
|
36
|
+
c.rspec_opts = '-Ispec'
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "Run specs with RCov"
|
40
|
+
RSpec::Core::RakeTask.new(:examples_with_coverage) do |t|
|
41
|
+
t.rcov = true
|
42
|
+
t.rcov_opts = ['--exclude', 'spec']
|
43
|
+
t.rspec_opts = '-Ispec'
|
44
|
+
end
|
45
|
+
|
46
|
+
task :test => [:features, :examples]
|
47
|
+
task :default => :test
|
48
|
+
|
49
|
+
require 'earth/version'
|
50
|
+
Rake::RDocTask.new do |rdoc|
|
51
|
+
rdoc.rdoc_dir = 'rdoc'
|
52
|
+
rdoc.title = "#{gemname} #{Earth::VERSION}"
|
53
|
+
rdoc.rdoc_files.include('README*')
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
27
55
|
end
|
data/earth.gemspec
CHANGED
@@ -4,8 +4,8 @@ require "earth/version"
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "earth"
|
7
|
-
s.version
|
8
|
-
s.date = "2011-
|
7
|
+
s.version = Earth::VERSION
|
8
|
+
s.date = "2011-03-04"
|
9
9
|
s.platform = Gem::Platform::RUBY
|
10
10
|
s.authors = ["Seamus Abshere", "Derek Kastner", "Andy Rossmeissl"]
|
11
11
|
s.email = %q{andy@rossmeissl.net}
|
@@ -28,14 +28,10 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.rubygems_version = %q{1.3.7}
|
29
29
|
|
30
30
|
s.add_runtime_dependency 'activerecord', '~> 3'
|
31
|
+
s.add_runtime_dependency 'cohort_scope', '>= 0.0.7'
|
31
32
|
s.add_runtime_dependency 'data_miner', '~> 1.1.1'
|
32
|
-
s.add_runtime_dependency 'errata'
|
33
33
|
s.add_runtime_dependency 'falls_back_on', '>= 0.0.3'
|
34
|
-
s.add_runtime_dependency 'geokit', '>= 1.5.0'
|
35
34
|
s.add_runtime_dependency 'geokit-rails'
|
36
|
-
s.add_runtime_dependency 'cohort_scope', '>= 0.0.7'
|
37
|
-
s.add_runtime_dependency 'conversions', '>= 1.4.5'
|
38
|
-
s.add_runtime_dependency 'weighted_average', '>= 0.0.4'
|
39
35
|
s.add_runtime_dependency 'loose_tight_dictionary', '>= 0.0.8'
|
40
|
-
s.
|
36
|
+
s.add_runtime_dependency 'weighted_average', '>= 0.0.4'
|
41
37
|
end
|
@@ -9,9 +9,9 @@ Feature: Data import for AutomobileMakeModelYearVariant
|
|
9
9
|
Then the verification should be successful
|
10
10
|
|
11
11
|
# FIXME TODO
|
12
|
-
# Scenario: Successfully verifying that fuel type code is found in
|
12
|
+
# Scenario: Successfully verifying that fuel type code is found in AutomobileFuel
|
13
13
|
# Given a "AutomobileMakeModelYearVariant" data import fetches results listed in "automobile_make_model_year_variant_good"
|
14
|
-
# When a data import verifies "Fuel type code should be found in
|
14
|
+
# When a data import verifies "Fuel type code should be found in AutomobileFuel"
|
15
15
|
# Then the verification should be successful
|
16
16
|
|
17
17
|
Scenario: Successfully verifying that fuel efficiencies are greater than zero
|
@@ -30,9 +30,9 @@ Feature: Data import for AutomobileMakeModelYearVariant
|
|
30
30
|
Then the verification should not be successful
|
31
31
|
|
32
32
|
# FIXME TODO
|
33
|
-
# Scenario: Failing to verify that fuel type code is found in
|
33
|
+
# Scenario: Failing to verify that fuel type code is found in AutomobileFuel
|
34
34
|
# Given a "AutomobileMakeModelYearVariant" data import fetches results listed in "automobile_make_model_year_variant_bad"
|
35
|
-
# When a data import verifies "Fuel type code should be found in
|
35
|
+
# When a data import verifies "Fuel type code should be found in AutomobileFuel"
|
36
36
|
# Then the verification should not be successful
|
37
37
|
|
38
38
|
Scenario: Failing to verify that fuel efficiencies are greater than zero
|
@@ -0,0 +1,32 @@
|
|
1
|
+
Given /^a "([^\"]*)" data import fetches results listed in "(.*)"$/ do |model, file_name|
|
2
|
+
@data_import_model = model.constantize
|
3
|
+
table_name = @data_import_model.table_name
|
4
|
+
|
5
|
+
fixture_path = File.expand_path("features/support/imports/#{file_name}", Dir.pwd)
|
6
|
+
|
7
|
+
fixture = Fixtures.new @data_import_model.connection, table_name, model, fixture_path
|
8
|
+
|
9
|
+
@data_import_model.connection.transaction(:requires_new => true) do
|
10
|
+
fixture.delete_existing_fixtures
|
11
|
+
fixture.insert_fixtures
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
When /^a data import verifies "(.*)"$/ do |verification_step_name|
|
16
|
+
@verification = @data_import_model.data_miner_config.steps.find { |f|
|
17
|
+
f.respond_to?(:description) and f.description == verification_step_name
|
18
|
+
}
|
19
|
+
@verification_result = begin
|
20
|
+
@verification.run
|
21
|
+
true
|
22
|
+
rescue => e
|
23
|
+
false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
Then /^the verification should be successful$/ do
|
28
|
+
@verification_result.should be_true
|
29
|
+
end
|
30
|
+
Then /^the verification should not be successful$/ do
|
31
|
+
@verification_result.should be_false
|
32
|
+
end
|
data/features/support/env.rb
CHANGED
@@ -4,7 +4,10 @@ require 'bundler'
|
|
4
4
|
Bundler.setup
|
5
5
|
|
6
6
|
require 'data_miner'
|
7
|
-
DataMiner.logger = Logger.new
|
7
|
+
DataMiner.logger = Logger.new nil
|
8
8
|
|
9
|
-
require '
|
10
|
-
|
9
|
+
require 'active_record'
|
10
|
+
require 'sqlite3'
|
11
|
+
ActiveRecord::Base.logger = Logger.new nil
|
12
|
+
ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => ':memory:'
|
13
|
+
Earth.init :all, :apply_schemas => true
|
@@ -1,3 +1,3 @@
|
|
1
|
-
row_hash,year,
|
1
|
+
row_hash,year,fuel_code,fuel_efficiency,fuel_efficiency_city,fuel_efficiency_highway,fuel_efficiency_units,fuel_efficiency_city_units,fuel_efficiency_highway_units
|
2
2
|
a1,2000,D,12.0,10.0,15.0,kilometres_per_litre,kilometres_per_litre,kilometres_per_litre
|
3
3
|
b2,2011,P,0,-10,0,foo,bar
|
@@ -1,3 +1,3 @@
|
|
1
|
-
row_hash,year,
|
1
|
+
row_hash,year,fuel_code,fuel_efficiency,fuel_efficiency_city,fuel_efficiency_highway,fuel_efficiency_units,fuel_efficiency_city_units,fuel_efficiency_highway_units
|
2
2
|
a1,2000,D,12.0,10.0,15.0,kilometres_per_litre,kilometres_per_litre,kilometres_per_litre
|
3
3
|
b2,2010,X,20.5,20.0,21.0,kilometres_per_litre,kilometres_per_litre,kilometres_per_litre
|
@@ -108,7 +108,7 @@ Aircraft.class_eval do
|
|
108
108
|
end
|
109
109
|
|
110
110
|
import "a curated list of aircraft",
|
111
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdDJFblR4MDE1RGtnLVM1S2JHRGZpT3c&hl=en&
|
111
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdDJFblR4MDE1RGtnLVM1S2JHRGZpT3c&hl=en&gid=0&output=csv' do
|
112
112
|
key 'bp_code'
|
113
113
|
store 'icao_code', :nullify => true
|
114
114
|
store 'bts_code', :nullify => true
|
@@ -11,7 +11,7 @@ AircraftClass.class_eval do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
import "a list of Brighter Planet-defined aircraft classes",
|
14
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGNBbHFibmxJUFprQkUwZHp6VU51Smc&hl=en&
|
14
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGNBbHFibmxJUFprQkUwZHp6VU51Smc&hl=en&gid=0&output=csv' do
|
15
15
|
key 'code', :field_name => 'aircraft_class_code'
|
16
16
|
store 'name'
|
17
17
|
end
|
@@ -7,7 +7,7 @@ FlightDistanceClass.class_eval do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
import "a list of distance classes taken from the WRI business travel tool and UK DEFRA/DECC GHG Conversion Factors for Company Reporting",
|
10
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdFBKM0xWaUhKVkxDRmdBVkE3VklxY2c&hl=en&
|
10
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdFBKM0xWaUhKVkxDRmdBVkE3VklxY2c&hl=en&gid=0&output=csv' do
|
11
11
|
key 'name'
|
12
12
|
store 'distance', :units_field_name => 'distance_units'
|
13
13
|
end
|
@@ -7,8 +7,8 @@ FlightSeatClass.class_eval do
|
|
7
7
|
float 'multiplier'
|
8
8
|
end
|
9
9
|
|
10
|
-
import "
|
11
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdG5zSER1QmFVVkhNcTM2cmhCMEJtWVE&hl=en&
|
10
|
+
import "seat classes used in the WRI GHG Protocol calculation tools",
|
11
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdG5zSER1QmFVVkhNcTM2cmhCMEJtWVE&hl=en&gid=0&output=csv' do
|
12
12
|
key 'name'
|
13
13
|
store 'distance_class_name'
|
14
14
|
store 'seat_class_name'
|
@@ -20,10 +20,12 @@ AutomobileFuel.class_eval do
|
|
20
20
|
string 'n2o_emission_factor_units'
|
21
21
|
float 'hfc_emission_factor'
|
22
22
|
string 'hfc_emission_factor_units'
|
23
|
+
float 'emission_factor' # DEPRECATED but motorcycle needs this
|
24
|
+
string 'emission_factor_units' # DEPRECATED but motorcycle needs this
|
23
25
|
end
|
24
26
|
|
25
27
|
import "a list of pure automobile fuels",
|
26
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdE9xTEdueFM2R0diNTgxUlk1QXFSb2c&output=
|
28
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdE9xTEdueFM2R0diNTgxUlk1QXFSb2c&gid=0&output=html' do
|
27
29
|
key 'name'
|
28
30
|
store 'code'
|
29
31
|
store 'base_fuel_name'
|
@@ -32,7 +34,7 @@ AutomobileFuel.class_eval do
|
|
32
34
|
end
|
33
35
|
|
34
36
|
import "a list of blended automobile fuels",
|
35
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdEswNGIxM0U4U0N1UUppdWw2ejJEX0E&output=csv' do
|
37
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdEswNGIxM0U4U0N1UUppdWw2ejJEX0E&gid=0&output=csv' do
|
36
38
|
key 'name'
|
37
39
|
store 'code'
|
38
40
|
store 'base_fuel_name'
|
@@ -96,6 +98,11 @@ AutomobileFuel.class_eval do
|
|
96
98
|
end
|
97
99
|
end
|
98
100
|
|
101
|
+
process "Derive emission factor" do
|
102
|
+
update_all "emission_factor = co2_emission_factor + ch4_emission_factor + n2o_emission_factor + hfc_emission_factor,
|
103
|
+
emission_factor_units = 'kilograms_co2e_per_litre'"
|
104
|
+
end
|
105
|
+
|
99
106
|
# FIXME TODO verify code somehow
|
100
107
|
|
101
108
|
%w{ base_fuel_name distance_key ef_key }.each do |attribute|
|
@@ -23,7 +23,7 @@ AutomobileMake.class_eval do
|
|
23
23
|
# sabshere 1/31/11 add Avanti, DaimlerChrysler, IHC, Tesla, etc.
|
24
24
|
process "Derive extra manufacturer names from CAFE data" do
|
25
25
|
AutomobileMakeFleetYear.run_data_miner!
|
26
|
-
|
26
|
+
INSERT_IGNORE %{INTO automobile_makes(name)
|
27
27
|
SELECT DISTINCT automobile_make_fleet_years.make_name
|
28
28
|
FROM automobile_make_fleet_years
|
29
29
|
}
|
@@ -12,7 +12,7 @@ AutomobileMakeFleetYear.class_eval do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
import "annual corporate average fuel economy data for domestic and imported vehicle fleets from the NHTSA",
|
15
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdEdXWXB6dkVLWkowLXhYSFVUT01sS2c&hl=en&
|
15
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdEdXWXB6dkVLWkowLXhYSFVUT01sS2c&hl=en&gid=0&output=csv',
|
16
16
|
:errata => { 'url' => 'http://static.brighterplanet.com/science/data/transport/automobiles/make_fleet_years/errata.csv' },
|
17
17
|
:select => lambda { |row| row['volume'].to_i > 0 } do
|
18
18
|
key 'name', :synthesize => lambda { |row| [ row['manufacturer_name'], row['year_content'], row['fleet'][2,2] ].join ' ' }
|
@@ -271,7 +271,6 @@ AutomobileMakeModelYearVariant.class_eval do
|
|
271
271
|
string 'fuel_efficiency_city_units'
|
272
272
|
float 'fuel_efficiency_highway'
|
273
273
|
string 'fuel_efficiency_highway_units'
|
274
|
-
string 'fuel_type_code'
|
275
274
|
string 'fuel_code'
|
276
275
|
string 'transmission'
|
277
276
|
string 'drive'
|
@@ -315,7 +314,6 @@ AutomobileMakeModelYearVariant.class_eval do
|
|
315
314
|
store 'name', :field_name => 'model'
|
316
315
|
store 'make_name', :field_name => 'make'
|
317
316
|
store 'year'
|
318
|
-
store 'fuel_type_code', :field_name => 'fuel_type'
|
319
317
|
store 'fuel_code', :field_name => 'fuel_type'
|
320
318
|
store 'fuel_efficiency_highway', :static => nil, :units => :kilometres_per_litre
|
321
319
|
store 'fuel_efficiency_city', :static => nil, :units => :kilometres_per_litre
|
@@ -354,7 +352,6 @@ AutomobileMakeModelYearVariant.class_eval do
|
|
354
352
|
key 'row_hash'
|
355
353
|
store 'name', :field_name => 'model'
|
356
354
|
store 'make_name', :field_name => 'make'
|
357
|
-
store 'fuel_type_code', :field_name => 'fl'
|
358
355
|
store 'fuel_code', :field_name => 'fl'
|
359
356
|
store 'fuel_efficiency_highway', :static => nil, :units => :kilometres_per_litre
|
360
357
|
store 'fuel_efficiency_city', :static => nil, :units => :kilometres_per_litre
|
@@ -389,7 +386,6 @@ AutomobileMakeModelYearVariant.class_eval do
|
|
389
386
|
key 'row_hash'
|
390
387
|
store 'name', :field_name => 'model'
|
391
388
|
store 'make_name', :field_name => 'make'
|
392
|
-
store 'fuel_type_code', :field_name => 'FUEL TYPE'
|
393
389
|
store 'fuel_code', :field_name => 'FUEL TYPE'
|
394
390
|
store 'fuel_efficiency_highway', :static => nil, :units => :kilometres_per_litre
|
395
391
|
store 'fuel_efficiency_city', :static => nil, :units => :kilometres_per_litre
|
@@ -420,7 +416,6 @@ AutomobileMakeModelYearVariant.class_eval do
|
|
420
416
|
key 'row_hash'
|
421
417
|
store 'name', :field_name => 'model'
|
422
418
|
store 'make_name', :field_name => 'make'
|
423
|
-
store 'fuel_type_code'
|
424
419
|
store 'fuel_code', :field_name => 'fuel_type_code'
|
425
420
|
store 'fuel_efficiency_highway', :static => nil, :units => :kilometres_per_litre
|
426
421
|
store 'fuel_efficiency_city', :static => nil, :units => :kilometres_per_litre
|
@@ -479,17 +474,8 @@ AutomobileMakeModelYearVariant.class_eval do
|
|
479
474
|
end
|
480
475
|
end
|
481
476
|
|
482
|
-
# FIXME TODO
|
483
|
-
|
484
|
-
# valid_codes = AutomobileFuelType.all.map(&:code)
|
485
|
-
# puts valid_codes
|
486
|
-
# AutomobileMakeModelVariant.all.each do |variant|
|
487
|
-
# unless valid_codes.include? variant.fuel_type_code
|
488
|
-
# raise "Invalid fuel type code for AutomobileMakeModelYearVariant #{variant.row_hash}: #{variant.fuel_type_code} (should be found in AutomobileFuelType)"
|
489
|
-
# end
|
490
|
-
# end
|
491
|
-
# end
|
492
|
-
#
|
477
|
+
# FIXME TODO verify fuel code appears in AutomobileFuel
|
478
|
+
|
493
479
|
verify "Fuel efficiencies should be greater than zero" do
|
494
480
|
AutomobileMakeModelYearVariant.all.each do |variant|
|
495
481
|
[:fuel_efficiency, :fuel_efficiency_city, :fuel_efficiency_highway].each do |type|
|
@@ -4,7 +4,6 @@ class AutomobileMakeModelYearVariant < ActiveRecord::Base
|
|
4
4
|
belongs_to :make, :class_name => 'AutomobileMake', :foreign_key => 'make_name'
|
5
5
|
belongs_to :make_model, :class_name => 'AutomobileMakeModel', :foreign_key => 'make_model_name'
|
6
6
|
belongs_to :make_model_year, :class_name => 'AutomobileMakeModelYear', :foreign_key => 'make_model_year_name'
|
7
|
-
belongs_to :fuel_type, :class_name => 'AutomobileFuelType', :foreign_key => 'fuel_type_code'
|
8
7
|
belongs_to :fuel, :class_name => 'AutomobileFuel', :foreign_key => 'fuel_code', :primary_key => 'code'
|
9
8
|
|
10
9
|
data_miner do
|
@@ -17,7 +17,7 @@ AutomobileSizeClass.class_eval do
|
|
17
17
|
|
18
18
|
# FIXME TODO pull this from AutomobileSizeClassYear
|
19
19
|
import "a list of size classes and pre-calculated fuel efficiencies",
|
20
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdHlRUE5IcWlrRENhN0EtUldPTy1rX1E&
|
20
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdHlRUE5IcWlrRENhN0EtUldPTy1rX1E&gid=0&output=csv' do
|
21
21
|
key 'name'
|
22
22
|
store 'type_name'
|
23
23
|
store 'fuel_efficiency_city', :units_field_name => 'fuel_efficiency_city_units'
|
@@ -35,7 +35,7 @@ AutomobileSizeClass.class_eval do
|
|
35
35
|
end
|
36
36
|
|
37
37
|
import "pre-calculated fuel efficiency multipliers",
|
38
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGt2NnhXLXUxNFRJSzczU3BkSHB3enc&hl=en&
|
38
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGt2NnhXLXUxNFRJSzczU3BkSHB3enc&hl=en&gid=0&output=csv' do
|
39
39
|
key 'name'
|
40
40
|
store 'hybrid_fuel_efficiency_city_multiplier'
|
41
41
|
store 'hybrid_fuel_efficiency_highway_multiplier'
|
@@ -12,7 +12,7 @@ AutomobileSizeClassYear.class_eval do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
import "automobile size class year fuel efficiencies from the 2010 EPA Fuel Economy Trends report",
|
15
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdDZOLWdDdlZja04xZkJYc3NjeGxQamc&hl=en&
|
15
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdDZOLWdDdlZja04xZkJYc3NjeGxQamc&hl=en&gid=0&output=csv' do
|
16
16
|
key 'name'
|
17
17
|
store 'size_class_name'
|
18
18
|
store 'year'
|
@@ -12,7 +12,7 @@ AutomobileTypeFuelControl.class_eval do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
import "automobile type fuel control data derived from the 2010 EPA GHG Inventory",
|
15
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdEloSTU5YUNOUXRFRUcxWHlTUi1GMkE&hl=en&output=csv' do
|
15
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdEloSTU5YUNOUXRFRUcxWHlTUi1GMkE&hl=en&gid=0&output=csv' do
|
16
16
|
key 'name'
|
17
17
|
store 'type_name'
|
18
18
|
store 'fuel_common_name'
|
@@ -75,7 +75,7 @@ AutomobileTypeFuelYear.class_eval do
|
|
75
75
|
end
|
76
76
|
|
77
77
|
import "fuel consumption derived from the 2010 EPA GHG Inventory",
|
78
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdHBCMFhLRTFTZENsd0dPUGUyYlJna0E&hl=en&output=csv' do
|
78
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdHBCMFhLRTFTZENsd0dPUGUyYlJna0E&hl=en&gid=0&output=csv' do
|
79
79
|
key 'name'
|
80
80
|
store 'fuel_consumption', :units_field_name => 'fuel_consumption_units'
|
81
81
|
end
|
@@ -12,7 +12,7 @@ AutomobileTypeFuelYearControl.class_eval do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
import "automobile type fuel year control data derived from the 2010 EPA GHG Inventory",
|
15
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGpQV2xMdlZkV1JzVlVTeU5ZalF6elE&hl=en&output=csv' do
|
15
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGpQV2xMdlZkV1JzVlVTeU5ZalF6elE&hl=en&gid=0&output=csv' do
|
16
16
|
key 'name'
|
17
17
|
store 'type_name'
|
18
18
|
store 'fuel_common_name'
|
@@ -11,7 +11,7 @@ AutomobileTypeYear.class_eval do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
import "automobile type year air conditioning emissions derived from the 2010 EPA GHG Inventory",
|
14
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdFoyTWhDeHpndTV5Ny1aX0sxR1ljSFE&hl=en&output=csv' do
|
14
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdFoyTWhDeHpndTV5Ny1aX0sxR1ljSFE&hl=en&gid=0&output=csv' do
|
15
15
|
key 'name'
|
16
16
|
store 'type_name'
|
17
17
|
store 'year'
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'earth/automobile/automobile_fuel/data_miner'
|
2
|
-
require 'earth/automobile/automobile_fuel_type/data_miner'
|
3
2
|
require 'earth/automobile/automobile_make/data_miner'
|
4
3
|
require 'earth/automobile/automobile_make_fleet_year/data_miner'
|
5
4
|
require 'earth/automobile/automobile_make_year/data_miner'
|
data/lib/earth/automobile.rb
CHANGED
@@ -30,7 +30,7 @@ BusClass.class_eval do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
import "a list of bus classes and pre-calculated trip and fuel use characteristics",
|
33
|
-
:url => 'https://spreadsheets.google.com/pub?hl=en&hl=en&key=0AoQJbWqPrREqdGRsSnJoS1hraGJvR012cDROWXFPbVE&output=csv' do
|
33
|
+
:url => 'https://spreadsheets.google.com/pub?hl=en&hl=en&key=0AoQJbWqPrREqdGRsSnJoS1hraGJvR012cDROWXFPbVE&gid=0&output=csv' do
|
34
34
|
key 'name'
|
35
35
|
store 'distance', :units_field_name => 'distance_units'
|
36
36
|
store 'passengers'
|
@@ -22,13 +22,13 @@ BusFuel.class_eval do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
import "a list of bus fuels without emission factors",
|
25
|
-
:url => 'https://spreadsheets.google.com/pub?
|
25
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGNscUdpbkdBUmJkTlFxdEtfSEdJS2c&gid=0&output=csv' do
|
26
26
|
key 'name'
|
27
27
|
store 'fuel_name'
|
28
28
|
end
|
29
29
|
|
30
30
|
import "a list of bus fuels and their emission factors",
|
31
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdHAtZ1YyWmxuS1JWUzZYSVhhdUViYmc&output=csv' do
|
31
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdHAtZ1YyWmxuS1JWUzZYSVhhdUViYmc&gid=0&output=csv' do
|
32
32
|
key 'name'
|
33
33
|
store 'fuel_name'
|
34
34
|
store 'ch4_emission_factor', :units_field_name => 'ch4_emission_factor_units'
|
@@ -36,7 +36,7 @@ BusFuel.class_eval do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
import "energy contents for compressed/liquified natural gas fuels",
|
39
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdDFfdHMycVB6dTkyUFFNM0x4b19TQVE&output=csv' do
|
39
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdDFfdHMycVB6dTkyUFFNM0x4b19TQVE&gid=0&output=csv' do
|
40
40
|
key 'name'
|
41
41
|
store 'energy_content', :units_field_name => 'energy_content_units'
|
42
42
|
end
|
@@ -11,7 +11,7 @@ BusFuelControl.class_eval do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
import "a list of bus fuel controls",
|
14
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdEw1QW80VVJhaXRkUURQSFhHczNyVWc&output=csv' do
|
14
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdEw1QW80VVJhaXRkUURQSFhHczNyVWc&gid=0&output=csv' do
|
15
15
|
key 'name'
|
16
16
|
store 'bus_fuel_name'
|
17
17
|
store 'control'
|
@@ -14,7 +14,7 @@ BusFuelYearControl.class_eval do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
import "a list of bus fuel year controls",
|
17
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGhHQkZPZW4zbXYzZ3NkYThBWnQ2QXc&output=csv' do
|
17
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGhHQkZPZW4zbXYzZ3NkYThBWnQ2QXc&gid=0&output=csv' do
|
18
18
|
key 'name'
|
19
19
|
store 'bus_fuel_name'
|
20
20
|
store 'year'
|
@@ -6,7 +6,7 @@ ComputationPlatform.class_eval do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
import "a list of computation platforms and the data center company they use",
|
9
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AkCJNpm9Ks6JdG5zVER5THhXRlE4N0RXTklVaS03Ymc&
|
9
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AkCJNpm9Ks6JdG5zVER5THhXRlE4N0RXTklVaS03Ymc&gid=0&gid=0&output=csv' do
|
10
10
|
key 'name'
|
11
11
|
store 'data_center_company_name'
|
12
12
|
end
|
@@ -6,7 +6,7 @@ DataCenterCompany.class_eval do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
import "a list of data center companies and their power usage effectiveness",
|
9
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdFlxZVZLai01WWJOOTFiaUd1blF6VkE&hl=en&
|
9
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdFlxZVZLai01WWJOOTFiaUd1blF6VkE&hl=en&gid=0&output=csv' do
|
10
10
|
key 'name'
|
11
11
|
store 'power_usage_effectiveness'
|
12
12
|
end
|
@@ -12,7 +12,7 @@ ServerType.class_eval do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
import "a list of server types and their characteristics",
|
15
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AkCJNpm9Ks6JdGExaW1ic2c0d2s1ZmpzeUdOa2kyRlE&hl=en&
|
15
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AkCJNpm9Ks6JdGExaW1ic2c0d2s1ZmpzeUdOa2kyRlE&hl=en&gid=0&output=csv' do
|
16
16
|
key 'name'
|
17
17
|
store 'data_center_company_name'
|
18
18
|
store 'cpu', :units_field_name => 'cpu_units'
|
@@ -7,7 +7,7 @@ ServerTypeAlias.class_eval do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
import "a list of server type aliases and their characteristics",
|
10
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AkCJNpm9Ks6JdDdkVlBzSUYweFN0OHBreEN6YTdTZ3c&hl=en&
|
10
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AkCJNpm9Ks6JdDdkVlBzSUYweFN0OHBreEN6YTdTZ3c&hl=en&gid=0&output=csv' do
|
11
11
|
key 'name', :field_name => 'alias'
|
12
12
|
store 'server_type_name'
|
13
13
|
store 'platform_name'
|
@@ -16,7 +16,7 @@ FoodGroup.class_eval do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
import "energy and units",
|
19
|
-
:url => 'http://spreadsheets.google.com/pub?key=trkBEq5oFnUQE76gQ6VpQgw' do
|
19
|
+
:url => 'http://spreadsheets.google.com/pub?key=trkBEq5oFnUQE76gQ6VpQgw&gid=0&output=csv' do
|
20
20
|
key 'name'
|
21
21
|
store 'energy', :units => 'unknown' #FIXME this needs to be "kilocalories per" and then whatever the suggested imperial measurement is
|
22
22
|
store 'suggested_imperial_measurement', :field_name => 'friendly_units'
|
@@ -24,7 +24,7 @@ Fuel.class_eval do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
import "fuels with non-variable characteristics",
|
27
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGJmYkdtajZyV3Byb0lrd21xLVhXUGc&hl=en&output=csv' do
|
27
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdGJmYkdtajZyV3Byb0lrd21xLVhXUGc&hl=en&gid=0&output=csv' do
|
28
28
|
key 'name'
|
29
29
|
store 'energy_content', :units_field_name => 'energy_content_units'
|
30
30
|
store 'carbon_content', :units_field_name => 'carbon_content_units'
|
@@ -33,7 +33,7 @@ Fuel.class_eval do
|
|
33
33
|
end
|
34
34
|
|
35
35
|
import "densities for aircraft fuels",
|
36
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdHBjTVE4NmRlc05iUHVZR1E3eEJwOGc&hl=en&output=csv' do
|
36
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdHBjTVE4NmRlc05iUHVZR1E3eEJwOGc&hl=en&gid=0&output=csv' do
|
37
37
|
key 'name'
|
38
38
|
store 'density', :units_field_name => 'density_units'
|
39
39
|
end
|
@@ -11,7 +11,7 @@ FuelPrice.class_eval do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
import 'fuel prices derived from the EIA',
|
14
|
-
:url => 'http://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdHlSdXJoOFB5aEpHenJQbTVJdS1pMVE',
|
14
|
+
:url => 'http://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdHlSdXJoOFB5aEpHenJQbTVJdS1pMVE&gid=0&output=csv',
|
15
15
|
:select => lambda { |row| row['fuel_type_name'].present? } do
|
16
16
|
key 'name', :field_name => 'fuel_type_name'
|
17
17
|
store 'price', :units_field_name => 'price_units'
|
@@ -28,7 +28,7 @@ FuelType.class_eval do
|
|
28
28
|
# end
|
29
29
|
|
30
30
|
import "a list of fuels and their emission factors and densities",
|
31
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdDR3RjlTcWlsLTc2TzQ0cERTMElJbHc&
|
31
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdDR3RjlTcWlsLTc2TzQ0cERTMElJbHc&gid=0&output=csv' do
|
32
32
|
key 'name', :field_name => 'fuel'
|
33
33
|
store 'emission_factor', :units_field_name => 'emission_factor_units'
|
34
34
|
store 'average_purchase_volume', :units_field_name => 'average_purchase_volume_units'
|
@@ -17,7 +17,7 @@ FuelYear.class_eval do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
import "fuels with annually variable characteristics, derived from the 2010 EPA GHG Inventory",
|
20
|
-
:url => 'https://spreadsheets.google.com/pub?hl=en&hl=en&key=0AoQJbWqPrREqdFZVSlZ3SUZsTzZLVTB5bVk5THdBN2c&output=csv' do
|
20
|
+
:url => 'https://spreadsheets.google.com/pub?hl=en&hl=en&key=0AoQJbWqPrREqdFZVSlZ3SUZsTzZLVTB5bVk5THdBN2c&gid=0&output=csv' do
|
21
21
|
key 'name'
|
22
22
|
store 'fuel_name'
|
23
23
|
store 'year'
|
@@ -10,7 +10,7 @@ GreenhouseGas.class_eval do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
import "greenhouse gas global warming potentials taken from the IPCC AR4",
|
13
|
-
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdE1tUjBwS1ZHZnBUUG1XcVpkOTVHOVE&
|
13
|
+
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdE1tUjBwS1ZHZnBUUG1XcVpkOTVHOVE&gid=0&output=csv' do
|
14
14
|
key 'name'
|
15
15
|
store 'abbreviation'
|
16
16
|
store 'ipcc_report'
|