automobile_trip 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +20 -20
- data/README.rdoc +17 -17
- data/features/automobile_trip_committees.feature +27 -0
- data/features/automobile_trip_emissions.feature +19 -3
- data/features/support/env.rb +1 -1
- data/lib/automobile_trip/carbon_model.rb +23 -6
- data/lib/automobile_trip/characterization.rb +2 -4
- data/lib/automobile_trip/data.rb +2 -2
- data/lib/automobile_trip/summarization.rb +0 -3
- data/lib/test_support/automobile_trip_record.rb +14 -0
- data/lib/test_support/db/schema.rb +9 -0
- metadata +84 -57
data/LICENSE
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
Copyright (c) 2009 Andy Rossmeissl
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright (c) 2009 Andy Rossmeissl
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
= automobile_trip
|
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 Andy Rossmeissl. See LICENSE for details.
|
1
|
+
= automobile_trip
|
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 Andy Rossmeissl. See LICENSE for details.
|
@@ -1,2 +1,29 @@
|
|
1
1
|
Feature: Automobile Trip Committee Calculations
|
2
2
|
The automobile trip model should generate correct committee calculations
|
3
|
+
|
4
|
+
Scenario: Fuel Use committee from default
|
5
|
+
Given an automobile_trip emitter
|
6
|
+
When the "fuel_use" committee is calculated
|
7
|
+
Then the committee should have used quorum "default"
|
8
|
+
And the conclusion of the committee should be "57.0"
|
9
|
+
|
10
|
+
Scenario: Emission factor committee from fuel type
|
11
|
+
Given an automobile_trip emitter
|
12
|
+
And a characteristic "fuel_type.name" of "Gasoline"
|
13
|
+
And the "emission_factor" committee is calculated
|
14
|
+
Then the committee should have used quorum "from fuel type"
|
15
|
+
And the conclusion of the committee should be "10.0"
|
16
|
+
|
17
|
+
Scenario: Emission factor committee from default
|
18
|
+
Given an automobile_trip emitter
|
19
|
+
When the "emission_factor" committee is calculated
|
20
|
+
Then the committee should have used quorum "default"
|
21
|
+
And the conclusion of the committee should be "2.46315"
|
22
|
+
|
23
|
+
Scenario: Emission committee from fuel use and emission factor
|
24
|
+
Given an automobile_trip emitter
|
25
|
+
And a characteristic "fuel_use" of "100"
|
26
|
+
And a characteristic "emission_factor" of "1.5"
|
27
|
+
When the "emission" committee is calculated
|
28
|
+
Then the committee should have used quorum "from fuel use and emission factor"
|
29
|
+
And the conclusion of the committee should be "150"
|
@@ -1,7 +1,23 @@
|
|
1
1
|
Feature: Automobile Trip Emissions Calculations
|
2
2
|
The automobile trip model should generate correct emission calculations
|
3
3
|
|
4
|
-
Scenario:
|
5
|
-
Given an
|
4
|
+
Scenario: Calculations starting from nothing
|
5
|
+
Given an automobile_trip has nothing
|
6
6
|
When emissions are calculated
|
7
|
-
Then the emission value should be 1
|
7
|
+
Then the emission value should be within "0.1" kgs of "140.4"
|
8
|
+
|
9
|
+
Scenario: Calculations starting from fuel use
|
10
|
+
Given an automobile_trip has "fuel_use" of "100"
|
11
|
+
When emissions are calculated
|
12
|
+
Then the emission value should be within "0.1" kgs of "246.3"
|
13
|
+
|
14
|
+
Scenario: Calculations starting from fuel type
|
15
|
+
Given an automobile_trip has "fuel_type.name" of "Gasoline"
|
16
|
+
When emissions are calculated
|
17
|
+
Then the emission value should be within "0.1" kgs of "570.0"
|
18
|
+
|
19
|
+
Scenario: Calculations starting from fuel use and fuel type
|
20
|
+
Given an automobile_trip has "fuel_type.name" of "Gasoline"
|
21
|
+
And it has "fuel_use" of "100"
|
22
|
+
When emissions are calculated
|
23
|
+
Then the emission value should be within "0.1" kgs of "1000.0"
|
data/features/support/env.rb
CHANGED
@@ -1,15 +1,32 @@
|
|
1
|
-
require 'leap'
|
2
|
-
require 'conversions'
|
3
1
|
|
4
2
|
module BrighterPlanet
|
5
3
|
module AutomobileTrip
|
6
4
|
module CarbonModel
|
7
5
|
def self.included(base)
|
8
|
-
base.extend ::Leap::Subject
|
9
6
|
base.decide :emission, :with => :characteristics do
|
10
|
-
committee :emission do
|
11
|
-
quorum 'from fuel
|
12
|
-
|
7
|
+
committee :emission do # returns kg CO2e
|
8
|
+
quorum 'from fuel use and emission factor', :needs => [:fuel_use, :emission_factor] do |characteristics|
|
9
|
+
characteristics[:fuel_use] * characteristics[:emission_factor]
|
10
|
+
end
|
11
|
+
|
12
|
+
quorum 'default' do
|
13
|
+
raise "The emission committee's default quorum should never be called"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
committee :emission_factor do # returns lbs CO2e / l
|
18
|
+
quorum 'from fuel type', :needs => :fuel_type do |characteristics|
|
19
|
+
characteristics[:fuel_type].emission_factor
|
20
|
+
end
|
21
|
+
|
22
|
+
quorum 'default' do
|
23
|
+
base.fallback.emission_factor
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
committee :fuel_use do # returns l
|
28
|
+
quorum 'default' do
|
29
|
+
base.fallback.fuel_use
|
13
30
|
end
|
14
31
|
end
|
15
32
|
end
|
@@ -1,13 +1,11 @@
|
|
1
|
-
require 'characterizable'
|
2
|
-
|
3
1
|
module BrighterPlanet
|
4
2
|
module AutomobileTrip
|
5
3
|
module Characterization
|
6
4
|
def self.included(base)
|
7
|
-
base.send :include, Characterizable
|
8
5
|
base.characterize do
|
6
|
+
has :fuel_use
|
7
|
+
has :fuel_type
|
9
8
|
end
|
10
|
-
base.add_implicit_characteristics
|
11
9
|
end
|
12
10
|
end
|
13
11
|
end
|
data/lib/automobile_trip/data.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'active_record'
|
2
|
+
require 'falls_back_on'
|
3
|
+
require 'automobile_trip'
|
4
|
+
require 'sniff'
|
5
|
+
|
6
|
+
class AutomobileTripRecord < ActiveRecord::Base
|
7
|
+
include Sniff::Emitter
|
8
|
+
include BrighterPlanet::AutomobileTrip
|
9
|
+
|
10
|
+
belongs_to :fuel_type, :foreign_key => 'fuel_type_name'
|
11
|
+
|
12
|
+
falls_back_on :emission_factor => 20.556.pounds_per_gallon.to(:kilograms_per_litre), # from footprint model gasoline car CO2e / gallon
|
13
|
+
:fuel_use => 57.0 # based on wikianswers average tank size of 15 gallons
|
14
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: automobile_trip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 21
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Andy Rossmeissl
|
@@ -18,99 +19,111 @@ autorequire:
|
|
18
19
|
bindir: bin
|
19
20
|
cert_chain: []
|
20
21
|
|
21
|
-
date: 2010-09-
|
22
|
+
date: 2010-09-22 00:00:00 -04:00
|
22
23
|
default_executable:
|
23
24
|
dependencies:
|
24
25
|
- !ruby/object:Gem::Dependency
|
25
|
-
|
26
|
+
type: :development
|
26
27
|
prerelease: false
|
27
|
-
|
28
|
+
name: activerecord
|
29
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
28
31
|
requirements:
|
29
|
-
- -
|
32
|
+
- - ~>
|
30
33
|
- !ruby/object:Gem::Version
|
34
|
+
hash: 7
|
31
35
|
segments:
|
32
36
|
- 3
|
33
37
|
- 0
|
34
38
|
- 0
|
35
|
-
|
36
|
-
|
37
|
-
type: :development
|
38
|
-
version_requirements: *id001
|
39
|
+
version: 3.0.0
|
40
|
+
requirement: *id001
|
39
41
|
- !ruby/object:Gem::Dependency
|
40
|
-
|
42
|
+
type: :development
|
41
43
|
prerelease: false
|
42
|
-
|
44
|
+
name: bundler
|
45
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
43
47
|
requirements:
|
44
|
-
- -
|
48
|
+
- - ~>
|
45
49
|
- !ruby/object:Gem::Version
|
50
|
+
hash: 23
|
46
51
|
segments:
|
47
52
|
- 1
|
48
53
|
- 0
|
49
54
|
- 0
|
50
|
-
|
51
|
-
|
52
|
-
version: 1.0.0.beta.2
|
53
|
-
type: :development
|
54
|
-
version_requirements: *id002
|
55
|
+
version: 1.0.0
|
56
|
+
requirement: *id002
|
55
57
|
- !ruby/object:Gem::Dependency
|
56
|
-
|
58
|
+
type: :development
|
57
59
|
prerelease: false
|
58
|
-
|
60
|
+
name: cucumber
|
61
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
59
63
|
requirements:
|
60
|
-
- -
|
64
|
+
- - ~>
|
61
65
|
- !ruby/object:Gem::Version
|
66
|
+
hash: 57
|
62
67
|
segments:
|
63
68
|
- 0
|
64
69
|
- 8
|
65
70
|
- 3
|
66
71
|
version: 0.8.3
|
67
|
-
|
68
|
-
version_requirements: *id003
|
72
|
+
requirement: *id003
|
69
73
|
- !ruby/object:Gem::Dependency
|
70
|
-
|
74
|
+
type: :development
|
71
75
|
prerelease: false
|
72
|
-
|
76
|
+
name: jeweler
|
77
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
73
79
|
requirements:
|
74
|
-
- -
|
80
|
+
- - ~>
|
75
81
|
- !ruby/object:Gem::Version
|
82
|
+
hash: 7
|
76
83
|
segments:
|
77
84
|
- 1
|
78
85
|
- 4
|
79
86
|
- 0
|
80
87
|
version: 1.4.0
|
81
|
-
|
82
|
-
version_requirements: *id004
|
88
|
+
requirement: *id004
|
83
89
|
- !ruby/object:Gem::Dependency
|
84
|
-
|
90
|
+
type: :development
|
85
91
|
prerelease: false
|
86
|
-
|
92
|
+
name: rake
|
93
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
87
95
|
requirements:
|
88
96
|
- - ">="
|
89
97
|
- !ruby/object:Gem::Version
|
98
|
+
hash: 3
|
90
99
|
segments:
|
91
100
|
- 0
|
92
101
|
version: "0"
|
93
|
-
|
94
|
-
version_requirements: *id005
|
102
|
+
requirement: *id005
|
95
103
|
- !ruby/object:Gem::Dependency
|
96
|
-
|
104
|
+
type: :development
|
97
105
|
prerelease: false
|
98
|
-
|
106
|
+
name: rdoc
|
107
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
99
109
|
requirements:
|
100
110
|
- - ">="
|
101
111
|
- !ruby/object:Gem::Version
|
112
|
+
hash: 3
|
102
113
|
segments:
|
103
114
|
- 0
|
104
115
|
version: "0"
|
105
|
-
|
106
|
-
version_requirements: *id006
|
116
|
+
requirement: *id006
|
107
117
|
- !ruby/object:Gem::Dependency
|
108
|
-
|
118
|
+
type: :development
|
109
119
|
prerelease: false
|
110
|
-
|
120
|
+
name: rspec
|
121
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
111
123
|
requirements:
|
112
|
-
- -
|
124
|
+
- - ~>
|
113
125
|
- !ruby/object:Gem::Version
|
126
|
+
hash: 62196417
|
114
127
|
segments:
|
115
128
|
- 2
|
116
129
|
- 0
|
@@ -118,36 +131,39 @@ dependencies:
|
|
118
131
|
- beta
|
119
132
|
- 17
|
120
133
|
version: 2.0.0.beta.17
|
121
|
-
|
122
|
-
version_requirements: *id007
|
134
|
+
requirement: *id007
|
123
135
|
- !ruby/object:Gem::Dependency
|
124
|
-
|
136
|
+
type: :development
|
125
137
|
prerelease: false
|
126
|
-
|
138
|
+
name: sniff
|
139
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
127
141
|
requirements:
|
128
|
-
- -
|
142
|
+
- - ~>
|
129
143
|
- !ruby/object:Gem::Version
|
144
|
+
hash: 3
|
130
145
|
segments:
|
131
146
|
- 0
|
132
|
-
-
|
133
|
-
-
|
134
|
-
version: 0.
|
135
|
-
|
136
|
-
version_requirements: *id008
|
147
|
+
- 1
|
148
|
+
- 12
|
149
|
+
version: 0.1.12
|
150
|
+
requirement: *id008
|
137
151
|
- !ruby/object:Gem::Dependency
|
138
|
-
|
152
|
+
type: :runtime
|
139
153
|
prerelease: false
|
140
|
-
|
154
|
+
name: emitter
|
155
|
+
version_requirements: &id009 !ruby/object:Gem::Requirement
|
156
|
+
none: false
|
141
157
|
requirements:
|
142
|
-
- -
|
158
|
+
- - ~>
|
143
159
|
- !ruby/object:Gem::Version
|
160
|
+
hash: 19
|
144
161
|
segments:
|
145
162
|
- 0
|
146
|
-
- 0
|
147
163
|
- 1
|
148
|
-
|
149
|
-
|
150
|
-
|
164
|
+
- 4
|
165
|
+
version: 0.1.4
|
166
|
+
requirement: *id009
|
151
167
|
description: A software model in Ruby for the greenhouse gas emissions of an automobile trip
|
152
168
|
email: andy@rossmeissl.net
|
153
169
|
executables: []
|
@@ -166,6 +182,11 @@ files:
|
|
166
182
|
- lib/automobile_trip/committee_structure.rb
|
167
183
|
- lib/automobile_trip/data.rb
|
168
184
|
- lib/automobile_trip/summarization.rb
|
185
|
+
- lib/test_support/automobile_trip_record.rb
|
186
|
+
- lib/test_support/db/schema.rb
|
187
|
+
- features/support/env.rb
|
188
|
+
- features/automobile_trip_committees.feature
|
189
|
+
- features/automobile_trip_emissions.feature
|
169
190
|
has_rdoc: true
|
170
191
|
homepage: http://github.com/brighterplanet/automobile_trip
|
171
192
|
licenses: []
|
@@ -176,23 +197,27 @@ rdoc_options:
|
|
176
197
|
require_paths:
|
177
198
|
- lib
|
178
199
|
required_ruby_version: !ruby/object:Gem::Requirement
|
200
|
+
none: false
|
179
201
|
requirements:
|
180
202
|
- - ">="
|
181
203
|
- !ruby/object:Gem::Version
|
204
|
+
hash: 3
|
182
205
|
segments:
|
183
206
|
- 0
|
184
207
|
version: "0"
|
185
208
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
209
|
+
none: false
|
186
210
|
requirements:
|
187
211
|
- - ">="
|
188
212
|
- !ruby/object:Gem::Version
|
213
|
+
hash: 3
|
189
214
|
segments:
|
190
215
|
- 0
|
191
216
|
version: "0"
|
192
217
|
requirements: []
|
193
218
|
|
194
219
|
rubyforge_project:
|
195
|
-
rubygems_version: 1.3.
|
220
|
+
rubygems_version: 1.3.7
|
196
221
|
signing_key:
|
197
222
|
specification_version: 3
|
198
223
|
summary: A carbon model
|
@@ -200,3 +225,5 @@ test_files:
|
|
200
225
|
- features/support/env.rb
|
201
226
|
- features/automobile_trip_committees.feature
|
202
227
|
- features/automobile_trip_emissions.feature
|
228
|
+
- lib/test_support/automobile_trip_record.rb
|
229
|
+
- lib/test_support/db/schema.rb
|