shipment 0.0.7 → 0.0.8
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-PREAMBLE +52 -0
- data/features/shipment_committees.feature +62 -101
- data/features/shipment_emissions.feature +41 -41
- data/features/step_definitions/shipment_steps.rb +11 -0
- data/lib/shipment/carbon_model.rb +10 -26
- data/lib/shipment/characterization.rb +1 -0
- data/lib/shipment/data.rb +1 -0
- metadata +9 -7
data/LICENSE-PREAMBLE
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
BRIGHTER PLANET ADDITIONAL PREAMBLE TO THE GNU AFFERO GENERAL PUBLIC LICENSE
|
2
|
+
January 7, 2011
|
3
|
+
|
4
|
+
This preamble is meant to help the licensee understand exactly what
|
5
|
+
software is being received under the license and set expectations as to
|
6
|
+
what is not covered.
|
7
|
+
|
8
|
+
IDENTITY OF THE SOFTWARE MODULE COVERED BY LICENSE:
|
9
|
+
|
10
|
+
This license covers the Brighter Planet carbon model referred to as
|
11
|
+
'Shipment,' officially distributed from
|
12
|
+
http://github.com/brighterplanet/shipment.
|
13
|
+
|
14
|
+
SCOPE OF THE SOFTWARE MODULE COVERED BY LICENSE:
|
15
|
+
|
16
|
+
The scope of the license includes only those files included in the
|
17
|
+
official Brighter Planet distribution package for the particular carbon
|
18
|
+
model identified above, including only the carbon model execution files,
|
19
|
+
reference data classes, input characterization, fallbacks, summarization
|
20
|
+
helpers, tests, and test fixtures.
|
21
|
+
|
22
|
+
WHAT IS NOT COVERED BY LICENSE:
|
23
|
+
|
24
|
+
This license does not extend to the following:
|
25
|
+
|
26
|
+
* Any element of any Brighter Planet website, including but not
|
27
|
+
limited the copyrights, trademarks, graphic design, text,
|
28
|
+
documentation, method of interaction with clients, runtime
|
29
|
+
environment, technical infrastructure, and software code associated
|
30
|
+
therewith;
|
31
|
+
|
32
|
+
* Any element of any Brighter Planet website user interface, including
|
33
|
+
but not limited to the copyrights, trademarks, graphic design, text,
|
34
|
+
documentation, method of interaction with clients, runtime
|
35
|
+
environment, technical infrastructure, and software code associated
|
36
|
+
therewith;
|
37
|
+
|
38
|
+
* Any element of other software modules licensed under any form of
|
39
|
+
license including but not limited to other forms of open source
|
40
|
+
license, commercial license, and the like;
|
41
|
+
|
42
|
+
* Any element of any Brighter Planet Carbon Middleware web service,
|
43
|
+
including but not limited to the copyrights, trademarks, graphic
|
44
|
+
design, text, documentation, method of interaction with clients,
|
45
|
+
runtime environment, technical infrastructure, and software code, is
|
46
|
+
not covered by the license; and
|
47
|
+
|
48
|
+
* Any aspect or use of http://carbon.brighterplanet.com.
|
49
|
+
|
50
|
+
If you have any questions, please contact licensing@brighterplanet.com
|
51
|
+
|
52
|
+
Copyright 2010, 2011 Brighter Planet, Inc.
|
@@ -1,46 +1,18 @@
|
|
1
1
|
Feature: Shipment Committee Calculations
|
2
2
|
The shipment model should generate correct committee calculations
|
3
3
|
|
4
|
-
Scenario:
|
4
|
+
Scenario: Weight from default
|
5
5
|
Given a shipment emitter
|
6
|
-
When the "
|
6
|
+
When the "weight" committee is calculated
|
7
7
|
Then the committee should have used quorum "default"
|
8
8
|
And the conclusion of the committee should be "3.4"
|
9
9
|
|
10
|
-
Scenario:
|
10
|
+
Scenario: Package count from default
|
11
11
|
Given a shipment emitter
|
12
|
-
|
13
|
-
When the "verified_weight" committee is calculated
|
14
|
-
Then the committee should have used quorum "default"
|
15
|
-
And the conclusion of the committee should be "3.4"
|
16
|
-
|
17
|
-
Scenario: Verified weight from valid weight
|
18
|
-
Given a shipment emitter
|
19
|
-
And a characteristic "weight" of "2.0"
|
20
|
-
When the "verified_weight" committee is calculated
|
21
|
-
Then the committee should have used quorum "from weight"
|
22
|
-
And the conclusion of the committee should be "2.0"
|
23
|
-
|
24
|
-
Scenario: Verified package count from nothing
|
25
|
-
Given a shipment emitter
|
26
|
-
When the "verified_package_count" committee is calculated
|
12
|
+
When the "package_count" committee is calculated
|
27
13
|
Then the committee should have used quorum "default"
|
28
14
|
And the conclusion of the committee should be "1"
|
29
15
|
|
30
|
-
Scenario: Verified package count from invalid package count
|
31
|
-
Given a shipment emitter
|
32
|
-
And a characteristic "package_count" of "0.0"
|
33
|
-
When the "verified_package_count" committee is calculated
|
34
|
-
Then the committee should have used quorum "default"
|
35
|
-
And the conclusion of the committee should be "1"
|
36
|
-
|
37
|
-
Scenario: Verified package count from valid package count
|
38
|
-
Given a shipment emitter
|
39
|
-
And a characteristic "package_count" of "2"
|
40
|
-
When the "verified_package_count" committee is calculated
|
41
|
-
Then the committee should have used quorum "from package count"
|
42
|
-
And the conclusion of the committee should be "2"
|
43
|
-
|
44
16
|
Scenario Outline: Origin from zip code
|
45
17
|
Given a shipment emitter
|
46
18
|
And a characteristic "origin_zip_code" of "<zip>"
|
@@ -54,27 +26,25 @@ Feature: Shipment Committee Calculations
|
|
54
26
|
|
55
27
|
Scenario Outline: Origin location from geocodeable origin
|
56
28
|
Given a shipment emitter
|
57
|
-
And a characteristic "origin" of "<origin>"
|
29
|
+
And a characteristic "origin" of address value "<origin>"
|
30
|
+
And the geocoder will encode the origin as "<geocode>"
|
58
31
|
When the "origin_location" committee is calculated
|
59
32
|
Then the committee should have used quorum "from origin"
|
60
33
|
And the conclusion of the committee should be "<location>"
|
61
34
|
Examples:
|
62
|
-
| origin
|
63
|
-
| 05753
|
64
|
-
| San Francisco, CA
|
65
|
-
|
|
66
|
-
| Canterbury, Kent, UK
|
35
|
+
| origin | geocode | location |
|
36
|
+
| 05753 | 43.9968185,-73.1491165 | 43.9968185,-73.1491165 |
|
37
|
+
| San Francisco, CA | 37.7749295,-122.4194155 | 37.7749295,-122.4194155 |
|
38
|
+
| 488 Haight Street, San Francisco, CA | 37.7722302,-122.4303328 | 37.7722302,-122.4303328 |
|
39
|
+
| Canterbury, Kent, UK | 51.2772689,1.0805173 | 51.2772689,1.0805173 |
|
67
40
|
|
68
|
-
Scenario
|
41
|
+
Scenario: Origin location from non-geocodeable origin
|
69
42
|
Given a shipment emitter
|
70
|
-
And a characteristic "origin" of "
|
43
|
+
And a characteristic "origin" of "Bag End, Hobbiton, Westfarthing, The Shire, Eriador, Middle Earth"
|
44
|
+
And the geocoder will encode the origin as ","
|
71
45
|
When the "origin_location" committee is calculated
|
72
46
|
Then the conclusion of the committee should be nil
|
73
|
-
|
74
|
-
| origin |
|
75
|
-
| 00000 |
|
76
|
-
| Bag End, Hobbiton, Westfarthing, The Shire, Eriador, Middle Earth |
|
77
|
-
|
47
|
+
|
78
48
|
Scenario Outline: Destination from zip code
|
79
49
|
Given a shipment emitter
|
80
50
|
And a characteristic "destination_zip_code" of "<zip>"
|
@@ -89,27 +59,25 @@ Feature: Shipment Committee Calculations
|
|
89
59
|
Scenario Outline: Destination location from geocodeable destination
|
90
60
|
Given a shipment emitter
|
91
61
|
And a characteristic "destination" of "<destination>"
|
62
|
+
And the geocoder will encode the destination as "<geocode>"
|
92
63
|
When the "destination_location" committee is calculated
|
93
64
|
Then the committee should have used quorum "from destination"
|
94
65
|
And the conclusion of the committee should be "<location>"
|
95
66
|
Examples:
|
96
|
-
| destination
|
97
|
-
|
|
98
|
-
| San Francisco, CA
|
99
|
-
|
|
100
|
-
| Canterbury, Kent, UK
|
67
|
+
| destination | geocode | location |
|
68
|
+
| 05753 | 43.9968185,-73.1491165 | 43.9968185,-73.1491165 |
|
69
|
+
| San Francisco, CA | 37.7749295,-122.4194155 | 37.7749295,-122.4194155 |
|
70
|
+
| 488 Haight Street, San Francisco, CA | 37.7722302,-122.4303328 | 37.7722302,-122.4303328 |
|
71
|
+
| Canterbury, Kent, UK | 51.2772689,1.0805173 | 51.2772689,1.0805173 |
|
101
72
|
|
102
|
-
Scenario
|
73
|
+
Scenario: Destination location from non-geocodeable origin
|
103
74
|
Given a shipment emitter
|
104
|
-
And a characteristic "destination" of "
|
75
|
+
And a characteristic "destination" of "Bag End, Hobbiton, Westfarthing, The Shire, Eriador, Middle Earth"
|
76
|
+
And the geocoder will encode the destination as ","
|
105
77
|
When the "destination_location" committee is calculated
|
106
78
|
Then the conclusion of the committee should be nil
|
107
|
-
Examples:
|
108
|
-
| destination |
|
109
|
-
| 00000 |
|
110
|
-
| Bag End, Hobbiton, Westfarthing, The Shire, Eriador, Middle Earth |
|
111
79
|
|
112
|
-
Scenario: Segment count from
|
80
|
+
Scenario: Segment count from default
|
113
81
|
Given a shipment emitter
|
114
82
|
When the "segment_count" committee is calculated
|
115
83
|
Then the committee should have used quorum "default"
|
@@ -125,22 +93,20 @@ Feature: Shipment Committee Calculations
|
|
125
93
|
|
126
94
|
Scenario Outline: Distance by road from locations and mode
|
127
95
|
Given a shipment emitter
|
128
|
-
And a characteristic "
|
129
|
-
And a characteristic "
|
96
|
+
And a characteristic "origin_location" of "<origin>"
|
97
|
+
And a characteristic "destination_location" of "<destination>"
|
130
98
|
And a characteristic "mode.name" of "<mode>"
|
131
99
|
And a characteristic "mapquest_api_key" of "ABC123"
|
132
100
|
And mapquest determines the distance to be "<mapquest_distance>"
|
133
|
-
When the "
|
134
|
-
And the "destination_location" committee is calculated
|
135
|
-
And the "distance" committee is calculated
|
101
|
+
When the "distance" committee is calculated
|
136
102
|
Then the committee should have used quorum "by road"
|
137
103
|
And the conclusion of the committee should be "<distance>"
|
138
104
|
Examples:
|
139
105
|
| origin | destination | mode | mapquest_distance | distance |
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
106
|
+
| 43,-73 | 43.-73 | ground | 0.0 | 0.0 |
|
107
|
+
| 43,-73 | 43.1,-73 | ground | 57.93638 | 57.93638 |
|
108
|
+
| 43,-73 | 43,-73 | courier | 0.0 | 0.0 |
|
109
|
+
| 43,-73 | 43.1,-73 | courier | 57.93638 | 57.93638 |
|
144
110
|
|
145
111
|
Scenario: Distance by road from undriveable locations and mode
|
146
112
|
Given a shipment emitter
|
@@ -148,7 +114,6 @@ Feature: Shipment Committee Calculations
|
|
148
114
|
And a characteristic "destination" of "Canterbury, Kent, UK"
|
149
115
|
And a characteristic "mode.name" of "ground"
|
150
116
|
And a characteristic "mapquest_api_key" of "ABC123"
|
151
|
-
# And mapquest determines the distance to be "400 Could not find a data set capable of performing the route."
|
152
117
|
When the "origin_location" committee is calculated
|
153
118
|
And the "destination_location" committee is calculated
|
154
119
|
And the "distance" committee is calculated
|
@@ -157,27 +122,23 @@ Feature: Shipment Committee Calculations
|
|
157
122
|
|
158
123
|
Scenario Outline: Distance as the crow flies from locations and mode
|
159
124
|
Given a shipment emitter
|
160
|
-
And a characteristic "
|
161
|
-
And a characteristic "
|
125
|
+
And a characteristic "origin_location" of "<origin>"
|
126
|
+
And a characteristic "destination_location" of "<destination>"
|
162
127
|
And a characteristic "mode.name" of "air"
|
163
128
|
And a characteristic "mapquest_api_key" of "ABC123"
|
164
|
-
When the "
|
165
|
-
And the "destination_location" committee is calculated
|
166
|
-
And the "distance" committee is calculated
|
129
|
+
When the "distance" committee is calculated
|
167
130
|
Then the committee should have used quorum "as the crow flies"
|
168
131
|
And the conclusion of the committee should be "<distance>"
|
169
132
|
Examples:
|
170
|
-
| origin
|
171
|
-
|
|
172
|
-
|
|
133
|
+
| origin | destination | distance |
|
134
|
+
| 43.9968185,-73.1491165 | 44.4774456,-73.2163467 | 53.75967 |
|
135
|
+
| 42.732535,-84.5555347 | 51.2772689,1.0805173 | 6192.60039 |
|
173
136
|
|
174
137
|
Scenario: Distance as the crow flies from locations
|
175
138
|
Given a shipment emitter
|
176
|
-
And a characteristic "
|
177
|
-
And a characteristic "
|
178
|
-
When the "
|
179
|
-
And the "destination_location" committee is calculated
|
180
|
-
And the "distance" committee is calculated
|
139
|
+
And a characteristic "origin_location" of "43.9968185,-73.1491165"
|
140
|
+
And a characteristic "destination_location" of "44.4774456,-73.2163467"
|
141
|
+
When the "distance" committee is calculated
|
181
142
|
Then the committee should have used quorum "as the crow flies"
|
182
143
|
And the conclusion of the committee should be "53.75967"
|
183
144
|
|
@@ -208,7 +169,7 @@ Feature: Shipment Committee Calculations
|
|
208
169
|
Examples:
|
209
170
|
| segments | factor |
|
210
171
|
| 1 | 1.0 |
|
211
|
-
|
|
172
|
+
| 2 | 1.8 |
|
212
173
|
| -1 | 1.8 |
|
213
174
|
|
214
175
|
Scenario: Adjusted distance from default
|
@@ -237,35 +198,35 @@ Feature: Shipment Committee Calculations
|
|
237
198
|
And a characteristic "carrier.name" of "FedEx"
|
238
199
|
When the "transport_emission_factor" committee is calculated
|
239
200
|
Then the committee should have used quorum "from carrier"
|
240
|
-
And the conclusion of the committee should be "
|
201
|
+
And the conclusion of the committee should be "0.008"
|
241
202
|
|
242
|
-
Scenario Outline: Transport emission factor from mode,
|
203
|
+
Scenario Outline: Transport emission factor from mode, weight, and adjusted distance
|
243
204
|
Given a shipment emitter
|
244
205
|
And a characteristic "mode.name" of "<mode>"
|
245
|
-
And a characteristic "
|
206
|
+
And a characteristic "weight" of "<weight>"
|
246
207
|
And a characteristic "adjusted_distance" of "<adjusted_distance>"
|
247
208
|
When the "transport_emission_factor" committee is calculated
|
248
|
-
Then the committee should have used quorum "from mode,
|
209
|
+
Then the committee should have used quorum "from mode, weight, and adjusted distance"
|
249
210
|
And the conclusion of the committee should be "<emission_factor>"
|
250
211
|
Examples:
|
251
212
|
| mode | weight | adjusted_distance | emission_factor |
|
252
|
-
| courier | 2.0 | 5.0 |
|
253
|
-
| ground | 2.0 | 50.0 |
|
254
|
-
| air | 2.0 | 50.0 |
|
213
|
+
| courier | 2.0 | 5.0 | 0.5 |
|
214
|
+
| ground | 2.0 | 50.0 | 0.0002 |
|
215
|
+
| air | 2.0 | 50.0 | 0.002 |
|
255
216
|
|
256
|
-
Scenario Outline: Transport emission factor from carrier mode,
|
217
|
+
Scenario Outline: Transport emission factor from carrier mode, weight, and adjusted distance
|
257
218
|
Given a shipment emitter
|
258
219
|
And a characteristic "carrier_mode.name" of "<carrier_mode>"
|
259
|
-
And a characteristic "
|
220
|
+
And a characteristic "weight" of "<weight>"
|
260
221
|
And a characteristic "adjusted_distance" of "<adjusted_distance>"
|
261
222
|
When the "transport_emission_factor" committee is calculated
|
262
|
-
Then the committee should have used quorum "from carrier mode,
|
223
|
+
Then the committee should have used quorum "from carrier mode, weight, and adjusted distance"
|
263
224
|
And the conclusion of the committee should be "<emission_factor>"
|
264
225
|
Examples:
|
265
226
|
| carrier_mode | weight | adjusted_distance | emission_factor |
|
266
|
-
| FedEx courier | 2.0 | 5.0 |
|
267
|
-
| FedEx ground | 2.0 | 50.0 |
|
268
|
-
| FedEx air | 2.0 | 50.0 |
|
227
|
+
| FedEx courier | 2.0 | 5.0 | 0.2 |
|
228
|
+
| FedEx ground | 2.0 | 50.0 | 0.0001 |
|
229
|
+
| FedEx air | 2.0 | 50.0 | 0.001 |
|
269
230
|
|
270
231
|
Scenario: Corporate emission factor from default
|
271
232
|
Given a shipment emitter
|
@@ -278,23 +239,23 @@ Feature: Shipment Committee Calculations
|
|
278
239
|
And a characteristic "carrier.name" of "FedEx"
|
279
240
|
When the "corporate_emission_factor" committee is calculated
|
280
241
|
Then the committee should have used quorum "from carrier"
|
281
|
-
And the conclusion of the committee should be "
|
242
|
+
And the conclusion of the committee should be "0.3"
|
282
243
|
|
283
|
-
Scenario: Transport emission from
|
244
|
+
Scenario: Transport emission from weight, adjusted distance, and transport emission factor
|
284
245
|
Given a shipment emitter
|
285
|
-
And a characteristic "
|
246
|
+
And a characteristic "weight" of "2.0"
|
286
247
|
And a characteristic "adjusted_distance" of "100.0"
|
287
248
|
And a characteristic "transport_emission_factor" of "2.0"
|
288
249
|
When the "transport_emission" committee is calculated
|
289
|
-
Then the committee should have used quorum "from
|
250
|
+
Then the committee should have used quorum "from weight, adjusted distance, and transport emission factor"
|
290
251
|
And the conclusion of the committee should be "400.0"
|
291
252
|
|
292
|
-
Scenario: Corporate emission from
|
253
|
+
Scenario: Corporate emission from package count and corporate emission factor
|
293
254
|
Given a shipment emitter
|
294
|
-
And a characteristic "
|
255
|
+
And a characteristic "package_count" of "2"
|
295
256
|
And a characteristic "corporate_emission_factor" of "2.0"
|
296
257
|
When the "corporate_emission" committee is calculated
|
297
|
-
Then the committee should have used quorum "from
|
258
|
+
Then the committee should have used quorum "from package count and corporate emission factor"
|
298
259
|
And the conclusion of the committee should be "4.0"
|
299
260
|
|
300
261
|
Scenario: Emission from transport emission and corporate emission
|
@@ -6,29 +6,34 @@ Feature: Shipment Emissions Calculations
|
|
6
6
|
When emissions are calculated
|
7
7
|
Then the emission value should be within "0.1" kgs of "6.0"
|
8
8
|
|
9
|
-
Scenario: Calculations from weight, package count, segment count
|
9
|
+
Scenario: Calculations from weight, package count, segment count, and distance
|
10
10
|
Given a shipment has "weight" of "10"
|
11
11
|
And it has "package_count" of "2"
|
12
12
|
And it has "segment_count" of "1"
|
13
|
+
And it has "distance" of "1000"
|
13
14
|
When emissions are calculated
|
14
|
-
Then the emission value should be within "0.1" kgs of "
|
15
|
+
Then the emission value should be within "0.1" kgs of "5.9"
|
15
16
|
|
16
17
|
Scenario: Calculations from origin/destination zip code
|
17
18
|
Given a shipment has "origin_zip_code" of "05753"
|
19
|
+
And the geocoder will encode the origin_zip_code as "43.9968185,-73.1491165"
|
18
20
|
And it has "destination_zip_code" of "05401"
|
21
|
+
And the geocoder will encode the destination_zip_code as "44.4774456,-73.2163467"
|
19
22
|
When emissions are calculated
|
20
23
|
Then the emission value should be within "0.1" kgs of "0.4"
|
21
24
|
|
22
25
|
Scenario: Calculations from origin/destination
|
23
26
|
Given a shipment has "origin" of "Lansing, MI"
|
27
|
+
And the geocoder will encode the origin as "42.732535,-84.5555347"
|
24
28
|
And it has "destination" of "Canterbury, Kent, UK"
|
29
|
+
And the geocoder will encode the destination as "51.2772689,1.0805173"
|
25
30
|
When emissions are calculated
|
26
31
|
Then the emission value should be within "0.1" kgs of "20.8"
|
27
32
|
|
28
33
|
Scenario: Calculations from carrier
|
29
34
|
Given a shipment has "carrier.name" of "FedEx"
|
30
35
|
When emissions are calculated
|
31
|
-
Then the emission value should be within "0.1" kgs of "
|
36
|
+
Then the emission value should be within "0.1" kgs of "9.1"
|
32
37
|
|
33
38
|
Scenario Outline: Calculations from mode
|
34
39
|
Given a shipment has "mode.name" of "<mode>"
|
@@ -36,9 +41,9 @@ Feature: Shipment Emissions Calculations
|
|
36
41
|
Then the emission value should be within "0.1" kgs of "<emission>"
|
37
42
|
Examples:
|
38
43
|
| mode | emission |
|
39
|
-
| courier |
|
40
|
-
| ground |
|
41
|
-
| air |
|
44
|
+
| courier | 5.2 |
|
45
|
+
| ground | 2.4 |
|
46
|
+
| air | 22.1 |
|
42
47
|
|
43
48
|
Scenario Outline: Calculations from carrier and mode
|
44
49
|
Given a shipment has "mode.name" of "<mode>"
|
@@ -47,51 +52,44 @@ Feature: Shipment Emissions Calculations
|
|
47
52
|
Then the emission value should be within "0.1" kgs of "<emission>"
|
48
53
|
Examples:
|
49
54
|
| mode | emission |
|
50
|
-
| courier |
|
51
|
-
| ground |
|
52
|
-
| air |
|
55
|
+
| courier | 2.3 |
|
56
|
+
| ground | 1.4 |
|
57
|
+
| air | 11.2 |
|
53
58
|
|
54
59
|
Scenario Outline: Calculations from mode and origin/destination
|
55
60
|
Given a shipment has "mode.name" of "<mode>"
|
56
61
|
And it has "origin" of "<origin>"
|
62
|
+
And the geocoder will encode the origin as "<origin_location>"
|
57
63
|
And it has "destination" of "<destination>"
|
64
|
+
And the geocoder will encode the destination as "<destination_location>"
|
58
65
|
When emissions are calculated
|
59
66
|
Then the emission value should be within "0.1" kgs of "<emission>"
|
60
67
|
Examples:
|
61
|
-
| mode | origin | destination | emission |
|
62
|
-
| courier | 05753 | 05401 |
|
63
|
-
| courier | Lansing, MI | Canterbury, Kent, UK |
|
64
|
-
| ground | 05753 | 05401 |
|
65
|
-
| ground | Lansing, MI | Canterbury, Kent, UK |
|
66
|
-
| air | 05753 | 05401 |
|
67
|
-
| air | Lansing, MI | Canterbury, Kent, UK |
|
68
|
-
|
69
|
-
Scenario Outline: Calculations from mode and carrier
|
70
|
-
Given a shipment has "carrier.name" of "FedEx"
|
71
|
-
And it has "mode.name" of "<mode>"
|
72
|
-
When emissions are calculated
|
73
|
-
Then the emission value should be within "0.1" kgs of "<emission>"
|
74
|
-
Examples:
|
75
|
-
| mode | emission |
|
76
|
-
| courier | 2600.0 |
|
77
|
-
| ground | 23389.2 |
|
78
|
-
| air | 67167.6 |
|
68
|
+
| mode | origin | origin_location | destination | destination_location | emission |
|
69
|
+
| courier | 05753 | 43.9968185,-73.1491165 | 05401 | 44.4774456,-73.2163467 | 5.2 |
|
70
|
+
| courier | Lansing, MI | 42.732535,-84.5555347 | Canterbury, Kent, UK | 51.2772689,1.0805173 | 5.2 |
|
71
|
+
| ground | 05753 | 43.9968185,-73.1491165 | 05401 | 44.4774456,-73.2163467 | 0.3 |
|
72
|
+
| ground | Lansing, MI | 42.732535,-84.5555347 | Canterbury, Kent, UK | 51.2772689,1.0805173 | 7.8 |
|
73
|
+
| air | 05753 | 43.9968185,-73.1491165 | 05401 | 44.4774456,-73.2163467 | 0.9 |
|
74
|
+
| air | Lansing, MI | 42.732535,-84.5555347 | Canterbury, Kent, UK | 51.2772689,1.0805173 | 83.6 |
|
79
75
|
|
80
76
|
Scenario Outline: Calculations from mode, carrier, and origin/destination
|
81
77
|
Given a shipment has "carrier.name" of "FedEx"
|
82
78
|
And it has "mode.name" of "<mode>"
|
83
79
|
And it has "origin" of "<origin>"
|
80
|
+
And the geocoder will encode the origin as "<origin_location>"
|
84
81
|
And it has "destination" of "<destination>"
|
82
|
+
And the geocoder will encode the destination as "<destination_location>"
|
85
83
|
When emissions are calculated
|
86
84
|
Then the emission value should be within "0.1" kgs of "<emission>"
|
87
85
|
Examples:
|
88
|
-
| mode | origin | destination | emission |
|
89
|
-
| courier | 05753 | 05401 |
|
90
|
-
| courier | Lansing, MI | Canterbury, Kent, UK |
|
91
|
-
| ground | 05753 | 05401 |
|
92
|
-
| ground | Lansing, MI | Canterbury, Kent, UK |
|
93
|
-
| air | 05753 | 05401 |
|
94
|
-
| air | Lansing, MI | Canterbury, Kent, UK |
|
86
|
+
| mode | origin | origin_location | destination | destination_location | emission |
|
87
|
+
| courier | 05753 | 43.9968185,-73.1491165 | 05401 | 44.4774456,-73.2163467 | 2.3 |
|
88
|
+
| courier | Lansing, MI | 42.732535,-84.5555347 | Canterbury, Kent, UK | 51.2772689,1.0805173 | 2.3 |
|
89
|
+
| ground | 05753 | 43.9968185,-73.1491165 | 05401 | 44.4774456,-73.2163467 | 0.3 |
|
90
|
+
| ground | Lansing, MI | 42.732535,-84.5555347 | Canterbury, Kent, UK | 51.2772689,1.0805173 | 4.1 |
|
91
|
+
| air | 05753 | 43.9968185,-73.1491165 | 05401 | 44.4774456,-73.2163467 | 0.7 |
|
92
|
+
| air | Lansing, MI | 42.732535,-84.5555347 | Canterbury, Kent, UK | 51.2772689,1.0805173 | 42.0 |
|
95
93
|
|
96
94
|
Scenario Outline: Calculations from everything
|
97
95
|
Given a shipment has "weight" of "10.0"
|
@@ -100,14 +98,16 @@ Feature: Shipment Emissions Calculations
|
|
100
98
|
And it has "carrier.name" of "FedEx"
|
101
99
|
And it has "mode.name" of "<mode>"
|
102
100
|
And it has "origin" of "<origin>"
|
101
|
+
And the geocoder will encode the origin as "<origin_location>"
|
103
102
|
And it has "destination" of "<destination>"
|
103
|
+
And the geocoder will encode the destination as "<destination_location>"
|
104
104
|
When emissions are calculated
|
105
105
|
Then the emission value should be within "0.1" kgs of "<emission>"
|
106
106
|
Examples:
|
107
|
-
| mode | origin | destination | emission |
|
108
|
-
| courier | 05753 | 05401 |
|
109
|
-
| courier | Lansing, MI | Canterbury, Kent, UK |
|
110
|
-
| ground | 05753 | 05401 |
|
111
|
-
| ground | Lansing, MI | Canterbury, Kent, UK |
|
112
|
-
| air | 05753 | 05401 |
|
113
|
-
| air | Lansing, MI | Canterbury, Kent, UK |
|
107
|
+
| mode | origin | origin_location | destination | destination_location | emission |
|
108
|
+
| courier | 05753 | 43.9968185,-73.1491165 | 05401 | 44.4774456,-73.2163467 | 2.6 |
|
109
|
+
| courier | Lansing, MI | 42.732535,-84.5555347 | Canterbury, Kent, UK | 51.2772689,1.0805173 | 2.6 |
|
110
|
+
| ground | 05753 | 43.9968185,-73.1491165 | 05401 | 44.4774456,-73.2163467 | 0.7 |
|
111
|
+
| ground | Lansing, MI | 42.732535,-84.5555347 | Canterbury, Kent, UK | 51.2772689,1.0805173 | 6.8 |
|
112
|
+
| air | 05753 | 43.9968185,-73.1491165 | 05401 | 44.4774456,-73.2163467 | 1.2 |
|
113
|
+
| air | Lansing, MI | 42.732535,-84.5555347 | Canterbury, Kent, UK | 51.2772689,1.0805173 | 68.7 |
|
@@ -2,3 +2,14 @@ Given /^mapquest determines the distance to be "([^\"]*)"$/ do |distance|
|
|
2
2
|
mockquest = mock MapQuestDirections, :distance_in_kilometres => distance
|
3
3
|
MapQuestDirections.stub!(:new).and_return mockquest
|
4
4
|
end
|
5
|
+
|
6
|
+
Given /^the geocoder will encode the (.*) as "(.*)"$/ do |component, location|
|
7
|
+
@expectations << lambda do
|
8
|
+
components = @characteristics ? @characteristics : @activity_hash
|
9
|
+
component_value = components[component.to_sym].to_s
|
10
|
+
code = mock Object, :ll => location
|
11
|
+
Geokit::Geocoders::MultiGeocoder.should_receive(:geocode).
|
12
|
+
with(component_value).
|
13
|
+
and_return code
|
14
|
+
end
|
15
|
+
end
|
@@ -35,15 +35,15 @@ module BrighterPlanet
|
|
35
35
|
end
|
36
36
|
|
37
37
|
committee :corporate_emission do
|
38
|
-
quorum 'from
|
39
|
-
characteristics[:
|
38
|
+
quorum 'from package count and corporate emission factor', :needs => [:package_count, :corporate_emission_factor] do |characteristics|
|
39
|
+
characteristics[:package_count] * characteristics[:corporate_emission_factor]
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
committee :transport_emission do
|
44
|
-
quorum 'from
|
44
|
+
quorum 'from weight, adjusted distance, and transport emission factor', :needs => [:weight, :adjusted_distance, :transport_emission_factor] do |characteristics|
|
45
45
|
# we're assuming that the number of stops, rather than number of packages carried, is limiting factor on local delivery routes
|
46
|
-
characteristics[:
|
46
|
+
characteristics[:weight] * characteristics[:adjusted_distance] * characteristics[:transport_emission_factor]
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -58,17 +58,17 @@ module BrighterPlanet
|
|
58
58
|
end
|
59
59
|
|
60
60
|
committee :transport_emission_factor do
|
61
|
-
quorum 'from carrier mode,
|
61
|
+
quorum 'from carrier mode, weight, and adjusted distance', :needs => [:carrier_mode, :weight, :adjusted_distance] do |characteristics|
|
62
62
|
if characteristics[:carrier_mode].mode_name == "courier"
|
63
|
-
characteristics[:carrier_mode].transport_emission_factor / (characteristics[:
|
63
|
+
characteristics[:carrier_mode].transport_emission_factor / (characteristics[:weight] * characteristics[:adjusted_distance])
|
64
64
|
else
|
65
65
|
characteristics[:carrier_mode].transport_emission_factor
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
quorum 'from mode,
|
69
|
+
quorum 'from mode, weight, and adjusted distance', :needs => [:mode, :weight, :adjusted_distance] do |characteristics|
|
70
70
|
if characteristics[:mode].name == "courier"
|
71
|
-
characteristics[:mode].transport_emission_factor / (characteristics[:
|
71
|
+
characteristics[:mode].transport_emission_factor / (characteristics[:weight] * characteristics[:adjusted_distance])
|
72
72
|
else
|
73
73
|
characteristics[:mode].transport_emission_factor
|
74
74
|
end
|
@@ -176,29 +176,13 @@ module BrighterPlanet
|
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
179
|
-
committee :
|
180
|
-
quorum 'from package count', :needs => :package_count do |characteristics|
|
181
|
-
if characteristics[:package_count] > 0
|
182
|
-
characteristics[:package_count]
|
183
|
-
else
|
184
|
-
nil
|
185
|
-
end
|
186
|
-
end
|
187
|
-
|
179
|
+
committee :package_count do
|
188
180
|
quorum 'default' do
|
189
181
|
1 # ASSUMED arbitrary
|
190
182
|
end
|
191
183
|
end
|
192
184
|
|
193
|
-
committee :
|
194
|
-
quorum 'from weight', :needs => :weight do |characteristics|
|
195
|
-
if characteristics[:weight] > 0
|
196
|
-
characteristics[:weight]
|
197
|
-
else
|
198
|
-
nil
|
199
|
-
end
|
200
|
-
end
|
201
|
-
|
185
|
+
committee :weight do
|
202
186
|
quorum 'default' do
|
203
187
|
3.4 # ASSUMED based on average FedEx air package weight of 7.5 lbs
|
204
188
|
end
|
@@ -12,6 +12,7 @@ module BrighterPlanet
|
|
12
12
|
has :destination
|
13
13
|
has :origin_zip_code # for backwards compatability - note that this is a string, not a ZipCode
|
14
14
|
has :destination_zip_code # for backwards compatability - note that this is a string, not a ZipCode
|
15
|
+
has :distance
|
15
16
|
has :mapquest_api_key, :display => lambda { |key| "secret key" }
|
16
17
|
end
|
17
18
|
end
|
data/lib/shipment/data.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shipment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 8
|
10
|
+
version: 0.0.8
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andy Rossmeissl
|
@@ -19,7 +19,7 @@ autorequire:
|
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
21
|
|
22
|
-
date:
|
22
|
+
date: 2011-01-12 00:00:00 -08:00
|
23
23
|
default_executable:
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|
@@ -76,12 +76,12 @@ dependencies:
|
|
76
76
|
requirements:
|
77
77
|
- - ~>
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
hash:
|
79
|
+
hash: 1
|
80
80
|
segments:
|
81
81
|
- 0
|
82
82
|
- 4
|
83
|
-
-
|
84
|
-
version: 0.4.
|
83
|
+
- 7
|
84
|
+
version: 0.4.7
|
85
85
|
type: :development
|
86
86
|
version_requirements: *id004
|
87
87
|
- !ruby/object:Gem::Dependency
|
@@ -138,6 +138,7 @@ extensions: []
|
|
138
138
|
|
139
139
|
extra_rdoc_files:
|
140
140
|
- LICENSE
|
141
|
+
- LICENSE-PREAMBLE
|
141
142
|
- README.rdoc
|
142
143
|
files:
|
143
144
|
- LICENSE
|
@@ -150,6 +151,7 @@ files:
|
|
150
151
|
- lib/shipment/relationships.rb
|
151
152
|
- lib/shipment/summarization.rb
|
152
153
|
- lib/test_support/shipment_record.rb
|
154
|
+
- LICENSE-PREAMBLE
|
153
155
|
- features/step_definitions/shipment_steps.rb
|
154
156
|
- features/support/env.rb
|
155
157
|
- features/shipment_committees.feature
|