bus_trip 0.0.8 → 0.0.9
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.
@@ -1,8 +1,8 @@
|
|
1
1
|
Feature: Bus Trip Committee Calculations
|
2
2
|
The bus trip model should generate correct committee calculations
|
3
3
|
|
4
|
-
Scenario Outline:
|
5
|
-
Given a bus trip has "
|
4
|
+
Scenario Outline: Distance from duration, distance estimate, and bus class
|
5
|
+
Given a bus trip has "distance_estimate" of "<distance_estimate>"
|
6
6
|
And it used "duration" "<duration>"
|
7
7
|
And it used "bus_class.name" "<bus_class>"
|
8
8
|
When emissions are calculated
|
@@ -10,6 +10,19 @@ Feature: Bus Trip Committee Calculations
|
|
10
10
|
Examples:
|
11
11
|
| duration | distance_estimate | bus_class | distance |
|
12
12
|
| 40 | | | 21 |
|
13
|
-
| | 60 | |
|
13
|
+
| | 60 | | 60 |
|
14
14
|
| | | regional coach | 21 |
|
15
15
|
| | | city transit | 8 |
|
16
|
+
|
17
|
+
Scenario Outline: Diesel consumed from distance and diesel intensity
|
18
|
+
Given a bus trip has "distance_estimate" of "<distance_estimate>"
|
19
|
+
And it used "duration" "<duration>"
|
20
|
+
And it used "bus_class.name" "<bus_class>"
|
21
|
+
When emissions are calculated
|
22
|
+
Then the diesel_consumed committee should be close to <diesel_consumed>, +/-0.1
|
23
|
+
Examples:
|
24
|
+
| duration | distance_estimate | bus_class | diesel_consumed |
|
25
|
+
| 40 | | | 7.0 |
|
26
|
+
| | 60 | | 20.1 |
|
27
|
+
| | | regional coach | 5.0 |
|
28
|
+
| | | city transit | 3.0 |
|
@@ -1,13 +1,33 @@
|
|
1
1
|
Feature: Bus Trip Emissions Calculations
|
2
2
|
The bus trip model should generate correct emission calculations
|
3
3
|
|
4
|
-
Scenario Outline:
|
5
|
-
Given a bus trip has "
|
4
|
+
Scenario Outline: Calculations for bus trips with just timeframe and distance
|
5
|
+
Given a bus trip has "distance_estimate" of "<distance>"
|
6
|
+
And it has "timeframe" of "<timeframe>"
|
7
|
+
When emissions are calculated
|
8
|
+
Then the emission value should be within 0.1 kgs of <emission>
|
9
|
+
Examples:
|
10
|
+
| timeframe | distance | emission |
|
11
|
+
| 2010-08-01/2010-08-01 | 10 | 1.2 |
|
12
|
+
| 2010-08-01/2010-08-11 | 400 | 51.0 |
|
13
|
+
|
14
|
+
Scenario Outline: Standard Calculations for bus trips with timeframe and bus class
|
15
|
+
Given a bus trip has "distance_estimate" of "<distance>"
|
16
|
+
And it has "bus_class.name" "<bus_class>"
|
17
|
+
And it has "timeframe" of "<timeframe>"
|
18
|
+
When emissions are calculated
|
19
|
+
Then the emission value should be within 0.1 kgs of <emission>
|
20
|
+
Examples:
|
21
|
+
| timeframe | distance | bus_class | emission |
|
22
|
+
| 2010-08-01/2010-08-01 | 10 | city transit | 3.4 |
|
23
|
+
| 2010-08-01/2010-08-11 | 400 | regional coach | 51.4 |
|
24
|
+
|
25
|
+
Scenario Outline: Calculations involving fuel types
|
26
|
+
Given a bus trip has "distance_estimate" of "<distance>"
|
6
27
|
And it used "bus_class.gasoline_intensity" "<gasoline>"
|
7
28
|
And it used "bus_class.diesel_intensity" "<diesel>"
|
8
29
|
And it used "bus_class.alternative_fuels_intensity" "<alternative>"
|
9
30
|
And it has "bus_class.passengers" "<passengers>"
|
10
|
-
And it has "distance_estimate" of "<distance>"
|
11
31
|
And it has "bus_class.name" "<bus_class>"
|
12
32
|
When emissions are calculated
|
13
33
|
Then the emission value should be within 0.1 kgs of <emission>
|
data/features/support/env.rb
CHANGED
@@ -10,7 +10,7 @@ module BrighterPlanet
|
|
10
10
|
committee :emission do # returns kg CO2
|
11
11
|
quorum 'from fuel and passengers', :needs => [:diesel_consumed, :gasoline_consumed, :alternative_fuels_consumed, :passengers, :distance, :bus_class] do |characteristics|
|
12
12
|
#(( litres diesel ) * ( kilograms CO2 / litre diesel ) + ( litres gasoline ) * ( kilograms CO2 / kWh ) + ( litre-equivs alternative fuel ) * (kilograms CO2 / litre-equiv alternative fuel))
|
13
|
-
(characteristics[:diesel_consumed] *
|
13
|
+
(characteristics[:diesel_consumed] * research(:diesel_emission_factor) + characteristics[:gasoline_consumed] * research(:gasoline_emission_factor) + characteristics[:alternative_fuels_consumed] * research(:alternative_fuels_emission_factor) + characteristics[:distance] * characteristics[:bus_class].fugitive_air_conditioning_emission) / characteristics[:passengers]
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -87,6 +87,17 @@ module BrighterPlanet
|
|
87
87
|
end
|
88
88
|
end
|
89
89
|
end
|
90
|
+
|
91
|
+
def self.research(key)
|
92
|
+
case key
|
93
|
+
when :diesel_emission_factor
|
94
|
+
22.450.pounds_per_gallon.to(:kilograms_per_litre) # CO2 / diesel https://brighterplanet.sifterapp.com/projects/30/issues/454
|
95
|
+
when :gasoline_emission_factor
|
96
|
+
23.681.pounds_per_gallon.to(:kilograms_per_litre) # CO2 / gasoline https://brighterplanet.sifterapp.com/projects/30/issues/454
|
97
|
+
when :alternative_fuels_emission_factor
|
98
|
+
9.742.pounds_per_gallon.to(:kilograms_per_litre) # CO2 / equiv alternative fuels https://brighterplanet.sifterapp.com/projects/30/issues/454
|
99
|
+
end
|
100
|
+
end
|
90
101
|
end
|
91
102
|
end
|
92
103
|
end
|
@@ -9,20 +9,8 @@ class BusTripRecord < ActiveRecord::Base
|
|
9
9
|
|
10
10
|
falls_back_on
|
11
11
|
|
12
|
-
class << self
|
13
|
-
def research(key)
|
14
|
-
case key
|
15
|
-
when :diesel_emission_factor
|
16
|
-
22.450.pounds_per_gallon.to(:kilograms_per_litre) # CO2 / diesel https://brighterplanet.sifterapp.com/projects/30/issues/454
|
17
|
-
when :gasoline_emission_factor
|
18
|
-
23.681.pounds_per_gallon.to(:kilograms_per_litre) # CO2 / gasoline https://brighterplanet.sifterapp.com/projects/30/issues/454
|
19
|
-
when :alternative_fuels_emission_factor
|
20
|
-
9.742.pounds_per_gallon.to(:kilograms_per_litre) # CO2 / equiv alternative fuels https://brighterplanet.sifterapp.com/projects/30/issues/454
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
12
|
def emission_date
|
26
13
|
created_at.to_date #FIXME we should add a date characteristic for this emitter
|
27
14
|
end
|
28
15
|
end
|
16
|
+
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bus_trip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 9
|
10
|
+
version: 0.0.9
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andy Rossmeissl
|
@@ -19,48 +19,45 @@ autorequire:
|
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
21
|
|
22
|
-
date: 2010-
|
22
|
+
date: 2010-09-02 00:00:00 -04:00
|
23
23
|
default_executable:
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
|
26
|
+
type: :development
|
27
27
|
prerelease: false
|
28
|
-
|
28
|
+
name: activerecord
|
29
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
29
30
|
none: false
|
30
31
|
requirements:
|
31
|
-
- -
|
32
|
+
- - ~>
|
32
33
|
- !ruby/object:Gem::Version
|
33
|
-
hash:
|
34
|
+
hash: 7
|
34
35
|
segments:
|
35
36
|
- 3
|
36
37
|
- 0
|
37
38
|
- 0
|
38
|
-
|
39
|
-
|
40
|
-
type: :development
|
41
|
-
version_requirements: *id001
|
39
|
+
version: 3.0.0
|
40
|
+
requirement: *id001
|
42
41
|
- !ruby/object:Gem::Dependency
|
43
|
-
|
42
|
+
type: :development
|
44
43
|
prerelease: false
|
45
|
-
|
44
|
+
name: bundler
|
45
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
46
46
|
none: false
|
47
47
|
requirements:
|
48
|
-
- -
|
48
|
+
- - ~>
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
hash:
|
50
|
+
hash: 15
|
51
51
|
segments:
|
52
52
|
- 1
|
53
53
|
- 0
|
54
|
-
|
55
|
-
|
56
|
-
- 2
|
57
|
-
version: 1.0.0.beta.2
|
58
|
-
type: :development
|
59
|
-
version_requirements: *id002
|
54
|
+
version: "1.0"
|
55
|
+
requirement: *id002
|
60
56
|
- !ruby/object:Gem::Dependency
|
61
|
-
|
57
|
+
type: :development
|
62
58
|
prerelease: false
|
63
|
-
|
59
|
+
name: cucumber
|
60
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
64
61
|
none: false
|
65
62
|
requirements:
|
66
63
|
- - "="
|
@@ -71,12 +68,12 @@ dependencies:
|
|
71
68
|
- 8
|
72
69
|
- 3
|
73
70
|
version: 0.8.3
|
74
|
-
|
75
|
-
version_requirements: *id003
|
71
|
+
requirement: *id003
|
76
72
|
- !ruby/object:Gem::Dependency
|
77
|
-
|
73
|
+
type: :development
|
78
74
|
prerelease: false
|
79
|
-
|
75
|
+
name: jeweler
|
76
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
80
77
|
none: false
|
81
78
|
requirements:
|
82
79
|
- - "="
|
@@ -87,12 +84,12 @@ dependencies:
|
|
87
84
|
- 4
|
88
85
|
- 0
|
89
86
|
version: 1.4.0
|
90
|
-
|
91
|
-
version_requirements: *id004
|
87
|
+
requirement: *id004
|
92
88
|
- !ruby/object:Gem::Dependency
|
93
|
-
|
89
|
+
type: :development
|
94
90
|
prerelease: false
|
95
|
-
|
91
|
+
name: rake
|
92
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
96
93
|
none: false
|
97
94
|
requirements:
|
98
95
|
- - ">="
|
@@ -101,12 +98,12 @@ dependencies:
|
|
101
98
|
segments:
|
102
99
|
- 0
|
103
100
|
version: "0"
|
104
|
-
|
105
|
-
version_requirements: *id005
|
101
|
+
requirement: *id005
|
106
102
|
- !ruby/object:Gem::Dependency
|
107
|
-
|
103
|
+
type: :development
|
108
104
|
prerelease: false
|
109
|
-
|
105
|
+
name: rdoc
|
106
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
110
107
|
none: false
|
111
108
|
requirements:
|
112
109
|
- - ">="
|
@@ -115,12 +112,12 @@ dependencies:
|
|
115
112
|
segments:
|
116
113
|
- 0
|
117
114
|
version: "0"
|
118
|
-
|
119
|
-
version_requirements: *id006
|
115
|
+
requirement: *id006
|
120
116
|
- !ruby/object:Gem::Dependency
|
121
|
-
|
117
|
+
type: :development
|
122
118
|
prerelease: false
|
123
|
-
|
119
|
+
name: rspec
|
120
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
124
121
|
none: false
|
125
122
|
requirements:
|
126
123
|
- - "="
|
@@ -133,40 +130,39 @@ dependencies:
|
|
133
130
|
- beta
|
134
131
|
- 17
|
135
132
|
version: 2.0.0.beta.17
|
136
|
-
|
137
|
-
version_requirements: *id007
|
133
|
+
requirement: *id007
|
138
134
|
- !ruby/object:Gem::Dependency
|
139
|
-
|
135
|
+
type: :development
|
140
136
|
prerelease: false
|
141
|
-
|
137
|
+
name: sniff
|
138
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
142
139
|
none: false
|
143
140
|
requirements:
|
144
|
-
- -
|
141
|
+
- - ~>
|
145
142
|
- !ruby/object:Gem::Version
|
146
|
-
hash:
|
143
|
+
hash: 15
|
147
144
|
segments:
|
148
145
|
- 0
|
149
|
-
-
|
146
|
+
- 1
|
150
147
|
- 10
|
151
|
-
version: 0.
|
152
|
-
|
153
|
-
version_requirements: *id008
|
148
|
+
version: 0.1.10
|
149
|
+
requirement: *id008
|
154
150
|
- !ruby/object:Gem::Dependency
|
155
|
-
|
151
|
+
type: :runtime
|
156
152
|
prerelease: false
|
157
|
-
|
153
|
+
name: emitter
|
154
|
+
version_requirements: &id009 !ruby/object:Gem::Requirement
|
158
155
|
none: false
|
159
156
|
requirements:
|
160
|
-
- -
|
157
|
+
- - ~>
|
161
158
|
- !ruby/object:Gem::Version
|
162
|
-
hash:
|
159
|
+
hash: 13
|
163
160
|
segments:
|
164
161
|
- 0
|
165
162
|
- 0
|
166
|
-
-
|
167
|
-
version: 0.0.
|
168
|
-
|
169
|
-
version_requirements: *id009
|
163
|
+
- 9
|
164
|
+
version: 0.0.9
|
165
|
+
requirement: *id009
|
170
166
|
description: A software model in Ruby for the greenhouse gas emissions of a bus trip
|
171
167
|
email: andy@rossmeissl.net
|
172
168
|
executables: []
|