earth 0.11.19 → 0.11.20

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -5,11 +5,23 @@ Bundler::GemHelper.install_tasks
5
5
  require 'bueller'
6
6
  Bueller::Tasks.new
7
7
 
8
+ desc "Load a console and connect to the test db"
8
9
  task :console do
9
10
  require 'earth'
10
11
  logger = Logger.new('log/test.log')
11
12
  DataMiner.logger = ActiveRecord::Base.logger = logger
12
- ActiveRecord::Base.establish_connection :adapter => 'postgresql', :database => 'test_earth'
13
+
14
+ case ENV['EARTH_DB_ADAPTER']
15
+ when 'mysql'
16
+ adapter = 'mysql2'
17
+ username = 'root'
18
+ password = 'password'
19
+ else
20
+ adapter = 'postgresql'
21
+ username = nil
22
+ password = nil
23
+ end
24
+ ActiveRecord::Base.establish_connection :adapter => adapter, :username => username, :password => password, :database => 'test_earth'
13
25
  Earth.init :all
14
26
 
15
27
  require 'irb'
@@ -36,7 +48,10 @@ if RUBY_VERSION =~ /^1\.8/
36
48
  end
37
49
  end
38
50
 
51
+ desc "Run tests with RSpec"
39
52
  task :test => :examples
53
+
54
+ desc "Run tests with RSpec"
40
55
  task :default => :test
41
56
 
42
57
  require 'earth/version'
