shipment 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,38 +31,28 @@ Feature: Shipment Committee Calculations
31
31
  Then the committee should have used quorum "default"
32
32
  And the conclusion of the committee should be "5"
33
33
 
34
- Scenario Outline: Distance from origin zip code, destination zip code, and default mode
34
+ Scenario Outline: Distance from origin zip code and destination zip code
35
35
  Given a shipment emitter
36
36
  And a characteristic "origin_zip_code.name" of "<origin>"
37
37
  And a characteristic "destination_zip_code.name" of "<destination>"
38
- When the "mode" committee is calculated
39
- And the "distance" committee is calculated
40
- Then the committee should have used quorum "from origin zip code, destination zip code, and mode"
38
+ When the "distance" committee is calculated
39
+ Then the committee should have used quorum "from origin zip code and destination zip code"
41
40
  And the conclusion of the committee should be "<distance>"
42
41
  Examples:
43
42
  | origin | destination | distance |
44
43
  | 05753 | 05753 | 0 |
45
44
  | 05753 | 05401 | 53 |
46
45
 
47
- Scenario Outline: Distance from origin zip code and destination zip code
46
+ Scenario Outline: Distance from zip codes not in database or missing lat/lng
48
47
  Given a shipment emitter
49
48
  And a characteristic "origin_zip_code.name" of "<origin>"
50
49
  And a characteristic "destination_zip_code.name" of "<destination>"
51
- And a characteristic "mode.name" of "<mode>"
52
50
  When the "distance" committee is calculated
53
- Then the committee should have used quorum "from origin zip code, destination zip code, and mode"
54
- And the conclusion of the committee should be "<distance>"
51
+ Then the conclusion of the committee should be nil
55
52
  Examples:
56
- | origin | destination | mode | distance |
57
- | 05753 | 05753 | courier | 0 |
58
- | 05753 | 05401 | courier | 53 |
59
- | 05753 | 20860 | courier | 8679 |
60
- | 05401 | 05401 | air | 0 |
61
- | 05401 | 94128 | air | 4133.31657 |
62
- | 05401 | 20860 | air | 8693 |
63
- | 05401 | 05401 | ground | 0 |
64
- | 05401 | 94128 | ground | 4133 |
65
- | 05401 | 20860 | ground | 8693 |
53
+ | origin | destination |
54
+ | 05753 | 20860 |
55
+ | 05753 | 99999 |
66
56
 
67
57
  Scenario: Route inefficiency factor from nothing
68
58
  Given a shipment emitter
@@ -121,7 +111,7 @@ Feature: Shipment Committee Calculations
121
111
  When the "mode" committee is calculated
122
112
  And the "transport_emission_factor" committee is calculated
123
113
  Then the committee should have used quorum "from mode"
124
- And the conclusion of the committee should be "3.0"
114
+ And the conclusion of the committee should be "0.00076955"
125
115
 
126
116
  Scenario Outline: Transport emission factor from mode
127
117
  Given a shipment emitter
@@ -140,7 +130,7 @@ Feature: Shipment Committee Calculations
140
130
  When the "carrier" committee is calculated
141
131
  And the "corporate_emission_factor" committee is calculated
142
132
  Then the committee should have used quorum "from carrier"
143
- And the conclusion of the committee should be "2.0"
133
+ And the conclusion of the committee should be "0.318"
144
134
 
145
135
  Scenario: Corporate emission factor from carrier
146
136
  Given a shipment emitter
@@ -149,7 +139,7 @@ Feature: Shipment Committee Calculations
149
139
  Then the committee should have used quorum "from carrier"
150
140
  And the conclusion of the committee should be "2.0"
151
141
 
152
- Scenario Outline: Transport emission from defaults
142
+ Scenario: Transport emission from defaults
153
143
  Given a shipment emitter
154
144
  When the "weight" committee is calculated
155
145
  And the "mode" committee is calculated
@@ -157,7 +147,7 @@ Feature: Shipment Committee Calculations
157
147
  And the "transport_emission_factor" committee is calculated
158
148
  And the "transport_emission" committee is calculated
159
149
  Then the committee should have used quorum "from mode, weight, adjusted distance, and transport emission factor"
160
- And the conclusion of the committee should be "600.0"
150
+ And the conclusion of the committee should be "8.42296"
161
151
 
162
152
  Scenario Outline: Transport emission from mode, weight, adjusted distance, and transport emission factor
163
153
  Given a shipment emitter
@@ -4,14 +4,14 @@ Feature: Shipment Emissions Calculations
4
4
  Scenario: Calculations starting from nothing
