flight 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/features/step_definitions/carbon_steps.rb +2 -2
- data/features/support/env.rb +1 -12
- data/lib/flight.rb +6 -6
- data/lib/test_support/db/schema.rb +0 -311
- metadata +89 -58
- data/lib/test_support/data_models/aircraft.rb +0 -25
- data/lib/test_support/data_models/aircraft_class.rb +0 -6
- data/lib/test_support/data_models/aircraft_manufacturer.rb +0 -5
- data/lib/test_support/data_models/airline.rb +0 -24
- data/lib/test_support/data_models/airport.rb +0 -52
- data/lib/test_support/data_models/flight_configuration.rb +0 -3
- data/lib/test_support/data_models/flight_distance_class.rb +0 -3
- data/lib/test_support/data_models/flight_domesticity.rb +0 -3
- data/lib/test_support/data_models/flight_fuel_type.rb +0 -6
- data/lib/test_support/data_models/flight_propulsion.rb +0 -3
- data/lib/test_support/data_models/flight_seat_class.rb +0 -8
- data/lib/test_support/data_models/flight_segment.rb +0 -30
- data/lib/test_support/data_models/flight_service.rb +0 -3
@@ -23,10 +23,10 @@ When /^emissions are calculated$/ do
|
|
23
23
|
@activity = FlightRecord.from_params_hash @activity_hash
|
24
24
|
if @current_date
|
25
25
|
Timecop.travel(@current_date) do
|
26
|
-
@emission = @activity.emission
|
26
|
+
@emission = @activity.emission Timeframe.this_year
|
27
27
|
end
|
28
28
|
else
|
29
|
-
@emission = @activity.emission
|
29
|
+
@emission = @activity.emission Timeframe.this_year
|
30
30
|
end
|
31
31
|
@characteristics = @activity.deliberations[:emission].characteristics
|
32
32
|
end
|
data/features/support/env.rb
CHANGED
@@ -5,15 +5,4 @@ require 'cucumber'
|
|
5
5
|
require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
|
6
6
|
|
7
7
|
require 'sniff'
|
8
|
-
|
9
|
-
Sniff.init File.join(File.dirname(__FILE__), '..', '..')
|
10
|
-
|
11
|
-
## How to clean your database when transactions are turned off. See
|
12
|
-
## http://github.com/bmabey/database_cleaner for more info.
|
13
|
-
#if defined?(ActiveRecord::Base)
|
14
|
-
# begin
|
15
|
-
# require 'database_cleaner'
|
16
|
-
# DatabaseCleaner.strategy = :truncation
|
17
|
-
# rescue LoadError => ignore_if_database_cleaner_not_present
|
18
|
-
# end
|
19
|
-
#end
|
8
|
+
Sniff.init File.join(File.dirname(__FILE__), '..', '..'), :earth => :air
|
data/lib/flight.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
require 'flight/carbon_model'
|
2
|
-
require 'flight/characterization'
|
3
|
-
require 'flight/data'
|
4
|
-
require 'flight/summarization'
|
5
|
-
|
6
1
|
module BrighterPlanet
|
7
2
|
module Flight
|
8
3
|
extend self
|
9
4
|
|
10
5
|
def included(base)
|
6
|
+
require 'flight/carbon_model'
|
7
|
+
require 'flight/characterization'
|
8
|
+
require 'flight/data'
|
9
|
+
require 'flight/summarization'
|
10
|
+
|
11
11
|
base.send :include, BrighterPlanet::Flight::CarbonModel
|
12
12
|
base.send :include, BrighterPlanet::Flight::Characterization
|
13
|
-
|
13
|
+
base.send :include, BrighterPlanet::Flight::Data
|
14
14
|
base.send :include, BrighterPlanet::Flight::Summarization
|
15
15
|
end
|
16
16
|
def flight_model
|
@@ -1,317 +1,6 @@
|
|
1
1
|
require 'sniff/database'
|
2
2
|
|
3
3
|
Sniff::Database.define_schema do
|
4
|
-
create_table "aircraft", :primary_key => "icao_code", :id => false, :force => true do |t|
|
5
|
-
t.string 'icao_code'
|
6
|
-
t.string "manufacturer_name"
|
7
|
-
t.string "name"
|
8
|
-
t.string "bts_name"
|
9
|
-
t.string "bts_aircraft_type_code"
|
10
|
-
t.string "brighter_planet_aircraft_class_code"
|
11
|
-
t.string "fuel_use_aircraft_name"
|
12
|
-
t.float "m3"
|
13
|
-
t.float "m2"
|
14
|
-
t.float "m1"
|
15
|
-
t.float "endpoint_fuel"
|
16
|
-
t.float "seats"
|
17
|
-
t.float "distance"
|
18
|
-
t.float "load_factor"
|
19
|
-
t.float "freight_share"
|
20
|
-
t.float "payload"
|
21
|
-
t.float "weighting"
|
22
|
-
t.datetime "created_at"
|
23
|
-
t.datetime "updated_at"
|
24
|
-
end
|
25
|
-
|
26
|
-
create_table "aircraft_classes", :primary_key => "brighter_planet_aircraft_class_code", :id => false, :force => true do |t|
|
27
|
-
t.string 'brighter_planet_aircraft_class_code'
|
28
|
-
t.string "name"
|
29
|
-
t.float "m1"
|
30
|
-
t.float "m2"
|
31
|
-
t.float "m3"
|
32
|
-
t.float "endpoint_fuel"
|
33
|
-
t.integer "seats"
|
34
|
-
t.datetime "created_at"
|
35
|
-
t.datetime "updated_at"
|
36
|
-
end
|
37
|
-
|
38
|
-
create_table "aircraft_manufacturers", :primary_key => "name", :id => false, :force => true do |t|
|
39
|
-
t.string 'name'
|
40
|
-
t.datetime "created_at"
|
41
|
-
t.datetime "updated_at"
|
42
|
-
end
|
43
|
-
|
44
|
-
create_table "airlines", :primary_key => "iata_code", :id => false, :force => true do |t|
|
45
|
-
t.string 'iata_code'
|
46
|
-
t.string "name"
|
47
|
-
t.string "dot_airline_id_code"
|
48
|
-
t.boolean "international"
|
49
|
-
t.float "distance"
|
50
|
-
t.float "load_factor"
|
51
|
-
t.float "freight_share"
|
52
|
-
t.float "payload"
|
53
|
-
t.datetime "created_at"
|
54
|
-
t.datetime "updated_at"
|
55
|
-
t.float "seats"
|
56
|
-
end
|
57
|
-
|
58
|
-
create_table "airports", :primary_key => "iata_code", :id => false, :force => true do |t|
|
59
|
-
t.string 'iata_code'
|
60
|
-
t.string "name"
|
61
|
-
t.string "city"
|
62
|
-
t.string "country_name"
|
63
|
-
t.string "country_iso_3166_code"
|
64
|
-
t.float "latitude"
|
65
|
-
t.float "longitude"
|
66
|
-
t.float "seats"
|
67
|
-
t.float "distance"
|
68
|
-
t.float "load_factor"
|
69
|
-
t.float "freight_share"
|
70
|
-
t.float "payload"
|
71
|
-
t.boolean "international_origin"
|
72
|
-
t.boolean "international_destination"
|
73
|
-
t.datetime "created_at"
|
74
|
-
t.datetime "updated_at"
|
75
|
-
end
|
76
|
-
|
77
|
-
create_table "flight_aircraft", :force => true do |t|
|
78
|
-
t.string "name"
|
79
|
-
t.integer "seats"
|
80
|
-
t.integer "flight_fuel_type_id"
|
81
|
-
t.float "endpoint_fuel"
|
82
|
-
t.integer "flight_manufacturer_id"
|
83
|
-
t.datetime "updated_at"
|
84
|
-
t.datetime "created_at"
|
85
|
-
t.date "bts_begin_date"
|
86
|
-
t.date "bts_end_date"
|
87
|
-
t.float "load_factor"
|
88
|
-
t.float "freight_share"
|
89
|
-
t.float "m3"
|
90
|
-
t.float "m2"
|
91
|
-
t.float "m1"
|
92
|
-
t.float "distance"
|
93
|
-
t.float "payload"
|
94
|
-
t.integer "flight_aircraft_class_id"
|
95
|
-
t.float "multiplier"
|
96
|
-
t.string "manufacturer_name"
|
97
|
-
t.string "brighter_planet_aircraft_class_code"
|
98
|
-
t.integer "weighting"
|
99
|
-
t.integer "bts_aircraft_type"
|
100
|
-
end
|
101
|
-
|
102
|
-
create_table "flight_aircraft_classes", :force => true do |t|
|
103
|
-
t.string "name"
|
104
|
-
t.integer "seats"
|
105
|
-
t.integer "flight_fuel_type_id"
|
106
|
-
t.float "endpoint_fuel"
|
107
|
-
t.string "brighter_planet_aircraft_class_code"
|
108
|
-
t.float "m1"
|
109
|
-
t.float "m2"
|
110
|
-
t.float "m3"
|
111
|
-
end
|
112
|
-
|
113
|
-
create_table "flight_aircraft_seat_classes", :force => true do |t|
|
114
|
-
t.integer "flight_aircraft_id"
|
115
|
-
t.integer "flight_seat_class_id"
|
116
|
-
t.integer "seats"
|
117
|
-
t.datetime "created_at"
|
118
|
-
t.datetime "updated_at"
|
119
|
-
t.float "multiplier"
|
120
|
-
t.boolean "fresh"
|
121
|
-
end
|
122
|
-
|
123
|
-
create_table "flight_airline_aircraft", :force => true do |t|
|
124
|
-
t.integer "flight_airline_id"
|
125
|
-
t.integer "flight_aircraft_id"
|
126
|
-
t.integer "seats"
|
127
|
-
t.datetime "updated_at"
|
128
|
-
t.datetime "created_at"
|
129
|
-
t.float "total_seat_area"
|
130
|
-
t.float "average_seat_area"
|
131
|
-
t.boolean "fresh"
|
132
|
-
t.float "multiplier"
|
133
|
-
end
|
134
|
-
|
135
|
-
create_table "flight_airline_aircraft_seat_classes", :force => true do |t|
|
136
|
-
t.integer "seats"
|
137
|
-
t.float "pitch"
|
138
|
-
t.float "width"
|
139
|
-
t.float "multiplier"
|
140
|
-
t.datetime "created_at"
|
141
|
-
t.datetime "updated_at"
|
142
|
-
t.float "seat_area"
|
143
|
-
t.string "name"
|
144
|
-
t.integer "flight_airline_id"
|
145
|
-
t.integer "flight_aircraft_id"
|
146
|
-
t.integer "flight_seat_class_id"
|
147
|
-
t.integer "weighting"
|
148
|
-
t.integer "peers"
|
149
|
-
end
|
150
|
-
|
151
|
-
create_table "flight_airline_seat_classes", :force => true do |t|
|
152
|
-
t.integer "flight_seat_class_id"
|
153
|
-
t.integer "flight_airline_id"
|
154
|
-
t.float "multiplier"
|
155
|
-
t.datetime "created_at"
|
156
|
-
t.datetime "updated_at"
|
157
|
-
t.integer "seats"
|
158
|
-
t.boolean "fresh"
|
159
|
-
end
|
160
|
-
|
161
|
-
create_table "flight_airlines", :force => true do |t|
|
162
|
-
t.string "name"
|
163
|
-
t.string "iata"
|
164
|
-
t.string "us_dot_airline_id"
|
165
|
-
t.float "load_factor"
|
166
|
-
t.float "freight_share"
|
167
|
-
t.float "distance"
|
168
|
-
t.float "multiplier"
|
169
|
-
t.integer "seats"
|
170
|
-
t.float "payload"
|
171
|
-
t.boolean "international"
|
172
|
-
end
|
173
|
-
|
174
|
-
create_table "flight_configurations", :primary_key => "name", :id => false, :force => true do |t|
|
175
|
-
t.string 'name'
|
176
|
-
t.string "bts_aircraft_configuration_code"
|
177
|
-
t.datetime "created_at"
|
178
|
-
t.datetime "updated_at"
|
179
|
-
end
|
180
|
-
|
181
|
-
create_table "flight_distance_classes", :primary_key => "name", :id => false, :force => true do |t|
|
182
|
-
t.string 'name'
|
183
|
-
t.float "distance"
|
184
|
-
t.string "distance_units"
|
185
|
-
t.datetime "updated_at"
|
186
|
-
t.datetime "created_at"
|
187
|
-
end
|
188
|
-
|
189
|
-
create_table "flight_domesticities", :primary_key => "name", :id => false, :force => true do |t|
|
190
|
-
t.string 'name'
|
191
|
-
t.string "bts_data_source_code"
|
192
|
-
t.float "distance"
|
193
|
-
t.string "distance_units"
|
194
|
-
t.float "freight_share"
|
195
|
-
t.float "load_factor"
|
196
|
-
t.float "seats"
|
197
|
-
t.float "payload"
|
198
|
-
t.string "payload_units"
|
199
|
-
t.datetime "created_at"
|
200
|
-
t.datetime "updated_at"
|
201
|
-
end
|
202
|
-
|
203
|
-
create_table "flight_fuel_types", :force => true do |t|
|
204
|
-
t.string "name"
|
205
|
-
t.float "emission_factor"
|
206
|
-
t.float "radiative_forcing_index"
|
207
|
-
t.float "density"
|
208
|
-
t.datetime "created_at"
|
209
|
-
t.datetime "updated_at"
|
210
|
-
end
|
211
|
-
|
212
|
-
create_table "flight_manufacturers", :force => true do |t|
|
213
|
-
t.string "name"
|
214
|
-
t.datetime "created_at"
|
215
|
-
t.datetime "updated_at"
|
216
|
-
end
|
217
|
-
|
218
|
-
create_table "flight_patterns", :force => true do |t|
|
219
|
-
t.string "name"
|
220
|
-
t.integer "flight_id"
|
221
|
-
t.date "start_date"
|
222
|
-
t.date "end_date"
|
223
|
-
t.datetime "created_at"
|
224
|
-
t.datetime "updated_at"
|
225
|
-
t.float "monthly_flights"
|
226
|
-
t.integer "profile_id"
|
227
|
-
end
|
228
|
-
|
229
|
-
create_table "flight_propulsions", :primary_key => "name", :id => false, :force => true do |t|
|
230
|
-
t.string 'name'
|
231
|
-
t.string "bts_aircraft_group_code"
|
232
|
-
t.datetime "created_at"
|
233
|
-
t.datetime "updated_at"
|
234
|
-
end
|
235
|
-
|
236
|
-
create_table "flight_seat_classes", :primary_key => "name", :id => false, :force => true do |t|
|
237
|
-
t.string 'name'
|
238
|
-
t.float "multiplier"
|
239
|
-
t.integer "seats"
|
240
|
-
t.datetime "updated_at"
|
241
|
-
t.datetime "created_at"
|
242
|
-
end
|
243
|
-
|
244
|
-
create_table "flight_segments", :primary_key => "row_hash", :id => false, :force => true do |t|
|
245
|
-
t.string 'row_hash'
|
246
|
-
t.string "propulsion_id"
|
247
|
-
t.integer "bts_aircraft_group_code"
|
248
|
-
t.string "configuration_id"
|
249
|
-
t.integer "bts_aircraft_configuration_code"
|
250
|
-
t.string "distance_group"
|
251
|
-
t.integer "bts_distance_group_code"
|
252
|
-
t.string "service_class_id"
|
253
|
-
t.string "bts_service_class_code"
|
254
|
-
t.string "domesticity_id"
|
255
|
-
t.string "bts_data_source_code"
|
256
|
-
t.integer "departures_performed"
|
257
|
-
t.integer "payload"
|
258
|
-
t.integer "total_seats"
|
259
|
-
t.integer "passengers"
|
260
|
-
t.integer "freight"
|
261
|
-
t.integer "mail"
|
262
|
-
t.integer "ramp_to_ramp"
|
263
|
-
t.integer "air_time"
|
264
|
-
t.float "load_factor"
|
265
|
-
t.float "freight_share"
|
266
|
-
t.integer "distance"
|
267
|
-
t.integer "departures_scheduled"
|
268
|
-
t.string "airline_iata_code"
|
269
|
-
t.string "dot_airline_id_code"
|
270
|
-
t.string "unique_carrier_name"
|
271
|
-
t.string "unique_carrier_entity"
|
272
|
-
t.string "region"
|
273
|
-
t.string "current_airline_iata_code"
|
274
|
-
t.string "carrier_name"
|
275
|
-
t.integer "carrier_group"
|
276
|
-
t.integer "carrier_group_new"
|
277
|
-
t.string "origin_airport_iata_code"
|
278
|
-
t.string "origin_city_name"
|
279
|
-
t.integer "origin_city_num"
|
280
|
-
t.string "origin_state_abr"
|
281
|
-
t.string "origin_state_fips"
|
282
|
-
t.string "origin_state_nm"
|
283
|
-
t.string "origin_country_iso_3166_code"
|
284
|
-
t.string "origin_country_name"
|
285
|
-
t.integer "origin_wac"
|
286
|
-
t.string "dest_airport_iata_code"
|
287
|
-
t.string "dest_city_name"
|
288
|
-
t.integer "dest_city_num"
|
289
|
-
t.string "dest_state_abr"
|
290
|
-
t.string "dest_state_fips"
|
291
|
-
t.string "dest_state_nm"
|
292
|
-
t.string "dest_country_iso_3166_code"
|
293
|
-
t.string "dest_country_name"
|
294
|
-
t.integer "dest_wac"
|
295
|
-
t.integer "bts_aircraft_type_code"
|
296
|
-
t.integer "year"
|
297
|
-
t.integer "quarter"
|
298
|
-
t.integer "month"
|
299
|
-
t.float "seats"
|
300
|
-
t.string "payload_units"
|
301
|
-
t.string "freight_units"
|
302
|
-
t.string "mail_units"
|
303
|
-
t.string "distance_units"
|
304
|
-
t.datetime "created_at"
|
305
|
-
t.datetime "updated_at"
|
306
|
-
end
|
307
|
-
|
308
|
-
create_table "flight_services", :primary_key => "name", :id => false, :force => true do |t|
|
309
|
-
t.string 'name'
|
310
|
-
t.string "bts_service_class_code"
|
311
|
-
t.datetime "created_at"
|
312
|
-
t.datetime "updated_at"
|
313
|
-
end
|
314
|
-
|
315
4
|
create_table "flight_records", :force => true do |t|
|
316
5
|
t.date "date"
|
317
6
|
t.datetime "created_at"
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 19
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
9
|
+
- 6
|
10
|
+
version: 0.0.6
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Andy Rossmeissl
|
@@ -18,28 +19,33 @@ autorequire:
|
|
18
19
|
bindir: bin
|
19
20
|
cert_chain: []
|
20
21
|
|
21
|
-
date: 2010-07-
|
22
|
+
date: 2010-07-20 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: rake
|
29
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
28
31
|
requirements:
|
29
32
|
- - ">="
|
30
33
|
- !ruby/object:Gem::Version
|
34
|
+
hash: 3
|
31
35
|
segments:
|
32
36
|
- 0
|
33
37
|
version: "0"
|
34
|
-
|
35
|
-
version_requirements: *id001
|
38
|
+
requirement: *id001
|
36
39
|
- !ruby/object:Gem::Dependency
|
37
|
-
|
40
|
+
type: :development
|
38
41
|
prerelease: false
|
39
|
-
|
42
|
+
name: bundler
|
43
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
40
45
|
requirements:
|
41
46
|
- - ">="
|
42
47
|
- !ruby/object:Gem::Version
|
48
|
+
hash: 62196359
|
43
49
|
segments:
|
44
50
|
- 1
|
45
51
|
- 0
|
@@ -47,76 +53,119 @@ dependencies:
|
|
47
53
|
- beta
|
48
54
|
- 2
|
49
55
|
version: 1.0.0.beta.2
|
50
|
-
|
51
|
-
version_requirements: *id002
|
56
|
+
requirement: *id002
|
52
57
|
- !ruby/object:Gem::Dependency
|
53
|
-
|
58
|
+
type: :development
|
54
59
|
prerelease: false
|
55
|
-
|
60
|
+
name: jeweler
|
61
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
56
63
|
requirements:
|
57
64
|
- - "="
|
58
65
|
- !ruby/object:Gem::Version
|
66
|
+
hash: 7
|
59
67
|
segments:
|
60
68
|
- 1
|
61
69
|
- 4
|
62
70
|
- 0
|
63
71
|
version: 1.4.0
|
64
|
-
|
65
|
-
version_requirements: *id003
|
72
|
+
requirement: *id003
|
66
73
|
- !ruby/object:Gem::Dependency
|
67
|
-
|
74
|
+
type: :development
|
68
75
|
prerelease: false
|
69
|
-
|
76
|
+
name: cucumber
|
77
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
70
79
|
requirements:
|
71
80
|
- - "="
|
72
81
|
- !ruby/object:Gem::Version
|
82
|
+
hash: 57
|
73
83
|
segments:
|
74
84
|
- 0
|
75
85
|
- 8
|
76
86
|
- 3
|
77
87
|
version: 0.8.3
|
78
|
-
|
79
|
-
version_requirements: *id004
|
88
|
+
requirement: *id004
|
80
89
|
- !ruby/object:Gem::Dependency
|
81
|
-
|
90
|
+
type: :development
|
82
91
|
prerelease: false
|
83
|
-
|
92
|
+
name: rdoc
|
93
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
84
95
|
requirements:
|
85
96
|
- - ">="
|
86
97
|
- !ruby/object:Gem::Version
|
98
|
+
hash: 3
|
87
99
|
segments:
|
88
100
|
- 0
|
89
101
|
version: "0"
|
90
|
-
|
91
|
-
version_requirements: *id005
|
102
|
+
requirement: *id005
|
92
103
|
- !ruby/object:Gem::Dependency
|
93
|
-
|
104
|
+
type: :development
|
94
105
|
prerelease: false
|
95
|
-
|
106
|
+
name: rspec
|
107
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
96
109
|
requirements:
|
97
110
|
- - "="
|
98
111
|
- !ruby/object:Gem::Version
|
112
|
+
hash: 62196417
|
99
113
|
segments:
|
114
|
+
- 2
|
100
115
|
- 0
|
101
116
|
- 0
|
102
|
-
-
|
103
|
-
|
117
|
+
- beta
|
118
|
+
- 17
|
119
|
+
version: 2.0.0.beta.17
|
120
|
+
requirement: *id006
|
121
|
+
- !ruby/object:Gem::Dependency
|
104
122
|
type: :development
|
105
|
-
|
123
|
+
prerelease: false
|
124
|
+
name: sniff
|
125
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
126
|
+
none: false
|
127
|
+
requirements:
|
128
|
+
- - "="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
hash: 21
|
131
|
+
segments:
|
132
|
+
- 0
|
133
|
+
- 0
|
134
|
+
- 5
|
135
|
+
version: 0.0.5
|
136
|
+
requirement: *id007
|
106
137
|
- !ruby/object:Gem::Dependency
|
107
|
-
|
138
|
+
type: :runtime
|
108
139
|
prerelease: false
|
109
|
-
|
140
|
+
name: weighted_average
|
141
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
142
|
+
none: false
|
110
143
|
requirements:
|
111
144
|
- - "="
|
112
145
|
- !ruby/object:Gem::Version
|
146
|
+
hash: 23
|
113
147
|
segments:
|
114
148
|
- 0
|
115
149
|
- 0
|
116
150
|
- 4
|
117
151
|
version: 0.0.4
|
152
|
+
requirement: *id008
|
153
|
+
- !ruby/object:Gem::Dependency
|
118
154
|
type: :runtime
|
119
|
-
|
155
|
+
prerelease: false
|
156
|
+
name: earth
|
157
|
+
version_requirements: &id009 !ruby/object:Gem::Requirement
|
158
|
+
none: false
|
159
|
+
requirements:
|
160
|
+
- - "="
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
hash: 17
|
163
|
+
segments:
|
164
|
+
- 0
|
165
|
+
- 0
|
166
|
+
- 7
|
167
|
+
version: 0.0.7
|
168
|
+
requirement: *id009
|
120
169
|
description: A software model in Ruby for the greenhouse gas emissions of a flight
|
121
170
|
email: andy@rossmeissl.net
|
122
171
|
executables: []
|
@@ -134,21 +183,12 @@ files:
|
|
134
183
|
- lib/flight/characterization.rb
|
135
184
|
- lib/flight/data.rb
|
136
185
|
- lib/flight/summarization.rb
|
137
|
-
- lib/test_support/data_models/aircraft.rb
|
138
|
-
- lib/test_support/data_models/aircraft_class.rb
|
139
|
-
- lib/test_support/data_models/aircraft_manufacturer.rb
|
140
|
-
- lib/test_support/data_models/airline.rb
|
141
|
-
- lib/test_support/data_models/airport.rb
|
142
|
-
- lib/test_support/data_models/flight_configuration.rb
|
143
|
-
- lib/test_support/data_models/flight_distance_class.rb
|
144
|
-
- lib/test_support/data_models/flight_domesticity.rb
|
145
|
-
- lib/test_support/data_models/flight_fuel_type.rb
|
146
|
-
- lib/test_support/data_models/flight_propulsion.rb
|
147
|
-
- lib/test_support/data_models/flight_seat_class.rb
|
148
|
-
- lib/test_support/data_models/flight_segment.rb
|
149
|
-
- lib/test_support/data_models/flight_service.rb
|
150
186
|
- lib/test_support/db/schema.rb
|
151
187
|
- lib/test_support/flight_record.rb
|
188
|
+
- features/step_definitions/carbon_steps.rb
|
189
|
+
- features/support/env.rb
|
190
|
+
- features/flight_committees.feature
|
191
|
+
- features/flight_emissions.feature
|
152
192
|
has_rdoc: true
|
153
193
|
homepage: http://github.com/brighterplanet/flight
|
154
194
|
licenses: []
|
@@ -159,23 +199,27 @@ rdoc_options:
|
|
159
199
|
require_paths:
|
160
200
|
- lib
|
161
201
|
required_ruby_version: !ruby/object:Gem::Requirement
|
202
|
+
none: false
|
162
203
|
requirements:
|
163
204
|
- - ">="
|
164
205
|
- !ruby/object:Gem::Version
|
206
|
+
hash: 3
|
165
207
|
segments:
|
166
208
|
- 0
|
167
209
|
version: "0"
|
168
210
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
211
|
+
none: false
|
169
212
|
requirements:
|
170
213
|
- - ">="
|
171
214
|
- !ruby/object:Gem::Version
|
215
|
+
hash: 3
|
172
216
|
segments:
|
173
217
|
- 0
|
174
218
|
version: "0"
|
175
219
|
requirements: []
|
176
220
|
|
177
221
|
rubyforge_project:
|
178
|
-
rubygems_version: 1.3.
|
222
|
+
rubygems_version: 1.3.7
|
179
223
|
signing_key:
|
180
224
|
specification_version: 3
|
181
225
|
summary: A carbon model
|
@@ -184,18 +228,5 @@ test_files:
|
|
184
228
|
- features/support/env.rb
|
185
229
|
- features/flight_committees.feature
|
186
230
|
- features/flight_emissions.feature
|
187
|
-
- lib/test_support/data_models/aircraft.rb
|
188
|
-
- lib/test_support/data_models/aircraft_class.rb
|
189
|
-
- lib/test_support/data_models/aircraft_manufacturer.rb
|
190
|
-
- lib/test_support/data_models/airline.rb
|
191
|
-
- lib/test_support/data_models/airport.rb
|
192
|
-
- lib/test_support/data_models/flight_configuration.rb
|
193
|
-
- lib/test_support/data_models/flight_distance_class.rb
|
194
|
-
- lib/test_support/data_models/flight_domesticity.rb
|
195
|
-
- lib/test_support/data_models/flight_fuel_type.rb
|
196
|
-
- lib/test_support/data_models/flight_propulsion.rb
|
197
|
-
- lib/test_support/data_models/flight_seat_class.rb
|
198
|
-
- lib/test_support/data_models/flight_segment.rb
|
199
|
-
- lib/test_support/data_models/flight_service.rb
|
200
231
|
- lib/test_support/db/schema.rb
|
201
232
|
- lib/test_support/flight_record.rb
|
@@ -1,25 +0,0 @@
|
|
1
|
-
class Aircraft < ActiveRecord::Base
|
2
|
-
set_table_name 'aircraft'
|
3
|
-
set_primary_key :icao_code
|
4
|
-
|
5
|
-
belongs_to :aircraft_class, :foreign_key => 'brighter_planet_aircraft_class_code'
|
6
|
-
belongs_to :manufacturer, :foreign_key => 'manufacturer_name', :class_name => 'AircraftManufacturer'
|
7
|
-
has_many :segments, :foreign_key => 'bts_aircraft_type_code', :class_name => "FlightSegment", :primary_key => 'bts_aircraft_type_code'
|
8
|
-
|
9
|
-
falls_back_on :m3 => lambda { weighted_average(:m3, :weighted_by => [:segments, :passengers]) }, # 9.73423082858437e-08 r7110: 8.6540464368905e-8 r6972: 8.37e-8
|
10
|
-
:m2 => lambda { weighted_average(:m2, :weighted_by => [:segments, :passengers]) }, # -0.000134350543484608 r7110: -0.00015337661447817 r6972: -4.09e-5
|
11
|
-
:m1 => lambda { weighted_average(:m1, :weighted_by => [:segments, :passengers]) }, # 6.7728101555467 r7110: 4.7781966869412 r6972: 7.85
|
12
|
-
:endpoint_fuel => lambda { weighted_average(:endpoint_fuel, :weighted_by => [:segments, :passengers]) }, # 1527.81790006167 r7110: 1065.3476555284 r6972: 1.72e3
|
13
|
-
:seats => lambda { weighted_average(:seats, :weighted_by => [:segments, :passengers]) } # 62.1741
|
14
|
-
|
15
|
-
class << self
|
16
|
-
def loose_search_columns
|
17
|
-
@_loose_search_columns ||= [primary_key, :manufacturer_name, :name]
|
18
|
-
end
|
19
|
-
|
20
|
-
# search by name
|
21
|
-
def loose_right_reader
|
22
|
-
@_loose_right_reader ||= lambda { |record| record[1,2].join ' ' }
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
class Airline < ActiveRecord::Base
|
2
|
-
set_primary_key :iata_code
|
3
|
-
|
4
|
-
# has_many :airline_aircraft, :class_name => 'AirlineAircraft'
|
5
|
-
# has_many :seat_classes, :class_name => 'AirlineSeatClass'
|
6
|
-
has_many :segments, :class_name => "FlightSegment", :foreign_key => 'airline_iata_code'
|
7
|
-
# has_many :airline_aircraft_seat_classes, :class_name => 'AirlineAircraftSeatClass'
|
8
|
-
|
9
|
-
|
10
|
-
class << self
|
11
|
-
def loose_search_columns
|
12
|
-
@_loose_search_columns ||= [primary_key, :name]
|
13
|
-
end
|
14
|
-
|
15
|
-
# search by name
|
16
|
-
def loose_right_reader
|
17
|
-
@_loose_right_reader ||= lambda { |record| record[1] }
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def all_flights_domestic?
|
22
|
-
!international?
|
23
|
-
end
|
24
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
class Airport < ActiveRecord::Base
|
2
|
-
set_primary_key :iata_code
|
3
|
-
|
4
|
-
acts_as_mappable :default_units => :nms,
|
5
|
-
:lat_column_name => :latitude,
|
6
|
-
:lng_column_name => :longitude
|
7
|
-
|
8
|
-
class << self
|
9
|
-
def loose_search_columns
|
10
|
-
@_loose_search_columns ||= [primary_key, :city]
|
11
|
-
end
|
12
|
-
|
13
|
-
# search by name
|
14
|
-
def loose_right_reader
|
15
|
-
@_loose_right_reader ||= lambda { |record| record[1] }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def name_and_location
|
20
|
-
[ name.to_s.titleize, city, country.andand.name ].select(&:present?).join ', '
|
21
|
-
end
|
22
|
-
|
23
|
-
# --------------------------------
|
24
|
-
# virtual has_many association
|
25
|
-
# has_many :segments won't work because there's no general way to specify the correct conditions
|
26
|
-
# even if you get clever with it, like
|
27
|
-
# has_many :segments,
|
28
|
-
# :class_name => 'FlightSegment',
|
29
|
-
# :foreign_key => 'origin_airport_id',
|
30
|
-
# :conditions => 'flight_segments.destination_airport_id = #{id}'
|
31
|
-
# you get queries like "`flight_segments`.origin_airport_id = 3654 AND (flight_segments.destination_airport_id = 3654))"
|
32
|
-
# in which you notice the AND which must be an OR
|
33
|
-
# and you can't just do finder_sql, because that breaks any other :select
|
34
|
-
def segments
|
35
|
-
FlightSegment.scoped :conditions => ['origin_airport_id = ? OR destination_airport_id = ?', id, id]
|
36
|
-
end
|
37
|
-
# --------------------------------
|
38
|
-
|
39
|
-
belongs_to :country, :foreign_key => 'country_iso_3166_code'
|
40
|
-
|
41
|
-
def all_flights_from_here_domestic?
|
42
|
-
!international_origin?
|
43
|
-
end
|
44
|
-
|
45
|
-
def all_flights_to_here_domestic?
|
46
|
-
!international_destination?
|
47
|
-
end
|
48
|
-
|
49
|
-
def united_states?
|
50
|
-
country == Country.united_states
|
51
|
-
end
|
52
|
-
end
|
@@ -1,6 +0,0 @@
|
|
1
|
-
class FlightFuelType < ActiveRecord::Base
|
2
|
-
# this fallback is jet fuel
|
3
|
-
falls_back_on :emission_factor => (21.09.pounds.to(:kilograms) / 1.gallons.to(:litres)), # in pounds CO2/gallon fuel: http://www.eia.doe.gov/oiaf/1605/excel/Fuel%20Emission%20Factors.xls
|
4
|
-
:radiative_forcing_index => 2, # from Matt
|
5
|
-
:density => 3.057 # kg / gal
|
6
|
-
end
|
@@ -1,8 +0,0 @@
|
|
1
|
-
class FlightSeatClass < ActiveRecord::Base
|
2
|
-
set_primary_key :name
|
3
|
-
# has_many :airline_seat_classes, :class_name => 'AirlineSeatClass'
|
4
|
-
# has_many :aircraft_seat_classes, :class_name => 'AircraftSeatClass'
|
5
|
-
# has_many :airline_aircraft_seat_classes, :class_name => 'AirlineAircraftSeatClass'
|
6
|
-
|
7
|
-
falls_back_on :multiplier => 1
|
8
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
class FlightSegment < ActiveRecord::Base
|
2
|
-
set_primary_key :row_hash
|
3
|
-
|
4
|
-
extend CohortScope
|
5
|
-
self.minimum_cohort_size = 5 #FIXME ??
|
6
|
-
|
7
|
-
belongs_to :airline, :foreign_key => 'airline_iata_code'
|
8
|
-
belongs_to :origin_airport, :foreign_key => "origin_airport_iata_code", :class_name => 'Airport'
|
9
|
-
belongs_to :destination_airport, :foreign_key => "dest_airport_iata_code", :class_name => 'Airport'
|
10
|
-
belongs_to :origin_country, :foreign_key => 'origin_country_iso_3166_code', :class_name => 'Country'
|
11
|
-
belongs_to :destination_country, :foreign_key => 'dest_country_iso_3166_code', :class_name => 'Country'
|
12
|
-
belongs_to :aircraft, :foreign_key => 'bts_aircraft_type_code', :primary_key => 'bts_aircraft_type_code'
|
13
|
-
belongs_to :propulsion, :class_name => 'FlightPropulsion'
|
14
|
-
belongs_to :configuration, :class_name => 'FlightConfiguration'
|
15
|
-
belongs_to :service_class, :class_name => 'FlightService'
|
16
|
-
belongs_to :domesticity, :class_name => 'FlightDomesticity'
|
17
|
-
|
18
|
-
falls_back_on :load_factor => lambda { weighted_average(:load_factor, :weighted_by => :passengers) }, # 0.78222911236768
|
19
|
-
:freight_share => lambda { weighted_average(:freight_share, :weighted_by => :passengers) }, # 0.024017329363736
|
20
|
-
:seats => lambda { weighted_average :seats, :weighted_by => :passengers }
|
21
|
-
|
22
|
-
INPUT_CHARACTERISTICS = [
|
23
|
-
:origin_airport,
|
24
|
-
:destination_airport,
|
25
|
-
:aircraft,
|
26
|
-
:airline,
|
27
|
-
:propulsion,
|
28
|
-
:domesticity
|
29
|
-
]
|
30
|
-
end
|