@@ -1,283 +1 @@
1
- date,name,email,type,section,action,x,y,condition,notes
2
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,meta,Intended use,,http://www.fueleconomy.gov/FEG/download.shtml
3
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^AM GENERAL$/i,,,1985
4
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^ASC INC/i,,,"1987, 1989, 1990"
5
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^AURORA CARS/i,,,1988
6
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^AUTOKRAFT/i,,,"1986, 1987"
7
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^BILL DOVELL/i,,,1985
8
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^CALLAWAY CARS/i,,,"1990, 1991"
9
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^CCC ENGINEERING/i,,,"1987, 1988"
10
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^CONSULIER INDUSTRIES/i,,,1990-1992
11
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^E\. P\. DUTTON/i,,,1985
12
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^ENVIRONMENTAL RSCH/i,,,1989
13
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^EVANS AUTOMOBILES/i,,,1989-1991
14
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^G&K AUTOMOTIVE/i,,,1991
15
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^GENERAL MOTORS/i,,,1989
16
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^GOLDACRE/i,,,1991
17
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^GRUMMAN/i,,,"1985, 1988"
18
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^ICI INTERNATIONAL/i,,,"1991, 1992"
19
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^INTERNATIONAL MOTORS/i,,,1985
20
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^J\.K\. MOTORS/i,,,1991
21
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^JBA MOTORCARS/i,,,"1988, 1989, 1991"
22
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^LAMBDA CONTROL SYSTEMS/i,,,1986
23
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^LIPHARDT/i,,,1991
24
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^MCEVOY/i,,,"1987, 1988"
25
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^PAS/i,,,"1989, 1991-1993"
26
- 11/19/2011,Ian Hough,ian@brighterplanet.com,technical,make,reject,/^QUANTUM/i,,,appears to be just chevy cavaliers
27
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^RED SHIFT/i,,,"1987, 1988"
28
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^ROUSH/i,,,"2002-2004, 2007-2010"
29
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^RUF AUTOMOBILE/i,,,"1987, 1988"
30
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^VIXEN MOTOR COMPANY/i,,,1986
31
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^VOLGA ASSOCIATED/i,,,1986
32
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/^WALLACE ENVIRONMENTAL/i,,,"1991, 1992"
33
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/COACH/i,,,"1986, 1995"
34
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,reject,/IMPORT/i,,,"1988, 1989, 1991, 1992"
35
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,make,replace,/^AMERICAN MOTORS.*/i,Eagle,,1985-1987
36
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,make,replace,/^(AUSTIN )?ROVER.*/i,Land Rover,,"1987-1991, 1993-1996"
37
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,make,replace,/^BMW.*/i,Alpina,Model contains Alpina,2011
38
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,make,replace,/^CX ?AUTOMOTIVE.*/i,Citroën,,"1987-1989, 1991-1993"
39
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,make,replace,/^GM$/i,Chevrolet,,"2003, 2004"
40
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,replace,/^MERCEDES-BENZ$/i,Maybach,Model contains Maybach,2004-2010
41
- 6/8/2011,Ian Hough,ian@brighterplanet.com,editorial,make,replace,/^MERCEDES-BENZ.*/i,Smart,Model contains Smart,"2008, 2010, 2011"
42
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,replace,/^ROLLS-ROYCE.*/i,Bentley,Model contains Bentley,1987-1997
43
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,replace,/^ROLLS-ROYCE.*/i,Bentley,Is a Turbo Brooklands,1995
44
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,make,replace,/^R-R MTR.+/i,Rolls-Royce,,1998-2002
45
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,make,replace,/^SHLBY$/i,Shelby,,2008
46
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,make,replace,/^SPYKR$/i,Spyker,,"2007, 2009"
47
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,make,replace,/^TCSTR$/i,Tecstar,,2008
48
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,make,replace,/^VEHICLE PRODUCTION GROUP.*/i,VPG,,2011
49
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,make,replace,/^VW$/,Volkswagen,,2009
50
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Acura
51
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Alfa Romeo
52
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Alpina
53
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Aston Martin
54
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Audi
55
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Bentley
56
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Bertone
57
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Bitter
58
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Bugatti
59
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Buick
60
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Cadillac
61
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Chevrolet
62
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Chrysler
63
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Daewoo
64
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Daihatsu
65
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Dodge
66
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Eagle
67
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Excalibur
68
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Ferrari
69
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Ford
70
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Geo
71
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Honda
72
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Hummer
73
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Hyundai
74
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Impco
75
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Infiniti
76
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Isuzu
77
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Jaguar
78
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Jeep
79
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Kia
80
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Laforza
81
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Lamborghini
82
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Land Rover
83
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Lexus
84
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Lincoln-Mercury,,,must precede replace on 'Lincoln'
85
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,replace,/^lincoln .+/i,Lincoln
86
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Lotus
87
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,make,truncate,Mahindra
88
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Maserati
89
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Mazda
90
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Mercedes-Benz
91
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Mercury
92
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Merkur
93
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Mini
94
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Mitsubishi
95
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Morgan
96
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Nissan
97
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Oldsmobile
98
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Panoz
99
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Panther
100
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Peugeot
101
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Pininfarina
102
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Plymouth
103
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Pontiac
104
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Porsche
105
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Qvale
106
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Renault
107
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Rolls-Royce
108
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Saab
109
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Saleen
110
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Saturn
111
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,make,truncate,Scion
112
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Shelby
113
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Subaru
114
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Suzuki
115
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,TVR
116
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Toyota
117
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Vector
118
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Volkswagen
119
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Volvo
120
- 7/8/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,make,truncate,Yugo
121
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,reject,/KIT$/i,,,"porsche 2003-2005, 2010"
122
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,reject,/NATIVA/i,,,"mitsubishi 1998-2000, 2002-2004"
123
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/ - /,,,clean -: ' - ' -> ' '
124
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/ \/ /,/,,clean /: ' / ' -> '/'
125
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,replace,/\/ /,,,clean /: '/ ' -> ' '
126
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,delete,/( +)?\((F|R|A|2|4)WD\)/i,,,clean drive: '(4wd)' etc.
127
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,delete,/( +|-)?(F|R|A|2|4)WD/i,,,clean drive: ' 4wd' etc.
128
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,delete,/ all wheel dri(ve)?$/i,,,clean drive: ' all wheel drive' etc.
129
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,delete,/ 2W$/,,,clean drive: terminal ' 2W'
130
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,delete,/ 4x(4|2)/i,,,clean drive: '4x4' and '4x2'
131
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,delete,/( |-)\(?4matic\)?/i,,,clean drive: '4matic' (mercedes 4wd)
132
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,delete,/ \(new version\)/i,,,clean (): cut '(new version)'
133
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,delete,/ \(new v$/i,,,clean (): cut terminal '(new v'
134
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,delete,/ \(incl\. outback\)/i,,,clean (): cut '(incl. outback)'
135
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,replace,/ ?\((.+)\)/i, \1,,clean (): cut keeping interior text
136
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,replace,/(\d)-?dr/i,\1-DOOR,,clean doors: 'x-dr' -> 'x-DOOR'
137
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,replace,/(\d) door/i,\1-DOOR,,clean doors: 'x door' -> 'x-DOOR'
138
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,replace,/2d hatchback/i,2-DOOR HATCHBACK,,clean doors: '2d' -> '2-DOOR'
139
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,replace,/conv cargo$/i,CARGO CONVERSION,,clean conv
140
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,replace,/cargo conv$/i,CARGO CONVERSION,,clean conv
141
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,replace,/van conv$/i,VAN CONVERSION,,clean conv
142
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/conv$/i,CONVERTIBLE,,clean conv
143
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/conv(ert)?\./i,CONVERTIBLE,,clean conv
144
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/conv\//i,CONVERTIBLE/,,clean conv
145
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,replace,/ pass(e)?(n)?$/i, PASSENGER,,clean pass
146
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,replace,/ pass /i, PASSENGER ,,clean pass
147
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/ turb$/i, TURBO,,clean turbo
148
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/soft( -)top/i,SOFTTOP,,clean softtop
149
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,delete,/ (turbo)?diesel$/i,,,clean fuel
150
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,delete,/ natural gas$/i,,,clean fuel
151
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,delete,/ ffv/i,,,clean fuel
152
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,delete,/ inc$/i,,,delete terminal ' inc'
153
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,delete,/^alfa romeo /i,,,clean up alfa romeo
154
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/^GTV6 2.5$/i,GTV,,clean up alfa romeo
155
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,delete,/^(bmw( |\/))?alpina /i,,is a alpina,clean up alpina
156
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,delete,/^aston martin /i,,,clean up aston martin
157
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,delete,/ manual$/i,,,clean up aston martin
158
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,replace,/^db-7/i,DB7,,clean up aston martin
159
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,delete,/bentley /i,,is a bentley,clean up bentley
160
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,delete,/& /i,,is a bentley,clean up bentley
161
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,replace,/br?kln?ds/i,BROOKLANDS,,clean up bentley
162
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,replace,/^cont supersports/i,CONTINENTAL SUPERSPORTS,,clean up bentley
163
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/s&s\(l$/i,LWB,,clean up bentley
164
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,model,replace,/limo$/i,LIMOUSINE,,clean up bentley
165
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,delete,/^bertone /i,,,clean up bertone
166
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,delete,/^bitter /i,,,clean up bitter
167
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,delete,/^bmw /i,,,clean up bmw
168
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,"/, /i",/,,clean up bmw
169
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,delete,/^cadillac /i,,,clean up cadillac
170
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,delete,/^chevrolet /i,,,clean up chevrolet
171
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,delete,/chevy /i,,is a chevrolet,clean up chevrolet
172
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,replace,/25chev van/i,25 VAN,is a chevrolet,clean up chevrolet
173
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/15slvradoclassichybrid/i,15 SILVERADO CLASSIC HYBRID,,clean up chevrolet
174
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,replace,/slvrd$/i,SILVERADO,,clean up chevrolet
175
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/montecarlo/i,MONTE CARLO,,clean up chevrolet
176
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/postal\*cab\*chassis.*/i,POSTAL CAB CHASSIS,,clean up chevrolet
177
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,replace,/suburbn/i,SUBURBAN,,clean up chevrolet
178
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,replace,/^g1500\/g2500/i,G1500/2500,,clean up chevrolet
179
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,delete,/^chrysler /i,,,clean up chrysler
180
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/impe$/i,IMPERIAL,,clean up chrysler
181
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/5th/i,FIFTH,,clean up chrysler
182
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/town and country/i,TOWN & COUNTRY,,clean up chrysler
183
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/town&c(oun)?try/i,TOWN & COUNTRY,,clean up chrysler
184
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,delete,/^daewoo /i,,,clean up daewoo
185
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,delete,/ ?dodge ?/i,,is a dodge,clean up dodge
186
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/p\/u/i,PICKUP,is a dodge,clean up dodge
187
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/ram50/i,RAM 50,is a dodge,clean up dodge
188
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,delete,/^eagle /i,,,clean up eagle
189
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,delete,/^renault /i,,,clean up eagle
190
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,delete,/ ?ferrari ?/i,,is a ferrari,clean up ferrari
191
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,replace,/f 40/i,F40,is a ferrari,clean up ferrari
192
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/^599 GTB$/,599 GTB Fiorano,,clean up ferrari
193
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,delete,/^ford /i,,,clean up ford
194
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,replace,/^escape hev$/i,ESCAPE HYBRID,,clean up ford
195
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,replace,/chassis cab/i,CAB CHASSIS,,clean up ford
196
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,model,replace,/station wag$/i,STATION WAGON,,clean up ford
197
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/^F(1|2)50$/,F\150 PICKUP,,clean up ford
198
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/^taurus wagon.+$/i,TAURUS WAGON,,clean up ford
199
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/15sierraclassichybrid/i,15 SIERRA CLASSIC HYBRID,,clean up gmc
200
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,replace,/^xg 350$/i,XG350,,clean up hyundai
201
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,delete,/^isuzu /i,,,clean up isuzu
202
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,replace,/^p'up.+/i,PICKUP,,clean up isuzu
203
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,model,replace,/1 ?ton/i,1-TON,,clean up isuzu and toyota
204
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/pickup truck/i,PICKUP,,clean up isuzu and jeep
205
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,delete,/^jaguar /i,,,clean up jaguar
206
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,delete,/ \d\.\d litre$/i,,,clean up jaguar
207
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/^jaguar$/i,XJ6,,1990 Jaguar XJ6 has just 'jaguar' for model name
208
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,model,replace,/^vanden plas s\.c\.$/i,VANDEN PLAS S/C,,clean up jaguar
209
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,model,replace,/pick\/up/i,PICKUP,,clean up jeep
210
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,delete,/kia /i,,is a kia,clean up kia
211
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/^optimams$/i,OPTIMA MS,,clean up kia
212
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/^riojb$/i,RIO JB,,clean up kia
213
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/^sedonavq$/i,SEDONA VQ,,clean up kia
214
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/^spectrald$/i,SPECTRA LD,,clean up kia
215
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/^sportagekm$/i,SPORTAGE KM,,clean up kia
216
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,delete,/^db132\//i,,,clean up lamborghini
217
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,delete,/^l-\d{3}(\/\d{3})? /i,,,clean up lamborghini
218
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/144 Diablo/i,DIABLO,,clean up lamborghini
219
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/gallard0/i,GALLARDO,,clean up lamborghini
220
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,delete,/^land rover /i,,,clean up land rover
221
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,model,delete,/^austin rover /i,,,clean up land rover
222
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/discovery ser ii/i,DISCOVERY SERIES II,,clean up land rover
223
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/([a-z]{2}) (\d{3})/i,\1\2,is a lexus,clean up lexus
224
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,delete,/^lincoli?n /i,,,clean up lincoln-mercury
225
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/^sable wagon.+/i,SABLE WAGON,,clean up lincoln-mercury
226
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,delete,/^lotus /i,,,clean up lotus
227
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,model,replace,/^98 esrit V8$/i,ESPRIT V8,,clean up lotus
228
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,model,replace,/^esprit\.v8$/i,ESPRIT V8,,clean up lotus
229
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/^espirit turbo$/i,ESPRIT TURBO,,clean up lotus
230
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,delete,/^maserati /i,,,clean up maserati
231
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,delete,/^maybach /i,,,clean up maybach
232
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/^57 S$/i,57S,is a maybach,clean up maybach
233
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,model,delete,/^mazda ?/i,,,clean up mazda
234
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,delete,/-16$/i,,is a mercedes benz,clean up mercedes-benz
235
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/^(\d{3}[de])(\d\.\d)/i,\1 \2,is a mercedes benz,clean up mercedes-benz
236
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,"/^([a-z]{1,3}) (\d{2,3})/i",\1\2,is a mercedes benz,clean up mercedes-benz
237
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/^clk320cabriolet$/i,CLK320 CABRIOLET,,clean up mercedes-benz
238
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/^mountainer$/i,MOUNTAINEER,,clean up mercury
239
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,delete,/^mini /i,,,clean up mini
240
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,model,replace,/ clubm$/i, CLUBMAN,,clean up mini
241
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,delete,/^mitsubishi /i,,,clean up mitsubishi
242
- 10/18/2011,Ian Hough,ian@brighterplanet.com,technical,model,replace,/^expo\.lrv$/i,EXPO LRV,,clean up mitsubishi
243
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/^3000 gt/i,3000GT,is a mitsubishi,clean up mitsubishi
244
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/ty eight/i,TY-EIGHT,,clean up oldsmobile
245
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,delete,/^panoz /i,,,clean up panoz
246
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,delete,/^pininfarina /i,,,clean up plymouth
247
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,delete,/ plymouth$/i,,,clean up porsche
248
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,model,delete,/^gt3 /i,,is a porsche,clean up porsche
249
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,model,delete,/^rs /i,,is a porsche,clean up porsche
250
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,delete,/^turbo +4 /i,,is a porsche,clean up porsche
251
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/^carrera 2 911 gt3$/i,911 CARRERA 2 GT3,,clean up porsche
252
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,model,replace,/^carrera /i,911 CARRERA ,,clean up porsche
253
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,model,replace,/^targa$/i,911 TARGA,,clean up porsche
254
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/^turbo$/i,911 TURBO,,clean up porsche
255
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/^turbo +2 911 gt2$/i,911 TURBO GT2,,clean up porsche
256
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/^turbo gt2$/i,911 TURBO GT2,,clean up porsche
257
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/carrera 2\/4/i,CARRERA 4/2,,clean up porsche
258
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,model,replace,/carrera (2|4) s/i,CARRERA \1S ,,clean up porsche
259
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/ cab( S)?$/i,\1 CABRIOLET,is a porsche,clean up porsche
260
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/928s/i,928 S,is a porsche,clean up porsche
261
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,delete,/^rolls( |-)royce /i,,,clean up rolls-royce
262
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,model,delete,/^r-r /i,,,clean up rolls-royce
263
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,delete,/^saab ?/i,,,clean up saab
264
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/sportcombi/i,SPORT COMBI,,clean up saab
265
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,model,delete,/^saleen /i,,,clean up saleen
266
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,delete,/^shelby /i,,,clean up shelby
267
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,delete,/^smart fortwo /i,,,clean up smart
268
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/^elec\. drive/i,ELECTRIC,,clean up smart
269
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/12 s$/i,12 SPYDER,,clean up spyker
270
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,delete,/^subaru /i,,,clean up subaru
271
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/^IMPREZA WGN/OUTBACK SPT$/i,IMPREZA WAGON/OUTBACK SPORT,,clean up subaru
272
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,delete,/^suzuki /i,,,clean up suzuki
273
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/^grand vitara xl-7$/i,GRAND VITARA XL7,,clean up suzuki
274
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,delete,/toyota /i,,is a toyota,clean up toyota
275
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/^4-runner$/i,4RUNNER,,clean up toyota
276
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,model,replace,/^cab\/chassis$/i,CAB CHASSIS,,clean up toyota
277
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,delete,/^tvr /i,,is a tvr,clean up tvr
278
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,model,delete,/^vector /i,,,clean up vector
279
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,editorial,model,delete,/ 16-Valve/i,,,clean up volvo
280
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/^240 DL\/240 GL/i,240DL/240GL,is a volvo,clean up volvo
281
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,replace,/^XC (\d{2})$/i,XC\1,is a volvo,clean up volvo
282
- 7/7/2009,Andy Rossmeissl,andy@brighterplanet.com,technical,model,replace,/^s80\/s80 (executive|premier)$/i,S80,,clean up volvo
283
- 10/18/2011,Ian Hough,ian@brighterplanet.com,editorial,model,delete,/yugo /i,,is a yugo,clean up yugo
1
+ date,name,email,type,section,action,x,y,condition,notes
@@ -32,7 +32,7 @@ Aircraft.class_eval do
32
32
  :encoding => 'windows-1252',
33
33
  :row_xpath => '//table[2]//table[1]//tr[3]//tr',
34
34
  :column_xpath => 'td',
35
- :errata => { :url => "file://#{Earth::ERRATA_DIR}/aircraft/faa_errata.csv", :responder => Aircraft::Guru.new },
35
+ :errata => { :url => "file://#{Earth::ERRATA_DIR}/aircraft/faa_errata.csv", :responder => "Aircraft::Guru" },
36
36
  :select => proc { |record| Aircraft.manufacturer_whitelist? record['Manufacturer'] }) do
37
37
  key 'icao_code', :field_name => 'Designator'
38
38
  store 'manufacturer_name', :field_name => 'Manufacturer'
@@ -34,7 +34,7 @@ Airport.class_eval do
34
34
  :headers => %w{ id name city country_name iata_code icao_code latitude longitude altitude timezone daylight_savings },
35
35
  :select => proc { |record| record['iata_code'].present? },
36
36
  :errata => { :url => "file://#{Earth::ERRATA_DIR}/airport/openflights_errata.csv",
37
- :responder => Airport::Guru.new } do
37
+ :responder => "Airport::Guru" } do
38
38
  key 'iata_code'