5
5
  Given a shipment has nothing
6
6
  When emissions are calculated
7
- Then the emission value should be within "0.1" kgs of "32835.8"
7
+ Then the emission value should be within "0.1" kgs of "8.7"
8
8
 
9
9
  Scenario: Calculations from weight, package count, segment count
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
13
  When emissions are calculated
14
- Then the emission value should be within "0.1" kgs of "96574.0"
14
+ Then the emission value should be within "0.1" kgs of "25.4"
15
15
 
16
16
  Scenario Outline: Calculations from origin/destination
17
17
  Given a shipment has "origin_zip_code.name" of "<origin>"
@@ -20,13 +20,13 @@ Feature: Shipment Emissions Calculations
20
20
  Then the emission value should be within "0.1" kgs of "<emission>"
21
21
  Examples:
22
22
  | origin | destination | emission |
23
- | 05401 | 05401 | 0.318 |
24
- | 05401 | 94128 | 224106.1 |
23
+ | 05401 | 05401 | 0.3 |
24
+ | 05401 | 94128 | 57.8 |
25
25
 
26
26
  Scenario: Calculations from carrier
27
27
  Given a shipment has "carrier.name" of "FedEx"
28
28
  When emissions are calculated
29
- Then the emission value should be within "0.1" kgs of "32835.8"
29
+ Then the emission value should be within "0.1" kgs of "10.4"
30
30
 
31
31
  Scenario Outline: Calculations from mode
32
32
  Given a shipment has "mode.name" of "<mode>"
@@ -34,9 +34,9 @@ Feature: Shipment Emissions Calculations
34
34
  Then the emission value should be within "0.1" kgs of "<emission>"
35
35
  Examples:
36
36
  | mode | emission |
37
- | courier | 4.0 |
38
- | ground | 10946.6 |
39
- | air | 54725.0 |
37
+ | courier | 2.3 |
38
+ | ground | 10944.9 |
39
+ | air | 54723.3 |
40
40
 
41
41
  Scenario Outline: Calculations from mode and origin/destination
42
42
  Given a shipment has "mode.name" of "<mode>"
@@ -46,9 +46,9 @@ Feature: Shipment Emissions Calculations
46
46
  Then the emission value should be within "0.1" kgs of "<emission>"
47
47
  Examples:
48
48
  | mode | origin | destination | emission |
49
- | courier | 05401 | 05401 | 99999.9 |
50
- | courier | 05401 | 94128 | 99999.9 |
51
- | ground | 05401 | 05401 | 99999.9 |
52
- | ground | 05401 | 94128 | 99999.9 |
53
- | air | 05401 | 05401 | 99999.9 |
54
- | air | 05401 | 94128 | 391297.9 |
49
+ | courier | 05401 | 05401 | 2.3 |
50
+ | ground | 05401 | 05401 | 0.3 |
51
+ | air | 05401 | 05401 | 0.3 |
52
+ | courier | 05401 | 94128 | 2.3 |
53
+ | ground | 05401 | 94128 | 71145.0 |
54
+ | air | 05401 | 94128 | 391296.2 |
@@ -95,14 +95,23 @@ module BrighterPlanet
95
95
  end
96
96
 
97
97
  committee :distance do
98
- quorum 'from origin zip code, destination zip code, and mode', :needs => [:origin_zip_code, :destination_zip_code], do |characteristics|
99
- if characteristics[:origin_zip_code] == characteristics[:destination_zip_code]
100
- # FIXME TODO
101
- # Special calculation to deal with travel within the same zipcode
102
- 0
98
+ quorum 'from origin zip code and destination zip code', :needs => [:origin_zip_code, :destination_zip_code], do |characteristics|
99
+ # Ensure both the origin and destination zip codes are in our database
100
+ if characteristics[:origin_zip_code] and characteristics[:destination_zip_code]
101
+ if characteristics[:origin_zip_code] == characteristics[:destination_zip_code]
102
+ # FIXME TODO
103
+ # Special calculation to deal with travel within the same zipcode
104
+ 0
105
+ # Ensure we have the lat/lng for both origin and destination
106
+ elsif characteristics[:origin_zip_code].latitude and characteristics[:origin_zip_code].longitude and
107
+ characteristics[:destination_zip_code].latitude and characteristics[:destination_zip_code].longitude
108
+ characteristics[:origin_zip_code].distance_to(characteristics[:destination_zip_code], :units => :kms)
109
+ # FIXME TODO: calculate the distance via road using map directions
110
+ else
111
+ nil
112
+ end
103
113
  else
