flight 0.0.23 → 0.1.0
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 +619 -20
- data/README.markdown +4 -0
- data/README.rdoc +1 -1
- data/features/flight_committees.feature +311 -160
- data/features/flight_emissions.feature +101 -8
- data/features/support/env.rb +1 -1
- data/lib/flight.rb +0 -10
- data/lib/flight/carbon_model.rb +342 -153
- data/lib/flight/characterization.rb +18 -17
- data/lib/flight/data.rb +19 -18
- data/lib/flight/relationships.rb +17 -0
- data/lib/flight/summarization.rb +5 -2
- data/lib/test_support/flight_record.rb +4 -26
- metadata +48 -49
@@ -1,30 +1,31 @@
|
|
1
|
+
require 'characterizable'
|
2
|
+
|
1
3
|
module BrighterPlanet
|
2
4
|
module Flight
|
3
5
|
module Characterization
|
4
6
|
def self.included(base)
|
7
|
+
base.send :include, Characterizable
|
5
8
|
base.characterize do
|
6
|
-
has :
|
7
|
-
has :
|
8
|
-
has :
|
9
|
+
has :aviation_multiplier
|
10
|
+
has :distance_estimate, :trumps => :distance_class, :measures => :length, :precision => 0
|
11
|
+
has :distance_class
|
12
|
+
has :fuel_type
|
13
|
+
has :seats_estimate, :range => 1..500
|
14
|
+
has :load_factor, :measures => :percentage
|
15
|
+
has :trips
|
16
|
+
has :seat_class
|
17
|
+
has :country
|
18
|
+
has :date
|
9
19
|
has :origin_airport do |origin_airport|
|
10
20
|
origin_airport.reveals :destination_airport,
|
11
|
-
:trumps => [:distance_class, :
|
21
|
+
:trumps => [:distance_class, :distance_estimate, :country]
|
12
22
|
end
|
13
|
-
has :
|
14
|
-
has :
|
15
|
-
has :domesticity
|
23
|
+
has :aircraft, :trumps => [:aircraft_class, :seats_estimate, :fuel_type]
|
24
|
+
has :aircraft_class, :trumps => :fuel_type
|
16
25
|
has :airline
|
17
|
-
has :
|
18
|
-
has :emplanements_per_trip
|
19
|
-
has :seat_class
|
20
|
-
has :load_factor, :measures => :percentage
|
21
|
-
has :seats_estimate, :range => 1..500
|
22
|
-
has :aircraft_class, :trumps => [:propulsion, :fuel_type]
|
23
|
-
has :aircraft, :trumps => [:propulsion, :aircraft_class, :seats_estimate, :fuel_type]
|
24
|
-
has :propulsion, :trumps => :fuel_type
|
25
|
-
|
26
|
-
has :creation_date, :hidden => true
|
26
|
+
has :segments_per_trip
|
27
27
|
end
|
28
|
+
base.add_implicit_characteristics
|
28
29
|
end
|
29
30
|
end
|
30
31
|
end
|
data/lib/flight/data.rb
CHANGED
@@ -1,27 +1,28 @@
|
|
1
|
+
require 'data_miner'
|
2
|
+
|
1
3
|
module BrighterPlanet
|
2
4
|
module Flight
|
3
5
|
module Data
|
4
6
|
def self.included(base)
|
5
7
|
base.data_miner do
|
6
8
|
schema do
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
string
|
15
|
-
string
|
16
|
-
|
17
|
-
string
|
18
|
-
string
|
19
|
-
|
20
|
-
|
21
|
-
string
|
22
|
-
|
23
|
-
|
24
|
-
time 'time_of_day'
|
9
|
+
float 'aviation_multiplier'
|
10
|
+
float 'distance_estimate'
|
11
|
+
string 'distance_class_name'
|
12
|
+
string 'fuel_type_name'
|
13
|
+
integer 'seats_estimate'
|
14
|
+
float 'load_factor'
|
15
|
+
integer 'trips'
|
16
|
+
string 'seat_class_name'
|
17
|
+
string 'country_iso_3166_code'
|
18
|
+
date 'date'
|
19
|
+
string 'origin_airport_id'
|
20
|
+
string 'destination_airport_id'
|
21
|
+
string 'aircraft_icao_code'
|
22
|
+
string 'aircraft_class_brighter_planet_aircraft_class_code'
|
23
|
+
string 'airline_iata_code'
|
24
|
+
integer 'segments_per_trip'
|
25
|
+
float 'dogleg_factor'
|
25
26
|
end
|
26
27
|
|
27
28
|
process "pull orphans" do
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module BrighterPlanet
|
2
|
+
module Flight
|
3
|
+
module Relationships
|
4
|
+
def self.included(target)
|
5
|
+
target.belongs_to :distance_class, :class_name => 'FlightDistanceClass', :foreign_key => 'name'
|
6
|
+
target.belongs_to :fuel_type, :foreign_key => 'name'
|
7
|
+
target.belongs_to :seat_class, :class_name => 'FlightSeatClass', :foreign_key => 'name'
|
8
|
+
target.belongs_to :country, :foreign_key => 'iso_3166_code'
|
9
|
+
target.belongs_to :origin_airport, :class_name => 'Airport'
|
10
|
+
target.belongs_to :destination_airport, :class_name => 'Airport'
|
11
|
+
target.belongs_to :aircraft, :foreign_key => 'icao_code'
|
12
|
+
target.belongs_to :aircraft_class, :foreign_key => 'brighter_planet_aircraft_class_code'
|
13
|
+
target.belongs_to :airline, :foreign_key => 'iata_code'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/flight/summarization.rb
CHANGED
@@ -1,11 +1,14 @@
|
|
1
|
+
require 'summary_judgement'
|
2
|
+
|
1
3
|
module BrighterPlanet
|
2
4
|
module Flight
|
3
5
|
module Summarization
|
4
6
|
def self.included(base)
|
7
|
+
base.extend SummaryJudgement
|
5
8
|
base.summarize do |has|
|
6
9
|
has.adjective 'one-way', :if => lambda { |flight| flight.trips == 1 }
|
7
|
-
has.adjective 'round-trip', :if => lambda { |flight| flight.trips ==
|
8
|
-
has.adjective 'nonstop', :if => lambda { |flight| flight.
|
10
|
+
has.adjective 'round-trip', :if => lambda { |flight| flight.trips == 2 }
|
11
|
+
has.adjective 'nonstop', :if => lambda { |flight| flight.segments_per_trip == 1 }
|
9
12
|
has.identity 'flight'
|
10
13
|
has.modifier lambda { |flight| "from #{flight.origin_airport.name}" }, :if => :origin_airport
|
11
14
|
has.modifier lambda { |flight| "to #{flight.destination_airport.name}" }, :if => :destination_airport
|
@@ -8,30 +8,8 @@ class FlightRecord < ActiveRecord::Base
|
|
8
8
|
include BrighterPlanet::Flight
|
9
9
|
set_table_name 'flight_records'
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
belongs_to :propulsion, :class_name => 'FlightPropulsion'
|
16
|
-
belongs_to :aircraft_class
|
17
|
-
belongs_to :aircraft
|
18
|
-
belongs_to :seat_class, :class_name => 'FlightSeatClass'
|
19
|
-
belongs_to :airline
|
20
|
-
belongs_to :domesticity, :class_name => 'FlightDomesticity'
|
21
|
-
|
22
|
-
falls_back_on :trips => 1.941, # http://www.bts.gov/publications/america_on_the_go/long_distance_transportation_patterns/html/table_07.html
|
23
|
-
:emplanements_per_trip => 1.67,
|
24
|
-
:distance_estimate => 2077.4455,
|
25
|
-
:load_factor => lambda { FlightSegment.fallback.load_factor }
|
26
|
-
|
27
|
-
class << self
|
28
|
-
def research(key)
|
29
|
-
case key
|
30
|
-
when :route_inefficiency_factor
|
31
|
-
1.07
|
32
|
-
when :dogleg_factor
|
33
|
-
1.25
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
11
|
+
falls_back_on :aviation_multiplier => 2.0, # from Kolmuss and Crimmins (2009) http://sei-us.org/publications/id/13
|
12
|
+
:dogleg_factor => 1.25, # assumed
|
13
|
+
:trips => 1.941, # http://www.bts.gov/publications/america_on_the_go/long_distance_transportation_patterns/html/table_07.html
|
14
|
+
:segments_per_trip => 1.67 # calculated from http://nhts.ornl.gov/
|
37
15
|
end
|
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: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.23
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andy Rossmeissl
|
@@ -19,13 +19,14 @@ autorequire:
|
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
21
|
|
22
|
-
date: 2010-10-
|
22
|
+
date: 2010-10-20 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
|
- - ~>
|
@@ -36,12 +37,12 @@ dependencies:
|
|
36
37
|
- 0
|
37
38
|
- 0
|
38
39
|
version: 3.0.0
|
39
|
-
|
40
|
-
version_requirements: *id001
|
40
|
+
requirement: *id001
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
|
42
|
+
type: :development
|
43
43
|
prerelease: false
|
44
|
-
|
44
|
+
name: bundler
|
45
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
45
46
|
none: false
|
46
47
|
requirements:
|
47
48
|
- - ~>
|
@@ -52,31 +53,29 @@ dependencies:
|
|
52
53
|
- 0
|
53
54
|
- 0
|
54
55
|
version: 1.0.0
|
55
|
-
|
56
|
-
version_requirements: *id002
|
56
|
+
requirement: *id002
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
|
-
|
58
|
+
type: :development
|
59
59
|
prerelease: false
|
60
|
-
|
60
|
+
name: cucumber
|
61
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
61
62
|
none: false
|
62
63
|
requirements:
|
63
|
-
- - "
|
64
|
+
- - ">="
|
64
65
|
- !ruby/object:Gem::Version
|
65
|
-
hash:
|
66
|
+
hash: 3
|
66
67
|
segments:
|
67
68
|
- 0
|
68
|
-
|
69
|
-
|
70
|
-
version: 0.8.3
|
71
|
-
type: :development
|
72
|
-
version_requirements: *id003
|
69
|
+
version: "0"
|
70
|
+
requirement: *id003
|
73
71
|
- !ruby/object:Gem::Dependency
|
74
|
-
|
72
|
+
type: :development
|
75
73
|
prerelease: false
|
76
|
-
|
74
|
+
name: jeweler
|
75
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
77
76
|
none: false
|
78
77
|
requirements:
|
79
|
-
- -
|
78
|
+
- - ~>
|
80
79
|
- !ruby/object:Gem::Version
|
81
80
|
hash: 7
|
82
81
|
segments:
|
@@ -84,12 +83,12 @@ dependencies:
|
|
84
83
|
- 4
|
85
84
|
- 0
|
86
85
|
version: 1.4.0
|
87
|
-
|
88
|
-
version_requirements: *id004
|
86
|
+
requirement: *id004
|
89
87
|
- !ruby/object:Gem::Dependency
|
90
|
-
|
88
|
+
type: :development
|
91
89
|
prerelease: false
|
92
|
-
|
90
|
+
name: rake
|
91
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
93
92
|
none: false
|
94
93
|
requirements:
|
95
94
|
- - ">="
|
@@ -98,12 +97,12 @@ dependencies:
|
|
98
97
|
segments:
|
99
98
|
- 0
|
100
99
|
version: "0"
|
101
|
-
|
102
|
-
version_requirements: *id005
|
100
|
+
requirement: *id005
|
103
101
|
- !ruby/object:Gem::Dependency
|
104
|
-
|
102
|
+
type: :development
|
105
103
|
prerelease: false
|
106
|
-
|
104
|
+
name: rdoc
|
105
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
107
106
|
none: false
|
108
107
|
requirements:
|
109
108
|
- - ">="
|
@@ -112,12 +111,12 @@ dependencies:
|
|
112
111
|
segments:
|
113
112
|
- 0
|
114
113
|
version: "0"
|
115
|
-
|
116
|
-
version_requirements: *id006
|
114
|
+
requirement: *id006
|
117
115
|
- !ruby/object:Gem::Dependency
|
118
|
-
|
116
|
+
type: :development
|
119
117
|
prerelease: false
|
120
|
-
|
118
|
+
name: rspec
|
119
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
121
120
|
none: false
|
122
121
|
requirements:
|
123
122
|
- - "="
|
@@ -130,12 +129,12 @@ dependencies:
|
|
130
129
|
- beta
|
131
130
|
- 17
|
132
131
|
version: 2.0.0.beta.17
|
133
|
-
|
134
|
-
version_requirements: *id007
|
132
|
+
requirement: *id007
|
135
133
|
- !ruby/object:Gem::Dependency
|
136
|
-
|
134
|
+
type: :development
|
137
135
|
prerelease: false
|
138
|
-
|
136
|
+
name: sniff
|
137
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
139
138
|
none: false
|
140
139
|
requirements:
|
141
140
|
- - ~>
|
@@ -146,24 +145,23 @@ dependencies:
|
|
146
145
|
- 2
|
147
146
|
- 0
|
148
147
|
version: 0.2.0
|
149
|
-
|
150
|
-
version_requirements: *id008
|
148
|
+
requirement: *id008
|
151
149
|
- !ruby/object:Gem::Dependency
|
152
|
-
|
150
|
+
type: :runtime
|
153
151
|
prerelease: false
|
154
|
-
|
152
|
+
name: emitter
|
153
|
+
version_requirements: &id009 !ruby/object:Gem::Requirement
|
155
154
|
none: false
|
156
155
|
requirements:
|
157
156
|
- - ~>
|
158
157
|
- !ruby/object:Gem::Version
|
159
|
-
hash:
|
158
|
+
hash: 21
|
160
159
|
segments:
|
161
160
|
- 0
|
162
161
|
- 1
|
163
|
-
-
|
164
|
-
version: 0.1.
|
165
|
-
|
166
|
-
version_requirements: *id009
|
162
|
+
- 7
|
163
|
+
version: 0.1.7
|
164
|
+
requirement: *id009
|
167
165
|
description: A software model in Ruby for the greenhouse gas emissions of a flight
|
168
166
|
email: andy@rossmeissl.net
|
169
167
|
executables: []
|
@@ -181,6 +179,7 @@ files:
|
|
181
179
|
- lib/flight/carbon_model.rb
|
182
180
|
- lib/flight/characterization.rb
|
183
181
|
- lib/flight/data.rb
|
182
|
+
- lib/flight/relationships.rb
|
184
183
|
- lib/flight/summarization.rb
|
185
184
|
- lib/test_support/flight_record.rb
|
186
185
|
- README.markdown
|