automobile-ruby19 0.0.13
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +5 -0
- data/README.rdoc +17 -0
- data/features/automobile_committees.feature +36 -0
- data/features/automobile_emissions.feature +13 -0
- data/features/support/env.rb +8 -0
- data/lib/automobile.rb +17 -0
- data/lib/automobile/carbon_model.rb +213 -0
- data/lib/automobile/characterization.rb +38 -0
- data/lib/automobile/data.rb +34 -0
- data/lib/automobile/summarization.rb +15 -0
- data/lib/test_support/automobile_record.rb +32 -0
- data/lib/test_support/db/schema.rb +24 -0
- metadata +228 -0
data/LICENSE
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
Copyright (c) 2010 Brighter Planet
|
2
|
+
|
3
|
+
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
|
4
|
+
|
5
|
+
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
data/README.rdoc
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= automobile
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
+
* Send me a pull request. Bonus points for topic branches.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 Brighter Planet. See LICENSE for details.
|
@@ -0,0 +1,36 @@
|
|
1
|
+
Feature: Automobile Committee Calculations
|
2
|
+
The automobile model should generate correct committee calculations
|
3
|
+
|
4
|
+
Scenario Outline: Retirement committee from acquisition
|
5
|
+
Given an automobile emitter
|
6
|
+
And a characteristic "timeframe" of "<timeframe>"
|
7
|
+
And a characteristic "acquisition" of "<acquisition>"
|
8
|
+
When the "retirement" committee is calculated
|
9
|
+
Then the conclusion of the committee should be "<retirement_committee>"
|
10
|
+
Examples:
|
11
|
+
| timeframe | acquisition | retirement_committee |
|
12
|
+
| 2009-03-04/2009-08-17 | 2010-04-21 | 2010-04-21 |
|
13
|
+
| 2009-03-04/2009-08-17 | 2007-01-30 | 2009-08-17 |
|
14
|
+
| 2009-03-04/2009-08-17 | | 2009-08-17 |
|
15
|
+
|
16
|
+
Scenario Outline: Acquisition committee from model year or year
|
17
|
+
Given an automobile emitter
|
18
|
+
And a characteristic "model_year.name" of "<make_model_year>"
|
19
|
+
And a characteristic "year" of "<year>"
|
20
|
+
When the "acquisition" committee is calculated
|
21
|
+
Then the conclusion of the committee should be "<acquisition_committee>"
|
22
|
+
Examples:
|
23
|
+
| make_model_year | year | acquisition_committee |
|
24
|
+
| | 2007 | 2007-01-01 |
|
25
|
+
| Honda FIT 2008 | | 2008-01-01 |
|
26
|
+
|
27
|
+
Scenario Outline: Acquisition committee from retirement
|
28
|
+
Given an automobile emitter
|
29
|
+
And a characteristic "timeframe" of "<timeframe>"
|
30
|
+
And a characteristic "retirement" of "<retirement>"
|
31
|
+
When the "acquisition" committee is calculated
|
32
|
+
Then the conclusion of the committee should be "<acquisition_committee>"
|
33
|
+
Examples:
|
34
|
+
| timeframe | retirement | acquisition_committee |
|
35
|
+
| 2010-08-10/2010-09-16 | 2007-02-03 | 2007-02-03 |
|
36
|
+
| 2010-08-10/2010-09-16 | | 2010-08-10 |
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Feature: Automobile Emissions Calculations
|
2
|
+
The automobile model should generate correct emission calculations
|
3
|
+
|
4
|
+
Scenario Outline: Standard Calculations for automobiles
|
5
|
+
Given an automobile has "annual_distance_estimate" of "<distance>"
|
6
|
+
And it has "timeframe" of "<timeframe>"
|
7
|
+
And it has "model_year.name" of "<make_model_year>"
|
8
|
+
When emissions are calculated
|
9
|
+
Then the emission value should be within "0.1" kgs of "<emission>"
|
10
|
+
Examples:
|
11
|
+
| distance | make_model_year | timeframe | emission |
|
12
|
+
| 30000 | Acura RSX 2003 | 2008-01-30/2009-05-20| 8706.4 |
|
13
|
+
| 80000 | Honda FIT 2008 | 2008-01-30/2009-05-20| 23217.1 |
|
data/lib/automobile.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'emitter'
|
2
|
+
|
3
|
+
module BrighterPlanet
|
4
|
+
module Automobile
|
5
|
+
extend BrighterPlanet::Emitter
|
6
|
+
|
7
|
+
def self.automobile_model
|
8
|
+
if Object.const_defined? 'Automobile'
|
9
|
+
::Automobile
|
10
|
+
elsif Object.const_defined? 'AutomobileRecord'
|
11
|
+
AutomobileRecord
|
12
|
+
else
|
13
|
+
raise 'There is no automobile model'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,213 @@
|
|
1
|
+
require 'conversions'
|
2
|
+
|
3
|
+
module BrighterPlanet
|
4
|
+
module Automobile
|
5
|
+
module CarbonModel
|
6
|
+
def self.included(base)
|
7
|
+
base.decide :emission, :with => :characteristics do
|
8
|
+
committee :emission do # returns kg CO2
|
9
|
+
quorum 'from fuel', :needs => [:fuel_consumed, :emission_factor], :appreciates => :fuel_type do |characteristics|
|
10
|
+
if characteristics[:fuel_type].andand.code == AutomobileFuelType::CODES[:electricity]
|
11
|
+
0.0 # FIXME waiting for fuel_efficiency values in kilometres per kWh from fuel_efficiency
|
12
|
+
else
|
13
|
+
characteristics[:fuel_consumed] * characteristics[:emission_factor]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
quorum 'default' do
|
18
|
+
raise "The emission committee's default quorum should never be called"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
committee :emission_factor do # returns kilograms CO2 per litre **OR** kilograms CO2 per litre
|
23
|
+
quorum 'from fuel type', :needs => :fuel_type do |characteristics|
|
24
|
+
characteristics[:fuel_type].emission_factor
|
25
|
+
end
|
26
|
+
|
27
|
+
quorum 'default' do
|
28
|
+
AutomobileFuelType.fallback.emission_factor
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
committee :fuel_consumed do # returns litres
|
33
|
+
quorum 'from adjusted fuel_efficiency and distance', :needs => [:adjusted_fuel_efficiency, :distance] do |characteristics|
|
34
|
+
characteristics[:distance] / characteristics[:adjusted_fuel_efficiency]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
committee :distance do # returns kilometres
|
39
|
+
quorum 'from annual distance', :needs => [:annual_distance, :active_subtimeframe] do |characteristics, timeframe|
|
40
|
+
characteristics[:annual_distance] * (characteristics[:active_subtimeframe] / timeframe.year)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
committee :annual_distance do # returns kilometres
|
45
|
+
quorum 'from annual distance estimate', :needs => :annual_distance_estimate do |characteristics|
|
46
|
+
characteristics[:annual_distance_estimate]
|
47
|
+
end
|
48
|
+
|
49
|
+
quorum 'from weekly distance estimate', :needs => :weekly_distance_estimate do |characteristics, timeframe|
|
50
|
+
(characteristics[:weekly_distance_estimate] / 7 ) * timeframe.year.days
|
51
|
+
end
|
52
|
+
|
53
|
+
quorum 'from daily distance', :needs => :daily_distance do |characteristics, timeframe|
|
54
|
+
characteristics[:daily_distance] * timeframe.year.days
|
55
|
+
end
|
56
|
+
|
57
|
+
quorum 'from size class', :needs => :size_class do |characteristics|
|
58
|
+
characteristics[:size_class].annual_distance
|
59
|
+
end
|
60
|
+
|
61
|
+
quorum 'from fuel type', :needs => :fuel_type do |characteristics|
|
62
|
+
characteristics[:fuel_type].annual_distance
|
63
|
+
end
|
64
|
+
|
65
|
+
quorum 'default' do
|
66
|
+
Automobile.automobile_model.fallback.annual_distance_estimate
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
committee :daily_distance do # returns kilometres
|
71
|
+
quorum 'from daily distance estimate', :needs => :daily_distance_estimate do |characteristics|
|
72
|
+
characteristics[:daily_distance_estimate]
|
73
|
+
end
|
74
|
+
|
75
|
+
quorum 'from daily duration', :needs => [:daily_duration, :speed] do |characteristics|
|
76
|
+
characteristics[:daily_duration] * characteristics[:speed]
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
committee :adjusted_fuel_efficiency do # returns kilometres per litre
|
81
|
+
quorum 'from fuel efficiency', :needs => :fuel_efficiency do |characteristics|
|
82
|
+
characteristics[:fuel_efficiency]
|
83
|
+
end
|
84
|
+
|
85
|
+
quorum 'from variant', :needs => [:variant, :urbanity] do |characteristics|
|
86
|
+
fuel_efficiencies = characteristics[:variant].attributes.symbolize_keys.slice(:fuel_efficiency_city, :fuel_efficiency_highway)
|
87
|
+
urbanity = characteristics[:urbanity]
|
88
|
+
1.0 / ((urbanity / fuel_efficiencies[:fuel_efficiency_city].to_f) + ((1.0 - urbanity) / fuel_efficiencies[:fuel_efficiency_highway].to_f))
|
89
|
+
end
|
90
|
+
|
91
|
+
quorum 'from nominal fuel efficiency and multiplier', :needs => [:nominal_fuel_efficiency, :fuel_efficiency_multiplier] do |characteristics|
|
92
|
+
characteristics[:nominal_fuel_efficiency] * characteristics[:fuel_efficiency_multiplier]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
committee :fuel_efficiency_multiplier do # returns coefficient
|
97
|
+
quorum 'from_size_class_and_hybridity', :needs => [:size_class, :hybridity, :urbanity] do |characteristics|
|
98
|
+
drivetrain = characteristics[:hybridity] ? :hybrid : :conventional
|
99
|
+
urbanity = characteristics[:urbanity]
|
100
|
+
size_class = characteristics[:size_class]
|
101
|
+
fuel_efficiency_multipliers = {
|
102
|
+
:city => size_class.send(:"#{drivetrain}_fuel_efficiency_city_multiplier"),
|
103
|
+
:highway => size_class.send(:"#{drivetrain}_fuel_efficiency_highway_multiplier")
|
104
|
+
}
|
105
|
+
if fuel_efficiency_multipliers.values.any?(&:nil?)
|
106
|
+
nil
|
107
|
+
else
|
108
|
+
1.0 / ((urbanity / fuel_efficiency_multipliers[:city]) + ((1.0 - urbanity) / fuel_efficiency_multipliers[:highway]))
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
quorum 'from hybridity', :needs => [:hybridity, :urbanity] do |characteristics|
|
113
|
+
drivetrain = characteristics[:hybridity] ? :hybrid : :conventional
|
114
|
+
urbanity = characteristics[:urbanity]
|
115
|
+
fuel_efficiency_multipliers = {
|
116
|
+
:city => AutomobileSizeClass.fallback.send(:"#{drivetrain}_fuel_efficiency_city_multiplier"),
|
117
|
+
:highway => AutomobileSizeClass.fallback.send(:"#{drivetrain}_fuel_efficiency_highway_multiplier")
|
118
|
+
}
|
119
|
+
1.0 / ((urbanity / fuel_efficiency_multipliers[:city]) + ((1.0 - urbanity) / fuel_efficiency_multipliers[:highway]))
|
120
|
+
end
|
121
|
+
|
122
|
+
quorum 'default' do
|
123
|
+
1.0
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
committee :nominal_fuel_efficiency do # returns kilometres per litre **OR** (FIXME) kilometres per kWh
|
128
|
+
quorum 'from model', :needs => [:model, :urbanity] do |characteristics|
|
129
|
+
fuel_efficiency_city = characteristics[:model].fuel_efficiency_city.to_f
|
130
|
+
fuel_efficiency_highway = characteristics[:model].fuel_efficiency_highway.to_f
|
131
|
+
urbanity = characteristics[:urbanity]
|
132
|
+
1.0 / ((urbanity / fuel_efficiency_city) + ((1.0 - urbanity) / fuel_efficiency_highway))
|
133
|
+
end
|
134
|
+
|
135
|
+
quorum 'from make and model year', :needs => [:model_year] do |characteristics|
|
136
|
+
characteristics[:model_year].make_year.andand.fuel_efficiency
|
137
|
+
end
|
138
|
+
|
139
|
+
quorum 'from size class', :needs => [:size_class, :urbanity] do |characteristics|
|
140
|
+
fuel_efficiencies = characteristics[:size_class].attributes.symbolize_keys.slice(:fuel_efficiency_city, :fuel_efficiency_highway)
|
141
|
+
urbanity = characteristics[:urbanity]
|
142
|
+
1.0 / ((urbanity / fuel_efficiencies[:fuel_efficiency_city].to_f) + ((1.0 - urbanity) / fuel_efficiencies[:fuel_efficiency_highway].to_f))
|
143
|
+
end
|
144
|
+
|
145
|
+
quorum 'from model year', :needs => :model_year do |characteristics|
|
146
|
+
characteristics[:model_year].fuel_efficiency
|
147
|
+
end
|
148
|
+
|
149
|
+
quorum 'from make', :needs => :make do |characteristics|
|
150
|
+
characteristics[:make].fuel_efficiency
|
151
|
+
end
|
152
|
+
|
153
|
+
quorum 'default' do
|
154
|
+
Automobile.automobile_model.fallback.fuel_efficiency
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
committee :speed do # returns kilometres per hour
|
159
|
+
quorum 'from urbanity', :needs => :urbanity do |characteristics|
|
160
|
+
1 / (characteristics[:urbanity] / ::BrighterPlanet::Automobile::CarbonModel::SPEEDS[:city] + (1 - characteristics[:urbanity]) / ::BrighterPlanet::Automobile::CarbonModel::SPEEDS[:highway])
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
committee :urbanity do
|
165
|
+
quorum 'default' do
|
166
|
+
Automobile.automobile_model.fallback.urbanity
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
committee :fuel_type do
|
171
|
+
quorum 'from variant', :needs => :variant do |characteristics|
|
172
|
+
characteristics[:variant].fuel_type
|
173
|
+
end
|
174
|
+
|
175
|
+
quorum 'default' do
|
176
|
+
Automobile.automobile_model.fallback.fuel_type
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
committee :active_subtimeframe do
|
181
|
+
quorum 'from acquisition and retirement', :needs => [:acquisition, :retirement] do |characteristics, timeframe|
|
182
|
+
Timeframe.constrained_new characteristics[:acquisition].to_date, characteristics[:retirement].to_date, timeframe
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
committee :acquisition do
|
187
|
+
quorum 'from model year or year', :appreciates => [:model_year, :year] do |characteristics|
|
188
|
+
if characteristics[:model_year]
|
189
|
+
Date.new characteristics[:model_year].year, 1, 1
|
190
|
+
elsif characteristics[:year]
|
191
|
+
Date.new characteristics[:year].to_i, 1, 1
|
192
|
+
end
|
193
|
+
end
|
194
|
+
quorum 'from retirement', :appreciates => :retirement do |characteristics, timeframe|
|
195
|
+
[ timeframe.from, characteristics[:retirement] ].compact.min
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
committee :retirement do
|
200
|
+
quorum 'from acquisition', :appreciates => :acquisition do |characteristics, timeframe|
|
201
|
+
[ timeframe.to, characteristics[:acquisition] ].compact.max
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
end
|
206
|
+
end
|
207
|
+
SPEEDS = {
|
208
|
+
:highway => 57.1.miles.to(:kilometres), # https://brighterplanet.sifterapp.com/projects/30/issues/428
|
209
|
+
:city => 19.9.miles.to(:kilometres) # https://brighterplanet.sifterapp.com/projects/30/issues/428
|
210
|
+
}
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module BrighterPlanet
|
2
|
+
module Automobile
|
3
|
+
module Characterization
|
4
|
+
def self.included(base)
|
5
|
+
base.characterize do
|
6
|
+
has :make do |make|
|
7
|
+
make.reveals :model_year do |model_year|
|
8
|
+
model_year.reveals :model, :trumps => :size_class do |model|
|
9
|
+
model.reveals :variant, :trumps => :hybridity
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
## sabshere 5/27/10: thought exercise... if we wanted people to send in make=ford&model=taurus&model_year=2006 (of course it would be &naked_model=, but you get the point)
|
14
|
+
# has :make do |make|
|
15
|
+
# make.reveals :naked_model_year do |model_year|
|
16
|
+
# model_year.reveals :model, :naked_trumps => :size_class do |model|
|
17
|
+
# model.reveals :naked_variant, :trumps => :hybridity
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
# end
|
21
|
+
has :fuel_type
|
22
|
+
has :fuel_efficiency, :trumps => [:urbanity, :hybridity], :measures => :length_per_volume
|
23
|
+
has :urbanity, :measures => :percentage
|
24
|
+
has :hybridity
|
25
|
+
has :daily_distance_estimate, :trumps => [:weekly_distance_estimate, :annual_distance_estimate, :daily_duration], :measures => :length #, :weekly_fuel_cost, :annual_fuel_cost]
|
26
|
+
has :daily_duration, :trumps => [:annual_distance_estimate, :weekly_distance_estimate, :daily_distance_estimate], :measures => :time #, :weekly_fuel_cost, :annual_fuel_cost]
|
27
|
+
has :weekly_distance_estimate, :trumps => [:annual_distance_estimate, :daily_distance_estimate, :daily_duration], :measures => :length #, :weekly_fuel_cost, :annual_fuel_cost]
|
28
|
+
has :annual_distance_estimate, :trumps => [:weekly_distance_estimate, :daily_distance_estimate, :daily_duration], :measures => :length #, :weekly_fuel_cost, :annual_fuel_cost]
|
29
|
+
has :acquisition
|
30
|
+
has :retirement
|
31
|
+
has :size_class
|
32
|
+
# has :annual_fuel_cost, :trumps => [:annual_distance_estimate, :weekly_distance_estimate, :daily_distance_estimate, :daily_duration, :weekly_fuel_cost], :measures => :cost
|
33
|
+
# has :weekly_fuel_cost, :trumps => [:annual_distance_estimate, :weekly_distance_estimate, :daily_distance_estimate, :daily_duration, :annual_fuel_cost], :measures => :cost
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module BrighterPlanet
|
2
|
+
module Automobile
|
3
|
+
module Data
|
4
|
+
def self.included(base)
|
5
|
+
base.data_miner do
|
6
|
+
schema do
|
7
|
+
string 'make_id'
|
8
|
+
string 'model_id'
|
9
|
+
string 'model_year_id'
|
10
|
+
string 'variant_id'
|
11
|
+
string 'size_class_id'
|
12
|
+
string 'fuel_type_id'
|
13
|
+
boolean 'hybridity'
|
14
|
+
float 'urbanity'
|
15
|
+
float 'fuel_efficiency'
|
16
|
+
float 'annual_distance_estimate'
|
17
|
+
float 'weekly_distance_estimate'
|
18
|
+
float 'daily_distance_estimate'
|
19
|
+
float 'daily_duration'
|
20
|
+
date 'date'
|
21
|
+
date 'acquisition'
|
22
|
+
date 'retirement'
|
23
|
+
end
|
24
|
+
|
25
|
+
process "pull orphans" do
|
26
|
+
AutomobileMakeFleetYear.run_data_miner! # sabshere 5/25/10 i'm not sure we actually need to have this in cm1
|
27
|
+
end
|
28
|
+
|
29
|
+
process :run_data_miner_on_belongs_to_associations
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module BrighterPlanet
|
2
|
+
module Automobile
|
3
|
+
module Summarization
|
4
|
+
def self.included(base)
|
5
|
+
base.summarize do |has|
|
6
|
+
has.adjective :model_year
|
7
|
+
has.adjective :make
|
8
|
+
has.adjective :model
|
9
|
+
has.identity 'automobile'
|
10
|
+
has.verb :own
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
require 'falls_back_on'
|
3
|
+
require 'automobile'
|
4
|
+
require 'sniff'
|
5
|
+
|
6
|
+
class AutomobileRecord < ActiveRecord::Base
|
7
|
+
class << self
|
8
|
+
def n
|
9
|
+
new :make => AutomobileMake.find_by_name('Nissan')
|
10
|
+
end
|
11
|
+
|
12
|
+
def add_implicit_characteristics
|
13
|
+
decisions[:emission].committees.map(&:name).reject { |c| characteristics.keys.unshift(:emission).include? c }.each do |c|
|
14
|
+
characterize { has c }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
include BrighterPlanet::Automobile
|
20
|
+
include Sniff::Emitter
|
21
|
+
|
22
|
+
belongs_to :variant, :class_name => 'AutomobileVariant'
|
23
|
+
belongs_to :make, :class_name => 'AutomobileMake'
|
24
|
+
belongs_to :model, :class_name => 'AutomobileModel'
|
25
|
+
belongs_to :model_year, :class_name => 'AutomobileModelYear'
|
26
|
+
belongs_to :fuel_type, :class_name => 'AutomobileFuelType'
|
27
|
+
belongs_to :size_class, :class_name => 'AutomobileSizeClass'
|
28
|
+
|
29
|
+
falls_back_on :fuel_efficiency => 20.182.miles_per_gallon.to(:kilometres_per_litre), # mpg https://brighterplanet.sifterapp.com/projects/30/issues/428
|
30
|
+
:urbanity => 0.43, # EPA via Ian https://brighterplanet.sifterapp.com/projects/30/issues/428
|
31
|
+
:annual_distance_estimate => 11819.miles.to(:kilometres) # miles https://brighterplanet.sifterapp.com/projects/30/issues/428
|
32
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'sniff/database'
|
2
|
+
|
3
|
+
Sniff::Database.define_schema do
|
4
|
+
create_table "automobile_records", :force => true do |t|
|
5
|
+
t.datetime "created_at"
|
6
|
+
t.datetime "updated_at"
|
7
|
+
t.date "date"
|
8
|
+
t.float "fuel_efficiency"
|
9
|
+
t.float "urbanity"
|
10
|
+
t.float "annual_distance_estimate"
|
11
|
+
t.float "weekly_distance_estimate"
|
12
|
+
t.float "daily_distance_estimate"
|
13
|
+
t.float "daily_duration"
|
14
|
+
t.date "acquisition"
|
15
|
+
t.boolean "hybridity"
|
16
|
+
t.date "retirement"
|
17
|
+
t.string "make_id"
|
18
|
+
t.string "model_id"
|
19
|
+
t.string "model_year_id"
|
20
|
+
t.string "variant_id"
|
21
|
+
t.string "size_class_id"
|
22
|
+
t.string "fuel_type_id"
|
23
|
+
end
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,228 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: automobile-ruby19
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 5
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 13
|
10
|
+
version: 0.0.13
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Andy Rossmeissl
|
14
|
+
- Seamus Abshere
|
15
|
+
- Ian Hough
|
16
|
+
- Matt Kling
|
17
|
+
- Derek Kastner
|
18
|
+
autorequire:
|
19
|
+
bindir: bin
|
20
|
+
cert_chain: []
|
21
|
+
|
22
|
+
date: 2010-09-21 00:00:00 -05:00
|
23
|
+
default_executable:
|
24
|
+
dependencies:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: activerecord
|
27
|
+
prerelease: false
|
28
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
hash: 7
|
34
|
+
segments:
|
35
|
+
- 3
|
36
|
+
- 0
|
37
|
+
- 0
|
38
|
+
version: 3.0.0
|
39
|
+
type: :development
|
40
|
+
version_requirements: *id001
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
prerelease: false
|
44
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ~>
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
hash: 23
|
50
|
+
segments:
|
51
|
+
- 1
|
52
|
+
- 0
|
53
|
+
- 0
|
54
|
+
version: 1.0.0
|
55
|
+
type: :development
|
56
|
+
version_requirements: *id002
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: cucumber
|
59
|
+
prerelease: false
|
60
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ~>
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
hash: 57
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
- 8
|
69
|
+
- 3
|
70
|
+
version: 0.8.3
|
71
|
+
type: :development
|
72
|
+
version_requirements: *id003
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: jeweler
|
75
|
+
prerelease: false
|
76
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ~>
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
hash: 7
|
82
|
+
segments:
|
83
|
+
- 1
|
84
|
+
- 4
|
85
|
+
- 0
|
86
|
+
version: 1.4.0
|
87
|
+
type: :development
|
88
|
+
version_requirements: *id004
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rake
|
91
|
+
prerelease: false
|
92
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
hash: 3
|
98
|
+
segments:
|
99
|
+
- 0
|
100
|
+
version: "0"
|
101
|
+
type: :development
|
102
|
+
version_requirements: *id005
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: rdoc
|
105
|
+
prerelease: false
|
106
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
107
|
+
none: false
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
hash: 3
|
112
|
+
segments:
|
113
|
+
- 0
|
114
|
+
version: "0"
|
115
|
+
type: :development
|
116
|
+
version_requirements: *id006
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: rspec
|
119
|
+
prerelease: false
|
120
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
hash: 62196417
|
126
|
+
segments:
|
127
|
+
- 2
|
128
|
+
- 0
|
129
|
+
- 0
|
130
|
+
- beta
|
131
|
+
- 17
|
132
|
+
version: 2.0.0.beta.17
|
133
|
+
type: :development
|
134
|
+
version_requirements: *id007
|
135
|
+
- !ruby/object:Gem::Dependency
|
136
|
+
name: sniff
|
137
|
+
prerelease: false
|
138
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
140
|
+
requirements:
|
141
|
+
- - ~>
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
hash: 57
|
144
|
+
segments:
|
145
|
+
- 0
|
146
|
+
- 1
|
147
|
+
- 17
|
148
|
+
version: 0.1.17
|
149
|
+
type: :development
|
150
|
+
version_requirements: *id008
|
151
|
+
- !ruby/object:Gem::Dependency
|
152
|
+
name: emitter-ruby19
|
153
|
+
prerelease: false
|
154
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
155
|
+
none: false
|
156
|
+
requirements:
|
157
|
+
- - ~>
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
hash: 19
|
160
|
+
segments:
|
161
|
+
- 0
|
162
|
+
- 1
|
163
|
+
- 4
|
164
|
+
version: 0.1.4
|
165
|
+
type: :runtime
|
166
|
+
version_requirements: *id009
|
167
|
+
description: A software model in Ruby for the greenhouse gas emissions of an automobile
|
168
|
+
email: andy@rossmeissl.net
|
169
|
+
executables: []
|
170
|
+
|
171
|
+
extensions: []
|
172
|
+
|
173
|
+
extra_rdoc_files:
|
174
|
+
- LICENSE
|
175
|
+
- README.rdoc
|
176
|
+
files:
|
177
|
+
- LICENSE
|
178
|
+
- README.rdoc
|
179
|
+
- lib/automobile.rb
|
180
|
+
- lib/automobile/carbon_model.rb
|
181
|
+
- lib/automobile/characterization.rb
|
182
|
+
- lib/automobile/data.rb
|
183
|
+
- lib/automobile/summarization.rb
|
184
|
+
- lib/test_support/automobile_record.rb
|
185
|
+
- lib/test_support/db/schema.rb
|
186
|
+
- features/support/env.rb
|
187
|
+
- features/automobile_committees.feature
|
188
|
+
- features/automobile_emissions.feature
|
189
|
+
has_rdoc: true
|
190
|
+
homepage: http://github.com/brighterplanet/automobile
|
191
|
+
licenses: []
|
192
|
+
|
193
|
+
post_install_message:
|
194
|
+
rdoc_options:
|
195
|
+
- --charset=UTF-8
|
196
|
+
require_paths:
|
197
|
+
- lib
|
198
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
199
|
+
none: false
|
200
|
+
requirements:
|
201
|
+
- - ">="
|
202
|
+
- !ruby/object:Gem::Version
|
203
|
+
hash: 3
|
204
|
+
segments:
|
205
|
+
- 0
|
206
|
+
version: "0"
|
207
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
208
|
+
none: false
|
209
|
+
requirements:
|
210
|
+
- - ">="
|
211
|
+
- !ruby/object:Gem::Version
|
212
|
+
hash: 3
|
213
|
+
segments:
|
214
|
+
- 0
|
215
|
+
version: "0"
|
216
|
+
requirements: []
|
217
|
+
|
218
|
+
rubyforge_project:
|
219
|
+
rubygems_version: 1.3.7
|
220
|
+
signing_key:
|
221
|
+
specification_version: 3
|
222
|
+
summary: A carbon model
|
223
|
+
test_files:
|
224
|
+
- features/support/env.rb
|
225
|
+
- features/automobile_committees.feature
|
226
|
+
- features/automobile_emissions.feature
|
227
|
+
- lib/test_support/automobile_record.rb
|
228
|
+
- lib/test_support/db/schema.rb
|