39
39
  store 'name'
40
40
  store 'city'
@@ -192,7 +192,7 @@ FlightSegment.class_eval do
192
192
  :form_data => form_data,
193
193
  :compression => :zip,
194
194
  :glob => '/*.csv',
195
- :errata => { :url => "file://#{Earth::ERRATA_DIR}/flight_segment/bts_errata.csv", :responder => FlightSegment::Guru.new },
195
+ :errata => { :url => "file://#{Earth::ERRATA_DIR}/flight_segment/bts_errata.csv", :responder => "FlightSegment::Guru" },
196
196
  :select => proc { |record| record['DEPARTURES_PERFORMED'].to_i > 0 } do
197
197
  key 'row_hash'
198
198
  store 'origin_airport_iata_code', :field_name => 'ORIGIN'
@@ -1,4 +1,3 @@
1
- require 'earth/fuel'
2
1
  class AutomobileMakeModelYearVariant < ActiveRecord::Base
3
2
  self.primary_key = "row_hash"
4
3
 
@@ -17,26 +16,25 @@ class AutomobileMakeModelYearVariant < ActiveRecord::Base
17
16
  col :speeds
18
17
  col :drive
19
18
  col :fuel_code
19
+ col :fuel_efficiency, :type => :float
20
+ col :fuel_efficiency_units
21
+ col :fuel_efficiency_city, :type => :float
22
+ col :fuel_efficiency_city_units
23
+ col :fuel_efficiency_highway, :type => :float
24
+ col :fuel_efficiency_highway_units
25
+ col :alt_fuel_code
26
+ col :alt_fuel_efficiency, :type => :float
27
+ col :alt_fuel_efficiency_units
28
+ col :alt_fuel_efficiency_city, :type => :float
29
+ col :alt_fuel_efficiency_city_units
30
+ col :alt_fuel_efficiency_highway, :type => :float
31
+ col :alt_fuel_efficiency_highway_units
20
32
  col :cylinders, :type => :integer
21
33
  col :displacement, :type => :float
22
34
  col :turbo, :type => :boolean
23
35
  col :supercharger, :type => :boolean
24
36
  col :injection, :type => :boolean
25
- col :fuel_efficiency, :type => :float
26
- col :fuel_efficiency_units
27
- col :fuel_efficiency_city, :type => :float
28
- col :fuel_efficiency_city_units
29
- col :fuel_efficiency_highway, :type => :float
30
- col :fuel_efficiency_highway_units
31
- col :raw_fuel_efficiency_city, :type => :float
32
- col :raw_fuel_efficiency_city_units
33
- col :raw_fuel_efficiency_highway, :type => :float
34
- col :raw_fuel_efficiency_highway_units
35
- col :carline_mfr_code, :type => :integer
36
- col :vi_mfr_code, :type => :integer
37
- col :carline_code, :type => :integer
38
- col :carline_class_code, :type => :integer
39
- col :carline_class_name
37
+ col :carline_class
40
38
  add_index :make_name
41
39
  add_index :model_name
42
40
  add_index :year
@@ -1,138 +1,177 @@
1
- require 'earth/fuel/data_miner'
2
1
  AutomobileMakeModelYearVariant.class_eval do
3
2
  # For errata
4
3
  class AutomobileMakeModelYearVariant::Guru
5
- %w{ alpina bentley chevrolet dodge ferrari jaguar kia lexus maybach mercedes-benz mitsubishi porsche toyota tvr volvo yugo }.each do |make|
6
- make_for_method = make.gsub('-', '_')
7
- method_name = :"is_a_#{make_for_method}?"
4
+ %w{ alpina bentley chevrolet dodge ferrari ford jaguar kia lexus maybach mercedes-benz mitsubishi porsche toyota tvr volvo yugo }.each do |make|
5
+ method_name = :"is_a_#{make.gsub('-', '_')}?"
8
6
  define_method method_name do |row|
9
- row['make'].to_s.upcase == "#{make.humanize.upcase}"
7
+ row['make_name'].downcase == make
10
8
  end
11
9
  end
12
10
 
13
- %w{ alpina bentley maybach smart }.each do |model|
14
- method_name = :"model_contains_#{model}?"
11
+ %w{ alpina bentley marquis maybach milan mystique scion smart }.each do |model_name|
12
+ method_name = :"model_contains_#{model_name}?"
15
13
  define_method method_name do |row|
16
- row['model'].to_s =~ /#{model.upcase}/i
14
+ row['model_name'].to_s =~ /#{model_name}/i
15
+ end
16
+ end
17
+
18
+ [["ford", "contour"], ["hyundai", "sonata"], ["jaguar", "xjr"], ["jaguar", "xjs convertible"], ["jaguar", "xjs coupe"], ["mercury", "mystique"], ["mitsubishi", "mirage"], ["volvo", "850"], ["volvo", "850 wagon"], ["volvo", "940"], ["volvo", "940 wagon"]].each do |make_name, model_name|
19
+ method_name = :"is_a_1995_#{make_name}_#{model_name.gsub(' ', '_')}_missing_fuel_efficiency?"
20
+ define_method method_name do |row|
21
+ row['year'] == 1995 and row['make_name'].downcase == make_name and row['model_name'].downcase == model_name and (row['fuel_efficiency_city'] == 0 or row['fuel_efficiency_highway'] == 0)
17
22
  end