104
- characteristics[:origin_zip_code].distance_to(characteristics[:destination_zip_code], :units => :kms)
105
- # FIXME TODO: calculate the distance via road using map directions
114
+ nil
106
115
  end
107
116
  end
108
117
  end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shipment
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 25
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 0
8
- - 2
9
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
10
11
  platform: ruby
11
12
  authors:
12
13
  - Andy Rossmeissl
@@ -18,96 +19,102 @@ autorequire:
18
19
  bindir: bin
19
20
  cert_chain: []
20
21
 
21
- date: 2010-12-10 00:00:00 -05:00
22
+ date: 2010-12-12 00:00:00 -05:00
22
23
  default_executable:
23
24
  dependencies:
24
25
  - !ruby/object:Gem::Dependency
25
26
  name: activerecord
27
+ prerelease: false
26
28
  requirement: &id001 !ruby/object:Gem::Requirement
27
29
  none: false
28
30
  requirements:
29
31
  - - ~>
30
32
  - !ruby/object:Gem::Version
33
+ hash: 5
31
34
  segments:
32
35
  - 3
33
36
  - 0
34
37
  - 1
35
38
  version: 3.0.1
36
39
  type: :development
37
- prerelease: false
38
40
  version_requirements: *id001
39
41
  - !ruby/object:Gem::Dependency
40
42
  name: bundler
43
+ prerelease: false
41
44
  requirement: &id002 !ruby/object:Gem::Requirement
42
45
  none: false
43
46
  requirements:
44
47
  - - ~>
45
48
  - !ruby/object:Gem::Version
49
+ hash: 23
46
50
  segments:
47
51
  - 1
48
52
  - 0
49
53
  - 0
50
54
  version: 1.0.0
51
55
  type: :development
52
- prerelease: false
53
56
  version_requirements: *id002
54
57
  - !ruby/object:Gem::Dependency
55
58
  name: rake
59
+ prerelease: false
56
60
  requirement: &id003 !ruby/object:Gem::Requirement
57
61
  none: false
58
62
  requirements:
59
63
  - - ">="
60
64
  - !ruby/object:Gem::Version
65
+ hash: 3
61
66
  segments:
62
67
  - 0
63
68
  version: "0"
64
69
  type: :development
65
- prerelease: false
66
70
  version_requirements: *id003
67
71
  - !ruby/object:Gem::Dependency
68
72
  name: sniff
73
+ prerelease: false
69
74
  requirement: &id004 !ruby/object:Gem::Requirement
70
75
  none: false
71
76
  requirements:
72
77
  - - ~>
73
78
  - !ruby/object:Gem::Version
79
+ hash: 9
74
80
  segments:
75
81
  - 0
76
82
  - 4
77
83
  - 3
78
84
  version: 0.4.3
79
85
  type: :development
80
- prerelease: false
81
86
  version_requirements: *id004
82
87
  - !ruby/object:Gem::Dependency
83
88
  name: emitter
89
+ prerelease: false
84
90
  requirement: &id005 !ruby/object:Gem::Requirement
85
91
  none: false
86
92
  requirements:
87
93
  - - ~>
88
94
  - !ruby/object:Gem::Version
95
+ hash: 19
89
96
  segments:
90
97
  - 0
91
98
  - 3
92
99
  - 0
93
100
  version: 0.3.0
94
101
  type: :runtime
95
- prerelease: false
96
102
  version_requirements: *id005
97
103
  - !ruby/object:Gem::Dependency
98
104
  name: earth
105
+ prerelease: false
99
106
  requirement: &id006 !ruby/object:Gem::Requirement
100
107
  none: false
101
108
  requirements:
102
109
  - - ~>
103
110
  - !ruby/object:Gem::Version
111
+ hash: 3
104
112
  segments:
105
113
  - 0
106
114
  - 3
107
- - 7
108
- version: 0.3.7
115
+ - 8
116
+ version: 0.3.8
109
117
  type: :runtime
110
- prerelease: false
111
118
  version_requirements: *id006
112
119
  description: A software model in Ruby for the greenhouse gas emissions of a shipment
113
120
  email: andy@rossmeissl.net
@@ -146,7 +153,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
153
  requirements:
147
154
  - - ">="
148
155
  - !ruby/object:Gem::Version
149
- hash: 71045619
156
+ hash: 3
150
157
  segments:
151
158
  - 0
152
159
  version: "0"
@@ -155,6 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
162
  requirements:
156
163
  - - ">="
157
164
  - !ruby/object:Gem::Version
165
+ hash: 3
158
166
  segments:
159
167
  - 0
160
168
  version: "0"