flight 0.0.18 → 0.0.19
Sign up to get free protection for your applications and to get access to all the features.
@@ -141,7 +141,7 @@ Feature: Flight Committee Calculations
|
|
141
141
|
And the conclusion of the committee should be "<distance>"
|
142
142
|
Examples:
|
143
143
|
| airline | distance |
|
144
|
-
| DA |
|
144
|
+
| DA | 99.89200 |
|
145
145
|
| IA | 1000.0 |
|
146
146
|
|
147
147
|
Scenario: Distance committee from default
|
@@ -214,13 +214,13 @@ Feature: Flight Committee Calculations
|
|
214
214
|
And a characteristic "aircraft_class.brighter_planet_aircraft_class_code" of "EX"
|
215
215
|
When the "seats" committee is calculated
|
216
216
|
Then the committee should have used quorum "from aircraft class"
|
217
|
-
And the conclusion of the committee should be "
|
217
|
+
And the conclusion of the committee should be "116"
|
218
218
|
|
219
219
|
Scenario: Seats committee from default
|
220
220
|
Given a flight emitter
|
221
221
|
When the "seats" committee is calculated
|
222
222
|
Then the committee should have used quorum "default"
|
223
|
-
And the conclusion of the committee should be "
|
223
|
+
And the conclusion of the committee should be "116"
|
224
224
|
|
225
225
|
Scenario: Passengers committee
|
226
226
|
Given a flight emitter
|
@@ -321,9 +321,3 @@ Feature: Flight Committee Calculations
|
|
321
321
|
Examples:
|
322
322
|
| fuel | passengers | seat_mult | ef | rfi | freight | date | emission |
|
323
323
|
| 100 | 100 | 1.5 | 10 | 2 | 0.10 | 2010-07-15 | 27 |
|
324
|
-
|
325
|
-
Scenario: Emission committee from default
|
326
|
-
Given a flight emitter
|
327
|
-
When the "emission" committee is calculated
|
328
|
-
Then the committee should have used quorum "default"
|
329
|
-
And the conclusion of the committee should be ""
|
@@ -6,9 +6,9 @@ Feature: Flight Emissions Calculations
|
|
6
6
|
And it has "destination_airport.iata_code" of "<dest>"
|
7
7
|
And it has "airline.iata_code" of "<airline>"
|
8
8
|
And it has "date" of "<date>"
|
9
|
-
And it
|
9
|
+
And it has "aircraft.bts_aircraft_type_code" of "<aircraft>"
|
10
10
|
When emissions are calculated
|
11
|
-
Then the emission value should be within 1 kgs of <emission>
|
11
|
+
Then the emission value should be within "0.1" kgs of "<emission>"
|
12
12
|
Examples:
|
13
13
|
| source | dest | airline | date | aircraft | emission |
|
14
|
-
| DCA | JFK | AA | 2010-06-25 | 1 |
|
14
|
+
| DCA | JFK | AA | 2010-06-25 | 1 | 146.7 |
|
data/lib/flight/carbon_model.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'leap'
|
2
1
|
require 'timeframe'
|
3
2
|
require 'weighted_average'
|
4
3
|
|
@@ -6,14 +5,16 @@ module BrighterPlanet
|
|
6
5
|
module Flight
|
7
6
|
module CarbonModel
|
8
7
|
def self.included(base)
|
9
|
-
base.extend ::Leap::Subject
|
10
8
|
base.extend FastTimestamp
|
11
9
|
base.decide :emission, :with => :characteristics do
|
12
10
|
committee :emission do
|
13
11
|
quorum 'from fuel and passengers with coefficients',
|
14
12
|
:needs => [:fuel, :passengers, :seat_class_multiplier, :emission_factor,
|
15
13
|
:radiative_forcing_index, :freight_share, :date] do |characteristics, timeframe|
|
16
|
-
|
14
|
+
date = characteristics[:date].is_a?(Date) ?
|
15
|
+
characteristics[:date] :
|
16
|
+
Date.parse(characteristics[:date].to_s)
|
17
|
+
if timeframe.include? date
|
17
18
|
#( kg fuel ) * ( kg CO2 / kg fuel ) = kg CO2
|
18
19
|
(characteristics[:fuel] / characteristics[:passengers] * characteristics[:seat_class_multiplier]) * characteristics[:emission_factor] * characteristics[:radiative_forcing_index] * (1 - characteristics[:freight_share])
|
19
20
|
else
|
@@ -149,14 +150,14 @@ module BrighterPlanet
|
|
149
150
|
end
|
150
151
|
|
151
152
|
quorum 'default' do
|
152
|
-
|
153
|
+
base.fallback.andand.load_factor
|
153
154
|
end
|
154
155
|
end
|
155
156
|
|
156
157
|
committee :adjusted_distance do # returns nautical miles
|
157
158
|
quorum 'from distance', :needs => [:distance, :emplanements_per_trip] do |characteristics|
|
158
|
-
route_inefficiency_factor =
|
159
|
-
dogleg_factor =
|
159
|
+
route_inefficiency_factor = base.research(:route_inefficiency_factor)
|
160
|
+
dogleg_factor = base.research(:dogleg_factor)
|
160
161
|
characteristics[:distance] * route_inefficiency_factor * ( dogleg_factor ** (characteristics[:emplanements_per_trip] - 1) )
|
161
162
|
end
|
162
163
|
end
|
@@ -185,13 +186,13 @@ module BrighterPlanet
|
|
185
186
|
end
|
186
187
|
|
187
188
|
quorum 'default' do
|
188
|
-
|
189
|
+
base.fallback.distance_estimate.kilometres.to :nautical_miles
|
189
190
|
end
|
190
191
|
end
|
191
192
|
|
192
193
|
committee :emplanements_per_trip do # per trip
|
193
194
|
quorum 'default' do
|
194
|
-
|
195
|
+
base.fallback.emplanements_per_trip_before_type_cast
|
195
196
|
end
|
196
197
|
end
|
197
198
|
|
@@ -226,7 +227,7 @@ module BrighterPlanet
|
|
226
227
|
|
227
228
|
committee :trips do
|
228
229
|
quorum 'default' do
|
229
|
-
|
230
|
+
base.fallback.andand.trips_before_type_cast
|
230
231
|
end
|
231
232
|
end
|
232
233
|
|
@@ -1,10 +1,7 @@
|
|
1
|
-
require 'characterizable'
|
2
|
-
|
3
1
|
module BrighterPlanet
|
4
2
|
module Flight
|
5
3
|
module Characterization
|
6
4
|
def self.included(base)
|
7
|
-
base.send :include, Characterizable
|
8
5
|
base.characterize do
|
9
6
|
has :date, :trumps => :year
|
10
7
|
has :year
|
@@ -28,7 +25,6 @@ module BrighterPlanet
|
|
28
25
|
|
29
26
|
has :creation_date, :hidden => true
|
30
27
|
end
|
31
|
-
base.add_implicit_characteristics
|
32
28
|
end
|
33
29
|
end
|
34
30
|
end
|
data/lib/flight/data.rb
CHANGED
data/lib/flight/summarization.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
|
-
require 'summary_judgement'
|
2
|
-
|
3
1
|
module BrighterPlanet
|
4
2
|
module Flight
|
5
3
|
module Summarization
|
6
4
|
def self.included(base)
|
7
|
-
base.extend SummaryJudgement
|
8
5
|
base.summarize do |has|
|
9
6
|
has.adjective 'one-way', :if => lambda { |flight| flight.trips == 1 }
|
10
7
|
has.adjective 'round-trip', :if => lambda { |flight| flight.trips == 1 }
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 57
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 19
|
10
|
+
version: 0.0.19
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andy Rossmeissl
|
@@ -19,48 +19,46 @@ autorequire:
|
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
21
|
|
22
|
-
date: 2010-09-
|
22
|
+
date: 2010-09-22 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: 23
|
51
51
|
segments:
|
52
52
|
- 1
|
53
53
|
- 0
|
54
54
|
- 0
|
55
|
-
|
56
|
-
|
57
|
-
version: 1.0.0.beta.2
|
58
|
-
type: :development
|
59
|
-
version_requirements: *id002
|
55
|
+
version: 1.0.0
|
56
|
+
requirement: *id002
|
60
57
|
- !ruby/object:Gem::Dependency
|
61
|
-
|
58
|
+
type: :development
|
62
59
|
prerelease: false
|
63
|
-
|
60
|
+
name: cucumber
|
61
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
64
62
|
none: false
|
65
63
|
requirements:
|
66
64
|
- - "="
|
@@ -71,12 +69,12 @@ dependencies:
|
|
71
69
|
- 8
|
72
70
|
- 3
|
73
71
|
version: 0.8.3
|
74
|
-
|
75
|
-
version_requirements: *id003
|
72
|
+
requirement: *id003
|
76
73
|
- !ruby/object:Gem::Dependency
|
77
|
-
|
74
|
+
type: :development
|
78
75
|
prerelease: false
|
79
|
-
|
76
|
+
name: jeweler
|
77
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
80
78
|
none: false
|
81
79
|
requirements:
|
82
80
|
- - "="
|
@@ -87,12 +85,12 @@ dependencies:
|
|
87
85
|
- 4
|
88
86
|
- 0
|
89
87
|
version: 1.4.0
|
90
|
-
|
91
|
-
version_requirements: *id004
|
88
|
+
requirement: *id004
|
92
89
|
- !ruby/object:Gem::Dependency
|
93
|
-
|
90
|
+
type: :development
|
94
91
|
prerelease: false
|
95
|
-
|
92
|
+
name: rake
|
93
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
96
94
|
none: false
|
97
95
|
requirements:
|
98
96
|
- - ">="
|
@@ -101,12 +99,12 @@ dependencies:
|
|
101
99
|
segments:
|
102
100
|
- 0
|
103
101
|
version: "0"
|
104
|
-
|
105
|
-
version_requirements: *id005
|
102
|
+
requirement: *id005
|
106
103
|
- !ruby/object:Gem::Dependency
|
107
|
-
|
104
|
+
type: :development
|
108
105
|
prerelease: false
|
109
|
-
|
106
|
+
name: rdoc
|
107
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
110
108
|
none: false
|
111
109
|
requirements:
|
112
110
|
- - ">="
|
@@ -115,12 +113,12 @@ dependencies:
|
|
115
113
|
segments:
|
116
114
|
- 0
|
117
115
|
version: "0"
|
118
|
-
|
119
|
-
version_requirements: *id006
|
116
|
+
requirement: *id006
|
120
117
|
- !ruby/object:Gem::Dependency
|
121
|
-
|
118
|
+
type: :development
|
122
119
|
prerelease: false
|
123
|
-
|
120
|
+
name: rspec
|
121
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
124
122
|
none: false
|
125
123
|
requirements:
|
126
124
|
- - "="
|
@@ -133,40 +131,39 @@ dependencies:
|
|
133
131
|
- beta
|
134
132
|
- 17
|
135
133
|
version: 2.0.0.beta.17
|
136
|
-
|
137
|
-
version_requirements: *id007
|
134
|
+
requirement: *id007
|
138
135
|
- !ruby/object:Gem::Dependency
|
139
|
-
|
136
|
+
type: :development
|
140
137
|
prerelease: false
|
141
|
-
|
138
|
+
name: sniff
|
139
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
142
140
|
none: false
|
143
141
|
requirements:
|
144
|
-
- -
|
142
|
+
- - ~>
|
145
143
|
- !ruby/object:Gem::Version
|
146
|
-
hash:
|
144
|
+
hash: 7
|
147
145
|
segments:
|
148
146
|
- 0
|
149
147
|
- 1
|
150
|
-
-
|
151
|
-
version: 0.1.
|
152
|
-
|
153
|
-
version_requirements: *id008
|
148
|
+
- 14
|
149
|
+
version: 0.1.14
|
150
|
+
requirement: *id008
|
154
151
|
- !ruby/object:Gem::Dependency
|
155
|
-
|
152
|
+
type: :runtime
|
156
153
|
prerelease: false
|
157
|
-
|
154
|
+
name: emitter
|
155
|
+
version_requirements: &id009 !ruby/object:Gem::Requirement
|
158
156
|
none: false
|
159
157
|
requirements:
|
160
|
-
- -
|
158
|
+
- - ~>
|
161
159
|
- !ruby/object:Gem::Version
|
162
|
-
hash:
|
160
|
+
hash: 19
|
163
161
|
segments:
|
164
162
|
- 0
|
165
|
-
-
|
163
|
+
- 1
|
166
164
|
- 4
|
167
|
-
version: 0.
|
168
|
-
|
169
|
-
version_requirements: *id009
|
165
|
+
version: 0.1.4
|
166
|
+
requirement: *id009
|
170
167
|
description: A software model in Ruby for the greenhouse gas emissions of a flight
|
171
168
|
email: andy@rossmeissl.net
|
172
169
|
executables: []
|