18
23
  end
19
24
 
20
25
  def is_a_turbo_brooklands?(row)
21
- row['model'] =~ /TURBO R\/RL BKLDS/i
26
+ row['model_name'] =~ /TURBO R\/RL BKLDS/i
27
+ end
28
+
29
+ def is_a_1989_hyundai_sonata_missing_transmission_and_speeds?(row)
30
+ row['make_name'].downcase == 'hyundai' and row['model_name'].downcase == 'sonata' and row['year'] == 1989 and (row['transmission'].blank? || row['speeds'].blank?)
31
+ end
32
+
33
+ def is_a_1989_isuzu_trooper_missing_transmission_and_speeds?(row)
34
+ row['make_name'].downcase == 'isuzu' and row['model_name'].downcase == 'trooper' and row['year'] == 1989 and (row['transmission'].blank? || row['speeds'].blank?)
35
+ end
36
+
37
+ def is_a_2005_mercedes_benz_slk55_amg?(row)
38
+ row['make_name'].downcase == 'mercedes-benz' and row['model_name'].downcase == 'slk55 amg' and row['year'] == 2005
22
39
  end
23
40
  end
24
41
 
25
- # updated with 2010 names
26
- TRANSMISSIONS = {
27
- 'A' => 'Automatic', # prefix
28
- 'M' => 'Manual', # prefix
29
- 'L' => 'Automatic', # prefix
30
- 'S' => 'Semi-Automatic', # prefix
31
- 'AM' => 'Automated Manual',
32
- 'C' => 'Continuously Variable',
33
- 'SA' => 'Semi-Automatic',
34
- 'CVT' => 'Continuously Variable',
35
- 'OT' => 'Other'
36
- }
37
-
38
- ENGINE_TYPES = {
39
- '(GUZZLER)' => nil, # "gas guzzler"
40
- '(POLICE)' => nil, # police automobile_variant
41
- '(MPFI)' => 'injection',
42
- '(MPI*)' => 'injection',
43
- '(SPFI)' => 'injection',
44
- '(FFS)' => nil, # doesn't necessarily mean fuel injection
45
- '(TURBO)' => 'turbo',
46
- '(TRBO)' => 'turbo',
47
- '(TC*)' => 'turbo',
48
- '(FFS,TRBO)' => 'turbo',
49
- '(S-CHARGE)' => 'supercharger',
50
- '(SC*)' => 'supercharger',
51
- '(DIESEL)' => nil, # diesel
52
- '(DSL)' => nil, # diesel
53
- '(ROTARY)' => nil, # rotary
54
- '(VARIABLE)' => nil, # variable displacement
55
- '(NO-CAT)' => nil, # no catalytic converter
56
- '(OHC)' => nil, # overhead camshaft
57
- '(OHV)' => nil, # overhead valves
58
- '(16-VALVE)' => nil, # 16V
59
- '(305)' => nil, # 305 cubic inch displacement
60
- '(307)' => nil, # 307 cubic inch displacement
61
- '(M-ENG)' => nil,
62
- '(W-ENG)' => nil,
63
- '(GM-BUICK)' => nil,
64
- '(GM-CHEV)' => nil,
65
- '(GM-OLDS)' => nil,
66
- '(GM-PONT)' => nil,
67
- }
68
-
69
- class AutomobileMakeModelYearVariant::ParserA
70
- ::FixedWidth.define :fuel_economy_guide_a do |d|
71
- d.rows do |row|
72
- row.trap { true } # there's only one section
73
- row.column 'active_year' , 4, :type => :integer # ACTIVE YEAR
74
- row.column 'state_code' , 1, :type => :string # STATE CODE: F=49-STATE,C=CALIFORNIA
75
- row.column 'carline_clss' , 2, :type => :integer # CARLINE CLASS CODE
76
- row.column 'carline_mfr_code' , 3, :type => :integer # CARLINE MANUFACTURER CODE
77
- row.column 'carline_name' , 28, :type => :string # CARLINE NAME
78
- row.column 'disp_cub_in' , 4, :type => :integer # DISP CUBIC INCHES
79
- row.column 'fuel_system' , 2, :type => :string # FUEL SYSTEM: 'FI' FOR FUEL INJECTION, 2-DIGIT INTEGER VALUE FOR #OF VENTURIES IF CARBURETOR SYSTEM.
80
- row.column 'model_trans' , 6, :type => :string # TRANSMISSION TYPE
81
- row.column 'no_cyc' , 2, :type => :integer # NUMBER OF ENGINE CYLINDERS
82
- row.column 'date_time' , 12, :type => :string # DATE AND TIME RECORD ENTERED -YYMMDDHHMMSS (YEAR, MONTH, DAY, HOUR, MINUTE, SECOND)
83
- row.column 'release_date' , 6, :type => :string # RELEASE DATE - YYMMDD (YEAR, MONTH, DAY)
84
- row.column 'vi_mfr_code' , 3, :type => :integer # VI MANUFACTURER CODE
85
- row.column 'carline_code' , 5, :type => :integer # CARLINE CODE
86
- row.column 'basic_eng_id' , 5, :type => :integer # BASIC ENGINE INDEX
87
- row.column 'carline_mfr_name' , 32, :type => :string # CARLINE MANUFACTURER NAME
88
- row.column 'suppress_code' , 1, :type => :integer # SUPPRESSION CODE (NO SUPPRESSED RECORD IF FOR PUBLIC ACCESS)
89
- row.column 'est_city_mpg' , 3, :type => :integer # ESTIMATED (CITY) MILES PER GALLON - 90% OF UNADJUSTED VALUE
90
- row.spacer 2
91
- row.column 'highway_mpg' , 3, :type => :integer # ESTIMATED (HWY) MILES PER GALLON - 78% OF UNADJUSTED VALUE
92
- row.spacer 2
93
- row.column 'combined_mpg' , 3, :type => :integer # COMBINED MILES PER GALLON
94
- row.spacer 2
95
- row.column 'unadj_city_mpg' , 3, :type => :integer # UNADJUSTED CITY MILES PER GALLON
96
- row.spacer 2
97
- row.column 'unadj_hwy_mpg' , 3, :type => :integer # UNADJUSTED HIGHWAY MILES PER GALLON
98
- row.spacer 2
99
- row.column 'unadj_comb_mpg' , 3, :type => :integer # UNADJUSTED COMBINED MILES PER GALLON
100
- row.spacer 2
101
- row.column 'ave_anl_fuel' , 6, :type => :integer # "$" in col 147, Annual Fuel Cost starting col 148 in I5
102
- row.column 'opt_disp' , 8, :type => :string # OPTIONAL DISPLACEMENT
103
- row.column 'engine_desc1' , 10, :type => :string # ENGINE DESCRIPTION 1
104
- row.column 'engine_desc2' , 10, :type => :string # ENGINE DESCRIPTION 2
105
- row.column 'engine_desc3' , 10, :type => :string # ENGINE DESCRIPTION 3
106
- row.column 'body_type_2d' , 10, :type => :string # BODY TYPE 2 DOOR - IF THE BODY TYPE APPLIES IT WILL TAKE THE FORM '2DR-PPP/LL' WHERE PPP=PASSENGER INTERIOR VOLUME AND LL=LUGGAGE INTERIOR VOLUME.
107
- row.column 'body_type_4d' , 10, :type => :string # BODY TYPE 4 DOOR - IF THE BODY TYPE APPLIES IT WILL TAKE THE FORM '4DR-PPP/LL' WHERE PPP=PASSENGER INTERIOR VOLUME AND LL=LUGGAGE INTERIOR VOLUME.
108
- row.column 'body_type_hbk' , 10, :type => :string # BODY TYPE HBK - IF THE BODY TYPE APPLIES IT WILL TAKE THE FORM 'HBK-PPP/LL' WHERE PPP=PASSENGER INTERIOR VOLUME AND LL=LUGGAGE INTERIOR VOLUME.
109
- row.column 'puerto_rico' , 1, :type => :string # '*' IF FOR PUERTO RICO SALES ONLY
110
- row.column 'overdrive' , 4, :type => :string # OVERDRIVE: ' OD ' FOR OVERDRIVE, 'EOD ' FOR ELECTRICALLY OPERATED OVERDRIVE AND 'AEOD' FOR AUTOMATIC OVERDRIVE
111
- row.column 'drive_system' , 3, :type => :string # FWD=FRONT WHEEL DRIVE, RWD=REAR, 4WD=4-WHEEL
112
- row.column 'filler' , 1, :type => :string # NOT USED
113
- row.column 'fuel_type' , 1, :type => :string # R=REGULAR(UNLEADED), P=PREMIUM, D=DIESEL
114
- row.column 'trans_desc' , 15, :type => :string # TRANSMISSION DESCRIPTORS
115
- end
116
- end
42
+ # To parse the FEG files
43
+ class AutomobileMakeModelYearVariant::Parser
117
44
  attr_reader :year
45
+
46
+ TRANSMISSIONS = {
47
+ 'A' => 'Automatic',
48
+ 'L' => 'Automatic',
49
+ 'M' => 'Manual',
50
+ 'S' => 'Semi-Automatic',
51
+ 'C' => 'Continuously Variable',
52
+ 'AM' => 'Automated Manual',
53
+ 'SA' => 'Semi-Automatic',
54
+ 'CVT' => 'Continuously Variable',
55
+ 'SCV' => 'Selectable Continuously Variable',
56
+ 'OT' => 'Other'
57
+ }
58
+
59
+ ENGINE_TYPES = {
60
+ '(GUZZLER)' => nil, # "gas guzzler"
61
+ '(POLICE)' => nil, # police automobile_variant
62
+ '(MPFI)' => 'injection',
63
+ '(MPI*)' => 'injection',
64
+ '(SPFI)' => 'injection',
65
+ '(FFS)' => nil, # doesn't necessarily mean fuel injection
66
+ '(TURBO)' => 'turbo',
67
+ '(TRBO)' => 'turbo',
68
+ '(TC*)' => 'turbo',
69
+ '(FFS,TRBO)' => 'turbo',
70
+ '(S-CHARGE)' => 'supercharger',
71
+ '(SC*)' => 'supercharger',
72
+ '(DIESEL)' => nil, # diesel
73
+ '(DSL)' => nil, # diesel
74
+ '(ROTARY)' => nil, # rotary
75
+ '(VARIABLE)' => nil, # variable displacement
76
+ '(NO-CAT)' => nil, # no catalytic converter
77
+ '(OHC)' => nil, # overhead camshaft
78
+ '(OHV)' => nil, # overhead valves
79
+ '(16-VALVE)' => nil, # 16V
80
+ '(305)' => nil, # 305 cubic inch displacement
81
+ '(307)' => nil, # 307 cubic inch displacement
82
+ '(M-ENG)' => nil,
83
+ '(W-ENG)' => nil,
84
+ '(GM-BUICK)' => nil,
85
+ '(GM-CHEV)' => nil,
86
+ '(GM-OLDS)' => nil,
87
+ '(GM-PONT)' => nil
88
+ }
89
+
90
+ FUEL_CODES = {
91
+ 'BE' => 'EL', # battery electric
92
+ 'CNG' => 'C', # CNG
93
+ 'DU' => 'D', # diesel (ultra-low sulphur)
94
+ 'E' => 'E', # ethanol
95
+ 'EL' => 'EL', # electric
96
+ 'G' => 'R', # regular gasoline
97
+ 'GP' => 'P', # premium gasoline recommended
98
+ 'GPR' => 'P', # premium gasoline required
99
+ 'GM' => 'P', # midgrade gasoline recommended
100
+ 'H' => 'H', # hydrogen
101
+ 'PE' => 'EL' # plug-in electric
102
+ }
103
+
118
104
  def initialize(options = {})
119
105
  options = options.stringify_keys
120
106
  @year = options['year']
121
107
  end
108
+
122
109
  def apply(row)
123
- row.merge!({
124
- 'make' => row['carline_mfr_name'], # make it line up with the errata
125
- 'model' => row['carline_name'].upcase, # ditto
126
- 'year' => year,
127
- 'transmission' => TRANSMISSIONS[row['model_trans'][0,1].to_s],
128
- 'speeds' => row['model_trans'][1,1] == 'V' ? 'variable' : row['model_trans'][1,1],
129
- 'displacement' => _displacement(row),
130
- 'turbo' => _turbo(row),
131
- 'supercharger' => [ENGINE_TYPES[row['engine_desc1'].to_s], ENGINE_TYPES[row['engine_desc2'].to_s]].flatten.include?('supercharger'),
132
- 'injection' => row['fuel_system'] == 'FI' ? true : false
133
- })
134
- row
110
+ # Pre-2010 fuel efficiencies need to be adjusted downwards to reflect real-world driving
111
+ # We do this by applying equations to the *unadjusted* city and highway fuel efficiency
112
+ # Source for the equations is EPA Fuel Economy Trends report Appendix A
113
+ # Starting in 2008 we could use the *adjusted* values from the FEG but this would require writing a new case for 2008 and 2009
114
+ # Starting in 2010 we use the *adjusted* fuel efficiencies from the FEG
115
+ case year
116
+ when (1985..1997)
117
+ row.merge!({
118
+ 'make_name' => row['carline_mfr_name'],
119
+ 'model_name' => row['carline_name'],
120
+ 'year' => year,
121
+ 'transmission' => TRANSMISSIONS[row['model_trans'][0,1].to_s],
122
+ 'speeds' => row['model_trans'][1,1] == 'V' ? 'variable' : row['model_trans'][1,1],
123
+ 'drive' => row['drive_system'],
124
+ 'fuel_code' => row['fuel_type'],
125
+ 'fuel_efficiency_city' => 1.0 / (0.003259 + (1.1805 / row['unadj_city_mpg'].to_f)), # adjust for real-world driving
126
+ 'fuel_efficiency_highway' => 1.0 / (0.001376 + (1.3466 / row['unadj_hwy_mpg'].to_f)), # adjust for real-world driving
127
+ 'cylinders' => row['no_cyl'],
128
+ 'displacement' => _displacement(row),
129
+ 'turbo' => _turbo(row),
130
+ 'supercharger' => [ENGINE_TYPES[row['engine_desc1'].to_s], ENGINE_TYPES[row['engine_desc2'].to_s]].flatten.include?('supercharger'),
131
+ 'injection' => row['fuel_system'] == 'FI' ? true : false
132
+ })
133
+ when (1998..2009)
134
+ row.merge!({
135
+ 'make_name' => row['Manufacturer'] || row['MFR'],
136
+ 'model_name' => (row['carline name'] || row['CAR LINE']).upcase,
137
+ 'year' => year,
138
+ 'transmission' => TRANSMISSIONS[(row['trans'] || row['TRANS'])[-3,1]],
139
+ 'speeds' => ((row['trans'] || row['TRANS'])[-2,1] == 'V') ? 'variable' : (row['trans'] || row['TRANS'])[-2,1],
140
+ 'drive' => ((row['drv'] || row['DRIVE SYS']) + 'WD').gsub('.0', ''),
141
+ 'fuel_code' => row['fl'] || row['FUEL TYPE'],
142
+ 'fuel_efficiency_city' => 1.0 / (0.003259 + (1.1805 / (row['ucty'] || row['UNRND CITY (EPA)']).to_f)), # adjust for real-world driving
143
+ 'fuel_efficiency_highway' => 1.0 / (0.001376 + (1.3466 / (row['uhwy'] || row['UNRND HWY (EPA)']).to_f)), # adjust for real-world driving
144
+ 'cylinders' => row['cyl'] || row['NUMB CYL'],
145
+ 'displacement' => row['displ'] || row['DISPLACEMENT'],
146
+ 'turbo' => ((row['T'] || row['TURBO']) == 'T' || (row['carline name'] || row['CAR LINE']).downcase.include?('turbo')) ? true : false,
147
+ 'supercharger' => (row['S'] || row['SPCHGR']) == 'S',
148
+ 'injection' => true,
149
+ 'carline_class' => row['Class'] || row['CLASS']
150
+ })
151
+ else # 2010..present
152
+ row.merge!({
153
+ 'make_name' => row['Division'],
154
+ 'model_name' => row['Carline'].upcase,
155
+ 'year' => year,
156
+ 'transmission' => TRANSMISSIONS[row['Trans']],
157
+ 'speeds' => row['# Gears'].to_i,
158
+ 'drive' => row['Drive Sys'] + 'WD',
159
+ 'fuel_code' => FUEL_CODES[row['Fuel Usage - Conventional Fuel']],
160
+ 'fuel_efficiency_city' => row['City FE (Guide) - Conventional Fuel'],
161
+ 'fuel_efficiency_highway' => row['Hwy FE (Guide) - Conventional Fuel'],
162
+ 'alt_fuel_code' => FUEL_CODES[row[' Fuel2 Usage - Alternative Fuel']],
163
+ 'alt_fuel_efficiency_city' => row['City2 FE (Guide) - Alternative Fuel'],
164
+ 'alt_fuel_efficiency_highway' => row['Hwy2 Fuel FE (Guide) - Alternative Fuel'],
165
+ 'cylinders' => row['# Cyl'],
166
+ 'displacement' => row['Eng Displ'],
167
+ 'turbo' => row['Air Aspir Method'] == 'TC',
168
+ 'supercharger' => row['Air Aspir Method'] == 'SC',
169
+ 'injection' => row['# Cyl'].present? ? true : false,
170
+ 'carline_class' => row['Carline Class Desc']
171
+ })
172
+ end
135
173
  end
174
+
136
175
  def _displacement(row)
137
176
  optional_displacement = row['opt_disp'].gsub(/[\(\)]/, '').strip.to_s
138
177
  if optional_displacement =~ /^(\d\.\d)L$/
@@ -143,250 +182,142 @@ AutomobileMakeModelYearVariant.class_eval do
143
182
  row['disp_cub_in'].to_f.cubic_inches.to(:litres).round(1)
144
183
  end
145
184
  end
185
+
146
186
  def _turbo(row)
147
187
  engine_types = [ENGINE_TYPES[row['engine_desc1'].to_s], ENGINE_TYPES[row['engine_desc2'].to_s]]
148
- engine_types << (row['carline_name'].to_s.downcase.include?('turbo') ? 'turbo' : nil)
188
+ engine_types << (row['model_name'].to_s.downcase.include?('turbo') ? 'turbo' : nil)
149
189
  engine_types.flatten.include?('turbo')
150
190
  end
151
- end
152
-
153
- class AutomobileMakeModelYearVariant::ParserB
154
- attr_reader :year
155
- def initialize(options = {})
156
- options = options.stringify_keys
157
- @year = options['year']
158
- end
159
- def apply(row)
160
- row.merge!({
161
- 'make' => row['Manufacturer'], # make it line up with the errata
162
- 'model' => row['carline name'].upcase, # ditto
163
- 'drive' => row['drv'] + 'WD',
164
- 'transmission' => TRANSMISSIONS[row['trans'][-3, 1]],
165
- 'speeds' => (row['trans'][-2, 1] == 'V') ? '1' : row['trans'][-2, 1],
166
- 'turbo' => (row['T'] == 'T' || row['carline name'].to_s.downcase.include?('turbo')) ? true : false,
167
- 'supercharger' => row['S'] == 'S',
168
- 'injection' => true,
169
- 'year' => year
170
- })
171
- row
172
- end
173
- end
174
-
175
- class AutomobileMakeModelYearVariant::ParserC
176
- attr_reader :year
177
- def initialize(options = {})
178
- options = options.stringify_keys
179
- @year = options['year']
180
- end
181
- def apply(row)
182
- row.merge!({
183
- 'make' => row['MFR'], # make it line up with the errata
184
- 'model' => row['CAR LINE'].upcase, # ditto
185
- 'drive' => row['DRIVE SYS'] + 'WD',
186
- 'transmission' => TRANSMISSIONS[row['TRANS'][-3, 1]],
187
- 'speeds' => (row['TRANS'][-2, 1] == 'V') ? '1' : row['TRANS'][-2, 1],
188
- 'turbo' => row['TURBO'] == 'T',
189
- 'supercharger' => row['SPCHGR'] == 'S',
190
- 'injection' => true,
191
- 'year' => year
192
- })
193
- row
194
- end
195
- end
196
-
197
- class AutomobileMakeModelYearVariant::ParserD
198
- OLD_FUEL_CODES = {
199
- 'CNG' => 'C',
200
- 'DU' => 'D',
201
- 'G' => 'R',
202
- 'GP' => 'P',
203
- 'GPR' => 'P',
204
- 'GM' => 'P',
205
- 'BE' => 'BE',
206
- 'H' => 'H'
207
- }
208
- attr_reader :year
209
- def initialize(options = {})
210
- options = options.stringify_keys
211
- @year = options['year']
212
- end
213
- def apply(row)
214
- row.merge!({
215
- 'make' => row['Division'], # make it line up with the errata
216
- 'model' => row['Carline'].upcase, # ditto
217
- 'drive' => row['Drive Sys'] + 'WD',
218
- 'transmission' => TRANSMISSIONS[row['Trans']],
219
- 'speeds' => row['# Gears'],
220
- 'turbo' => row['Air Aspir Method'] == 'TC',
221
- 'supercharger' => row['Air Aspir Method'] == 'SC',
222
- 'injection' => true,
223
- 'year' => year,
224
- 'fuel_type_code' => OLD_FUEL_CODES[row['Fuel Usage - Conventional Fuel']]
225
- })
226
- row
191
+
192
+ # for the 1985-1997 fuel economy guides
193
+ ::FixedWidth.define :fuel_economy_guide do |d|
194
+ d.rows do |row|
195
+ row.trap { true } # there's only one section
196
+ row.column 'active_year', 4, :type => :integer # ACTIVE YEAR
197
+ row.column 'state_code', 1, :type => :string # STATE CODE: F=49-STATE,C=CALIFORNIA
198
+ row.column 'carline_clss', 2, :type => :integer # CARLINE CLASS CODE
199
+ row.column 'carline_mfr_code', 3, :type => :integer # CARLINE MANUFACTURER CODE
200
+ row.column 'carline_name', 28, :type => :string # CARLINE NAME
201
+ row.column 'disp_cub_in', 4, :type => :integer # DISP CUBIC INCHES
202
+ row.column 'fuel_system', 2, :type => :string # FUEL SYSTEM: 'FI' FOR FUEL INJECTION, 2-DIGIT INTEGER VALUE FOR #OF VENTURIES IF CARBURETOR SYSTEM.
203
+ row.column 'model_trans', 6, :type => :string # TRANSMISSION TYPE
204
+ row.column 'no_cyl', 2, :type => :integer # NUMBER OF ENGINE CYLINDERS
205
+ row.column 'date_time', 12, :type => :string # DATE AND TIME RECORD ENTERED -YYMMDDHHMMSS (YEAR, MONTH, DAY, HOUR, MINUTE, SECOND)
206
+ row.column 'release_date', 6, :type => :string # RELEASE DATE - YYMMDD (YEAR, MONTH, DAY)
207
+ row.column 'vi_mfr_code', 3, :type => :integer # VI MANUFACTURER CODE
208
+ row.column 'carline_code', 5, :type => :integer # CARLINE CODE
209
+ row.column 'basic_eng_id', 5, :type => :integer # BASIC ENGINE INDEX
210
+ row.column 'carline_mfr_name', 32, :type => :string # CARLINE MANUFACTURER NAME
211
+ row.column 'suppress_code', 1, :type => :integer # SUPPRESSION CODE (NO SUPPRESSED RECORD IF FOR PUBLIC ACCESS)
212
+ row.column 'city_mpg', 3, :type => :integer # ESTIMATED (CITY) MILES PER GALLON - 90% OF UNADJUSTED VALUE
213
+ row.spacer 2
214
+ row.column 'highway_mpg', 3, :type => :integer # ESTIMATED (HWY) MILES PER GALLON - 78% OF UNADJUSTED VALUE
215
+ row.spacer 2
216
+ row.column 'combined_mpg', 3, :type => :integer # COMBINED MILES PER GALLON
217
+ row.spacer 2
218
+ row.column 'unadj_city_mpg', 3, :type => :integer # UNADJUSTED CITY MILES PER GALLON
219
+ row.spacer 2
220
+ row.column 'unadj_hwy_mpg', 3, :type => :integer # UNADJUSTED HIGHWAY MILES PER GALLON
221
+ row.spacer 2
222
+ row.column 'unadj_comb_mpg', 3, :type => :integer # UNADJUSTED COMBINED MILES PER GALLON
223
+ row.spacer 2
224
+ row.column 'ave_anl_fuel', 6, :type => :integer # "$" in col 147, Annual Fuel Cost starting col 148 in I5
225
+ row.column 'opt_disp', 8, :type => :string # OPTIONAL DISPLACEMENT
226
+ row.column 'engine_desc1', 10, :type => :string # ENGINE DESCRIPTION 1
227
+ row.column 'engine_desc2', 10, :type => :string # ENGINE DESCRIPTION 2
228
+ row.column 'engine_desc3', 10, :type => :string # ENGINE DESCRIPTION 3
229
+ row.column 'body_type_2d', 10, :type => :string # BODY TYPE 2 DOOR - IF THE BODY TYPE APPLIES IT WILL TAKE THE FORM '2DR-PPP/LL' WHERE PPP=PASSENGER INTERIOR VOLUME AND LL=LUGGAGE INTERIOR VOLUME.
230
+ row.column 'body_type_4d', 10, :type => :string # BODY TYPE 4 DOOR - IF THE BODY TYPE APPLIES IT WILL TAKE THE FORM '4DR-PPP/LL' WHERE PPP=PASSENGER INTERIOR VOLUME AND LL=LUGGAGE INTERIOR VOLUME.
231
+ row.column 'body_type_hbk', 10, :type => :string # BODY TYPE HBK - IF THE BODY TYPE APPLIES IT WILL TAKE THE FORM 'HBK-PPP/LL' WHERE PPP=PASSENGER INTERIOR VOLUME AND LL=LUGGAGE INTERIOR VOLUME.
232
+ row.column 'puerto_rico', 1, :type => :string # '*' IF FOR PUERTO RICO SALES ONLY
233
+ row.column 'overdrive', 4, :type => :string # OVERDRIVE: ' OD ' FOR OVERDRIVE, 'EOD ' FOR ELECTRICALLY OPERATED OVERDRIVE AND 'AEOD' FOR AUTOMATIC OVERDRIVE
234
+ row.column 'drive_system', 3, :type => :string # FWD=FRONT WHEEL DRIVE, RWD=REAR, 4WD=4-WHEEL
235
+ row.column 'filler', 1, :type => :string # NOT USED
236
+ row.column 'fuel_type', 1, :type => :string # R=REGULAR(UNLEADED), P=PREMIUM, D=DIESEL
237
+ row.column 'trans_desc', 15, :type => :string # TRANSMISSION DESCRIPTORS
238
+ end
227
239
  end
228
240
  end
229
241
 
230
242
  data_miner do
231
- # 1985---1997
232
- # FIXME TODO 14 records in the 1995 FEG are missing fuel efficiencies
233
- (85..97).each do |yy|
234
- filename = (yy == 96) ? "#{yy}MFGUI.ASC" : "#{yy}MFGUI.DAT"
235
- import "19#{ yy } Fuel Economy Guide",
236
- :url => "http://www.fueleconomy.gov/FEG/epadata/#{yy}mfgui.zip",
237
- :format => :fixed_width,
238
- :cut => ((yy == 95) ? '13-' : nil),
239
- :schema_name => :fuel_economy_guide_a,
240
- :select => proc { |row| row['model'].present? and (row['suppress_code'].blank? or row['suppress_code'].to_f == 0) and row['state_code'] == 'F' },
241
- :filename => filename,
242
- :transform => { :class => AutomobileMakeModelYearVariant::ParserA, :year => "19#{yy}".to_i },
243
- :errata => { :url => "file://#{Earth::ERRATA_DIR}/automobile_make_model_year_variant/feg_errata.csv", :responder => AutomobileMakeModelYearVariant::Guru.new } do
244
- key 'row_hash'
245
- store 'make_name', :field_name => 'make'
246
- store 'model_name', :field_name => 'model'
247
- store 'year'
248
- store 'transmission'
249
- store 'speeds'
250
- store 'drive', :field_name => 'drive_system'
251
- store 'fuel_code', :field_name => 'fuel_type'
252
- store 'cylinders', :field_name => 'no_cyc'
253
- store 'displacement'
254
- store 'turbo'
255
- store 'supercharger'
256
- store 'injection'
257
- store 'raw_fuel_efficiency_city', :field_name => 'unadj_city_mpg', :from_units => :miles_per_gallon, :to_units => :kilometres_per_litre
258
- store 'raw_fuel_efficiency_highway', :field_name => 'unadj_hwy_mpg', :from_units => :miles_per_gallon, :to_units => :kilometres_per_litre
259
- store 'carline_mfr_code'
260
- store 'vi_mfr_code'
261
- store 'carline_code'
262
- store 'carline_class_code', :field_name => 'carline_clss'
263
- end
243
+ fuel_economy_guides = (1985..1997).inject({}) do |memo, year|
244
+ yy = year.to_s[2..3]
245
+ memo[year] = {
246
+ :url => "http://www.fueleconomy.gov/FEG/epadata/#{yy}mfgui.zip",
247
+ :filename => ((yy == "96") ? "#{yy}MFGUI.ASC" : "#{yy}MFGUI.DAT"),
248
+ :format => :fixed_width,
249
+ :schema_name => :fuel_economy_guide,
250
+ :cut => ((yy == "95") ? '13-' : nil),
251
+ :select => proc { |row| row['model_name'].present? and (row['suppress_code'].blank? or row['suppress_code'].to_f == 0) and row['state_code'] == 'F' }
252
+ }
253
+ memo
264
254
  end
265
255
 
266
- # 1998--2005
267
- {
268
- # FIXME TODO 2005 Mercedes-Benz SLK55 AMG has NULL speeds (it does in the EPA FEG also)
269
- # FIXME TODO numbers from xls files are getting imported as floats rather than integers (e.g. 4.0WD rather than 4WD)
256
+ fuel_economy_guides.merge!({
270
257
  1998 => { :url => 'http://www.fueleconomy.gov/FEG/epadata/98guide6.zip', :filename => '98guide6.csv' },
271
- 1999 => { :url => 'http://www.fueleconomy.gov/FEG/epadata/99guide.zip', :filename => '99guide6.csv' },
272
- 2000 => { :url => 'http://www.fueleconomy.gov/FEG/epadata/00data.zip', :filename => 'G6080900.xls' },
258
+ 1999 => { :url => 'http://www.fueleconomy.gov/FEG/epadata/99guide.zip', :filename => '99guide6.csv' },
259
+ 2000 => { :url => 'http://www.fueleconomy.gov/FEG/epadata/00data.zip', :filename => 'G6080900.xls' },
273
260
  2001 => { :url => 'http://static.brighterplanet.com/science/data/transport/automobiles/fuel_economy_guide/01guide0918.csv' }, # parseexcel 0.5.2 can't read Excel 5.0 { :url => 'http://www.fueleconomy.gov/FEG/epadata/01data.zip', :filename => '01guide0918.xls' }
274
- 2002 => { :url => 'http://www.fueleconomy.gov/FEG/epadata/02data.zip', :filename => 'guide_jan28.xls' },
275
- 2003 => { :url => 'http://www.fueleconomy.gov/FEG/epadata/03data.zip', :filename => 'guide_2003_feb04-03b.csv' },
276
- 2004 => { :url => 'http://www.fueleconomy.gov/FEG/epadata/04data.zip', :filename => 'gd04-Feb1804-RelDtFeb20.csv' },
277
- 2005 => { :url => 'http://www.fueleconomy.gov/FEG/epadata/05data.zip', :filename => 'guide2005-2004oct15.csv' }
278
- }.each do |year, options|
279
- import "#{ year } Fuel Economy Guide",
280
- options.merge(:transform => { :class => AutomobileMakeModelYearVariant::ParserB, :year => year },
281
- :errata => { :url => "file://#{Earth::ERRATA_DIR}/automobile_make_model_year_variant/feg_errata.csv", :responder => AutomobileMakeModelYearVariant::Guru.new },
282
- :select => proc { |row| row['model'].present? }) do
283
- key 'row_hash'
284
- store 'make_name', :field_name => 'make'
285
- store 'model_name', :field_name => 'model'
286
- store 'year'
287
- store 'transmission'
288
- store 'speeds'
289
- store 'drive'
290
- store 'fuel_code', :field_name => 'fl'
291
- store 'cylinders', :field_name => 'cyl'
292
- store 'displacement', :field_name => 'displ'
293
- store 'turbo'
294
- store 'supercharger'
295
- store 'injection'
296
- store 'raw_fuel_efficiency_highway', :field_name => 'uhwy', :from_units => :miles_per_gallon, :to_units => :kilometres_per_litre
297
- store 'raw_fuel_efficiency_city', :field_name => 'ucty', :from_units => :miles_per_gallon, :to_units => :kilometres_per_litre
298
- store 'carline_class_code', :field_name => 'cls' if year >= 2000
299
- store 'carline_class_name', :field_name => 'Class'
300
- end
301
- end
302
-
303
- # 2006--2009
304
- {
305
- 2006 => { :url => 'http://www.fueleconomy.gov/FEG/epadata/06data.zip', :filename => '2006_FE_Guide_14-Nov-2005_download.csv' },
261
+ 2002 => { :url => 'http://www.fueleconomy.gov/FEG/epadata/02data.zip', :filename => 'guide_jan28.xls' },
262
+ 2003 => { :url => 'http://www.fueleconomy.gov/FEG/epadata/03data.zip', :filename => 'guide_2003_feb04-03b.csv' },
263
+ 2004 => { :url => 'http://www.fueleconomy.gov/FEG/epadata/04data.zip', :filename => 'gd04-Feb1804-RelDtFeb20.csv' },
264
+ 2005 => { :url => 'http://www.fueleconomy.gov/FEG/epadata/05data.zip', :filename => 'guide2005-2004oct15.csv' },
265
+ 2006 => { :url => 'http://www.fueleconomy.gov/FEG/epadata/06data.zip', :filename => '2006_FE_Guide_14-Nov-2005_download.csv' },
306
266
  2007 => { :url => 'http://static.brighterplanet.com/science/data/transport/automobiles/fuel_economy_guide/2007_FE_guide_ALL_no_sales_May_01_2007.csv' }, # the 07data.xls file provided by the government has a bad encoding
307
- 2008 => { :url => 'http://www.fueleconomy.gov/FEG/epadata/08data.zip', :filename => '2008_FE_guide_ALL_rel_dates_-no sales-for DOE-5-1-08.csv' },
308
- 2009 => { :url => 'http://www.fueleconomy.gov/FEG/epadata/09data.zip', :filename => '2009_FE_guide for DOE_ALL-rel dates-no-sales-8-28-08download.csv' }
309
- }.each do |year, options|
310
- import "#{ year } Fuel Economy Guide",
311
- options.merge(:transform => { :class => AutomobileMakeModelYearVariant::ParserC, :year => year },
312
- :errata => { :url => "file://#{Earth::ERRATA_DIR}/automobile_make_model_year_variant/feg_errata.csv", :responder => AutomobileMakeModelYearVariant::Guru.new },
313
- :select => proc { |row| row['model'].present? }) do
314
- key 'row_hash'
315
- store 'make_name', :field_name => 'make'
316
- store 'model_name', :field_name => 'model'
317
- store 'year'
318
- store 'fuel_code', :field_name => 'FUEL TYPE'
319
- store 'fuel_efficiency_highway', :static => nil, :units => :kilometres_per_litre
320
- store 'fuel_efficiency_city', :static => nil, :units => :kilometres_per_litre
321
- store 'raw_fuel_efficiency_highway', :field_name => 'UNRND HWY (EPA)', :from_units => :miles_per_gallon, :to_units => :kilometres_per_litre
322
- store 'raw_fuel_efficiency_city', :field_name => 'UNRND CITY (EPA)', :from_units => :miles_per_gallon, :to_units => :kilometres_per_litre
323
- store 'cylinders', :field_name => 'NUMB CYL'
324
- store 'displacement', :field_name => 'DISPLACEMENT'
325
- store 'carline_class_code', :field_name => 'CLS'
326
- store 'carline_class_name', :field_name => 'CLASS'
327
- store 'transmission'
328
- store 'speeds'
329
- store 'turbo'
330
- store 'supercharger'
331
- store 'injection'
332
- store 'drive'
333
- end
267
+ 2008 => { :url => 'http://www.fueleconomy.gov/FEG/epadata/08data.zip', :filename => '2008_FE_guide_ALL_rel_dates_-no sales-for DOE-5-1-08.csv' },
268
+ 2009 => { :url => 'http://www.fueleconomy.gov/FEG/epadata/09data.zip', :filename => '2009_FE_guide for DOE_ALL-rel dates-no-sales-8-28-08download.csv' },
269
+ 2010 => { :url => 'http://www.fueleconomy.gov/FEG/epadata/10data.zip', :filename => '2010FEGuide for DOE-all rel dates-no-sales-02-22-2011public.xlsx' },
270
+ 2011 => { :url => 'http://www.fueleconomy.gov/FEG/epadata/11data.zip', :filename => '2011FEGuide-for DOE rel-dates before 1-23-2011-no-sales-01-10-2011_All_public.xlsx' },
271
+ 2012 => { :url => 'http://www.fueleconomy.gov/feg/epadata/12data.zip', :filename => '2012 FEGuide for DOE-rev1-rel dates before 3-13-2012-no-sales-3-7-2012public3-20.xlsx' }
272
+ })
273
+
274
+ fuel_economy_guides.each do |year, options|
275
+ options.merge!({
276
+ :transform => { :class => AutomobileMakeModelYearVariant::Parser, :year => year },
277
+ :select => (options[:select] || proc { |row| row['model_name'].present? }),
278
+ :errata => {
279
+ :url => "file://#{Earth::ERRATA_DIR}/automobile_make_model_year_variant/feg_errata.csv",
280
+ :responder => "AutomobileMakeModelYearVariant::Guru"
281
+ }
282
+ })
334
283
  end
335
284
 
336
- # 2010--?
337
- {
338
- # FIXME TODO numbers from xlsx files are getting imported as floats rather than integers (e.g. speeds = 6.0 rather than 6)
339
- # Note: it's ok for electric vehicles to be missing cylinders and displacement
340
- 2010 => { :url => 'http://www.fueleconomy.gov/FEG/epadata/10data.zip', :filename => '2010FEGuide for DOE-all rel dates-no-sales-02-22-2011public.xlsx' },
341
- 2011 => { :url => 'http://www.fueleconomy.gov/FEG/epadata/11data.zip', :filename => '2011FEGuide-for DOE rel-dates before 1-23-2011-no-sales-01-10-2011_All_public.xlsx' }
342
- }.each do |year, options|
343
- import "#{ year } Fuel Economy Guide",
344
- options.merge(:transform => { :class => AutomobileMakeModelYearVariant::ParserD, :year => year },
345
- :errata => { :url => "file://#{Earth::ERRATA_DIR}/automobile_make_model_year_variant/feg_errata.csv", :responder => AutomobileMakeModelYearVariant::Guru.new },
346
- :select => proc { |row| row['model'].present? }) do
285
+ fuel_economy_guides.each do |year, options|
286
+ import "#{year} Fuel Economy Guide", options do
347
287
  key 'row_hash'
348
- store 'make_name', :field_name => 'make'
349
- store 'model_name', :field_name => 'model'
288
+ store 'make_name'
289
+ store 'model_name'
350
290
  store 'year'
351
- store 'fuel_code', :field_name => 'fuel_type_code'
352
- store 'fuel_efficiency_highway', :static => nil, :units => :kilometres_per_litre
353
- store 'fuel_efficiency_city', :static => nil, :units => :kilometres_per_litre
354
- store 'raw_fuel_efficiency_highway', :field_name => 'Hwy Unadj FE - Conventional Fuel', :from_units => :miles_per_gallon, :to_units => :kilometres_per_litre
355
- store 'raw_fuel_efficiency_city', :field_name => 'City Unadj FE - Conventional Fuel', :from_units => :miles_per_gallon, :to_units => :kilometres_per_litre
356
- store 'cylinders', :field_name => '# Cyl'
357
- store 'displacement', :field_name => 'Eng Displ'
358
- store 'carline_class_code', :field_name => 'Carline Class'
359
- store 'carline_class_name', :field_name => 'Carline Class Desc'
360
291
  store 'transmission'
361
292
  store 'speeds'
293
+ store 'drive'
294
+ store 'fuel_code'
295
+ store 'fuel_efficiency_city', :from_units => :miles_per_gallon, :to_units => :kilometres_per_litre
296
+ store 'fuel_efficiency_highway', :from_units => :miles_per_gallon, :to_units => :kilometres_per_litre
297
+ store 'alt_fuel_code'
298
+ store 'alt_fuel_efficiency_city', :from_units => :miles_per_gallon, :to_units => :kilometres_per_litre
299
+ store 'alt_fuel_efficiency_highway', :from_units => :miles_per_gallon, :to_units => :kilometres_per_litre
300
+ store 'cylinders'
301
+ store 'displacement'
362
302
  store 'turbo'
363
303
  store 'supercharger'
364
304
  store 'injection'
365
- store 'drive'
305
+ store 'carline_class'
366
306
  end
367
307
  end
368
308
 
369
- # Note: need to divide by 0.425143707 b/c equation is designed for miles / gallon not km / l
370
- # Note: EPA seems to adjust differently for plug-in hybrid electric vehicles (e.g. Leaf and Volt)
371
- process "Calculate adjusted fuel efficiency using the latest EPA equations from EPA Fuel Economy Trends report Appendix A including conversion from miles per gallon to kilometres per litre" do
372
- where("raw_fuel_efficiency_city > 0").update_all(%{
373
- fuel_efficiency_city = 1.0 / ((0.003259 / 0.425143707) + (1.1805 / raw_fuel_efficiency_city)),
374
- fuel_efficiency_city_units = 'kilometres_per_litre'
375
- })
376
- where("raw_fuel_efficiency_highway > 0").update_all(%{
377
- fuel_efficiency_highway = 1.0 / ((0.001376 / 0.425143707) + (1.3466 / raw_fuel_efficiency_highway)),
378
- fuel_efficiency_highway_units = 'kilometres_per_litre'
379
- })
380
- end
381
-
382
- # This will be useful later for calculating MakeModel and Make fuel efficiency based on Variant
309
+ # Combined fuel efficiency will be useful later when deriving MakeModel and Make fuel efficiency
383
310
  # NOTE: we use a 43/57 city/highway weighting per the latest EPA analysis of real-world driving behavior
384
311
  # This results in a deviation from EPA fuel economy label values which use a historical 55/45 weighting
385
312
  process "Calculate combined adjusted fuel efficiency using the latest EPA equation" do
386
- update_all(%{
313
+ where("fuel_efficiency_city IS NOT NULL AND fuel_efficiency_highway IS NOT NULL").update_all(%{
387
314
  fuel_efficiency = 1.0 / ((0.43 / fuel_efficiency_city) + (0.57 / fuel_efficiency_highway)),
388
315
  fuel_efficiency_units = 'kilometres_per_litre'
389
316
  })
317
+ where("alt_fuel_efficiency_city IS NOT NULL AND alt_fuel_efficiency_highway IS NOT NULL").update_all(%{
318
+ alt_fuel_efficiency = 1.0 / ((0.43 / alt_fuel_efficiency_city) + (0.57 / alt_fuel_efficiency_highway)),
319
+ alt_fuel_efficiency_units = 'kilometres_per_litre'
320
+ })
390
321
  end
391
322
  end
392
323
  end