earth 0.6.4 → 0.6.5
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/earth.gemspec +1 -1
- data/features/automobile_fuel.feature +144 -144
- data/features/automobile_make.feature +24 -24
- data/features/automobile_make_fleet_year.feature +34 -34
- data/features/automobile_make_model.feature +24 -24
- data/features/automobile_make_model_year.feature +34 -34
- data/features/automobile_make_model_year_variant.feature +46 -46
- data/features/automobile_make_year.feature +34 -34
- data/features/automobile_size_class.feature +59 -59
- data/features/automobile_size_class_year.feature +34 -34
- data/features/automobile_type_fuel_age.feature +55 -55
- data/features/automobile_type_fuel_control.feature +34 -34
- data/features/automobile_type_fuel_year.feature +124 -124
- data/features/automobile_type_fuel_year_age.feature +94 -94
- data/features/automobile_type_fuel_year_control.feature +74 -74
- data/features/automobile_type_year.feature +64 -64
- data/features/bus_class.feature +39 -39
- data/features/bus_fuel.feature +114 -114
- data/features/carrier.feature +64 -64
- data/features/carrier_mode.feature +64 -64
- data/features/computation_carrier.feature +14 -14
- data/features/computation_carrier_instance_class.feature +24 -24
- data/features/egrid_region.feature +20 -20
- data/features/egrid_subregion.feature +134 -134
- data/features/fuel_year.feature +54 -54
- data/features/greenhouse_gas.feature +44 -44
- data/features/rail_class.feature +64 -64
- data/features/shipment_mode.feature +34 -34
- data/lib/earth/air.rb +1 -0
- data/lib/earth/air/data_miner.rb +1 -0
- data/lib/earth/air/flight_distance_class.rb +10 -0
- data/lib/earth/air/flight_distance_class/data_miner.rb +18 -2
- data/lib/earth/air/flight_distance_class_seat_class.rb +10 -0
- data/lib/earth/air/flight_distance_class_seat_class/data_miner.rb +13 -0
- data/lib/earth/air/flight_seat_class.rb +6 -5
- data/lib/earth/air/flight_seat_class/data_miner.rb +18 -6
- data/lib/earth/version.rb +1 -1
- data/spec/earth_spec.rb +2 -2
- metadata +187 -173
data/features/fuel_year.feature
CHANGED
@@ -1,54 +1,54 @@
|
|
1
|
-
Feature: Data import for FuelYear
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
1
|
+
# Feature: Data import for FuelYear
|
2
|
+
# As a data user
|
3
|
+
# I want to import FuelYear data
|
4
|
+
# So that I can perform fuel year control-based calculations
|
5
|
+
#
|
6
|
+
# Scenario: Successfully verifying that fuel name is never missing
|
7
|
+
# Given a "FuelYear" data import fetches results listed in "fuel_year_good"
|
8
|
+
# When a data import verifies "Fuel name should never be missing"
|
9
|
+
# Then the verification should be successful
|
10
|
+
#
|
11
|
+
# Scenario: Successfully verifying that year is from 1990 to 2008
|
12
|
+
# Given a "FuelYear" data import fetches results listed in "fuel_year_good"
|
13
|
+
# When a data import verifies "Year should be from 1990 to 2008"
|
14
|
+
# Then the verification should be successful
|
15
|
+
#
|
16
|
+
# Scenario: Successfully verifying that carbon content and energy content are greater than zero
|
17
|
+
# Given a "FuelYear" data import fetches results listed in "fuel_year_good"
|
18
|
+
# When a data import verifies "Carbon content and energy content should be greater than zero"
|
19
|
+
# Then the verification should be successful
|
20
|
+
#
|
21
|
+
# Scenario: Successfully verifying that emission factors are zero or more
|
22
|
+
# Given a "FuelYear" data import fetches results listed in "fuel_year_good"
|
23
|
+
# When a data import verifies "Emission factors should be zero or more"
|
24
|
+
# Then the verification should be successful
|
25
|
+
#
|
26
|
+
# # Scenario: Successfully verifying that units are correct
|
27
|
+
# # Given a "FuelYear" data import fetches results listed in "fuel_year_good"
|
28
|
+
# # When a data import verifies "Units should be correct"
|
29
|
+
# # Then the verification should be successful
|
30
|
+
# #
|
31
|
+
# Scenario: Failing to verify that fuel name is never missing
|
32
|
+
# Given a "FuelYear" data import fetches results listed in "fuel_year_bad"
|
33
|
+
# When a data import verifies "Fuel name should never be missing"
|
34
|
+
# Then the verification should not be successful
|
35
|
+
#
|
36
|
+
# Scenario: Failing to verify that year is from 1990 to 2008
|
37
|
+
# Given a "FuelYear" data import fetches results listed in "fuel_year_bad"
|
38
|
+
# When a data import verifies "Year should be from 1990 to 2008"
|
39
|
+
# Then the verification should not be successful
|
40
|
+
#
|
41
|
+
# Scenario: Failing to verify that carbon content and energy content are greater than zero
|
42
|
+
# Given a "FuelYear" data import fetches results listed in "fuel_year_bad"
|
43
|
+
# When a data import verifies "Carbon content and energy content should be greater than zero"
|
44
|
+
# Then the verification should not be successful
|
45
|
+
#
|
46
|
+
# Scenario: Failing to verify that emission factors are zero or more
|
47
|
+
# Given a "FuelYear" data import fetches results listed in "fuel_year_bad"
|
48
|
+
# When a data import verifies "Emission factors should be zero or more"
|
49
|
+
# Then the verification should not be successful
|
50
|
+
#
|
51
|
+
# # Scenario: Failing to verify that units are correct
|
52
|
+
# # Given a "FuelYear" data import fetches results listed in "fuel_year_bad"
|
53
|
+
# # When a data import verifies "Units should be correct"
|
54
|
+
# # Then the verification should not be successful
|
@@ -1,44 +1,44 @@
|
|
1
|
-
Feature: Data import for GreenhouseGas
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
1
|
+
# Feature: Data import for GreenhouseGas
|
2
|
+
# As a data user
|
3
|
+
# I want to import GreenhouseGas data
|
4
|
+
# So that I can perform global warming potential-based calculations
|
5
|
+
#
|
6
|
+
# Scenario: Successfully verifying that abbreviation and IPCC report are never missing
|
7
|
+
# Given a "GreenhouseGas" data import fetches results listed in "greenhouse_gas_good"
|
8
|
+
# When a data import verifies "Abbreviation and IPCC report should never be missing"
|
9
|
+
# Then the verification should be successful
|
10
|
+
#
|
11
|
+
# Scenario: Successfully verifying that time horizon is 100
|
12
|
+
# Given a "GreenhouseGas" data import fetches results listed in "greenhouse_gas_good"
|
13
|
+
# When a data import verifies "Time horizon should be 100"
|
14
|
+
# Then the verification should be successful
|
15
|
+
#
|
16
|
+
# Scenario: Successfully verifying that time horizon units are years
|
17
|
+
# Given a "GreenhouseGas" data import fetches results listed in "greenhouse_gas_good"
|
18
|
+
# When a data import verifies "Time horizon units should be years"
|
19
|
+
# Then the verification should be successful
|
20
|
+
#
|
21
|
+
# Scenario: Successfully verifying that global warming potential is one or more
|
22
|
+
# Given a "GreenhouseGas" data import fetches results listed in "greenhouse_gas_good"
|
23
|
+
# When a data import verifies "Global warming potential should be one or more"
|
24
|
+
# Then the verification should be successful
|
25
|
+
#
|
26
|
+
# Scenario: Failing to verify that abbreviation and IPCC report are never missing
|
27
|
+
# Given a "GreenhouseGas" data import fetches results listed in "greenhouse_gas_bad"
|
28
|
+
# When a data import verifies "Abbreviation and IPCC report should never be missing"
|
29
|
+
# Then the verification should not be successful
|
30
|
+
#
|
31
|
+
# Scenario: Failing to verify that time horizon is 100
|
32
|
+
# Given a "GreenhouseGas" data import fetches results listed in "greenhouse_gas_bad"
|
33
|
+
# When a data import verifies "Time horizon should be 100"
|
34
|
+
# Then the verification should not be successful
|
35
|
+
#
|
36
|
+
# Scenario: Failing to verify that time horizon units are years
|
37
|
+
# Given a "GreenhouseGas" data import fetches results listed in "greenhouse_gas_bad"
|
38
|
+
# When a data import verifies "Time horizon units should be years"
|
39
|
+
# Then the verification should not be successful
|
40
|
+
#
|
41
|
+
# Scenario: Failing to verify that global warming potential is one or more
|
42
|
+
# Given a "GreenhouseGas" data import fetches results listed in "greenhouse_gas_bad"
|
43
|
+
# When a data import verifies "Global warming potential should be one or more"
|
44
|
+
# Then the verification should not be successful
|
data/features/rail_class.feature
CHANGED
@@ -1,64 +1,64 @@
|
|
1
|
-
Feature: Data import for RailClass
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
1
|
+
# Feature: Data import for RailClass
|
2
|
+
# As a data user
|
3
|
+
# I want to import RailClass data
|
4
|
+
# So that I can perform rail class-based calculations
|
5
|
+
#
|
6
|
+
# Scenario: Successfully verifying that passengers, distance, speed, and electricity intensity are greater than zero
|
7
|
+
# Given a "RailClass" data import fetches results listed in "rail_class_good"
|
8
|
+
# When a data import verifies "Passengers, distance, speed, and electricity intensity should be greater than zero"
|
9
|
+
# Then the verification should be successful
|
10
|
+
#
|
11
|
+
# Scenario: Successfully verifying that distance units are kilometres
|
12
|
+
# Given a "RailClass" data import fetches results listed in "rail_class_good"
|
13
|
+
# When a data import verifies "Distance units should be kilometres"
|
14
|
+
# Then the verification should be successful
|
15
|
+
#
|
16
|
+
# Scenario: Successfully verifying that speed units are kilometres per hour
|
17
|
+
# Given a "RailClass" data import fetches results listed in "rail_class_good"
|
18
|
+
# When a data import verifies "Speed units should be kilometres per hour"
|
19
|
+
# Then the verification should be successful
|
20
|
+
#
|
21
|
+
# Scenario: Successfully verifying that electricity intensity units are kilowatt hours per kilometre
|
22
|
+
# Given a "RailClass" data import fetches results listed in "rail_class_good"
|
23
|
+
# When a data import verifies "Electricity intensity units should be kilowatt hours per kilometre"
|
24
|
+
# Then the verification should be successful
|
25
|
+
#
|
26
|
+
# Scenario: Successfully verifying that diesel intensity is zero or more
|
27
|
+
# Given a "RailClass" data import fetches results listed in "rail_class_good"
|
28
|
+
# When a data import verifies "Diesel intensity should be zero or more"
|
29
|
+
# Then the verification should be successful
|
30
|
+
#
|
31
|
+
# Scenario: Successfully verifying that diesel intensity units are litres per kilometre
|
32
|
+
# Given a "RailClass" data import fetches results listed in "rail_class_good"
|
33
|
+
# When a data import verifies "Diesel intensity units should be litres per kilometre"
|
34
|
+
# Then the verification should be successful
|
35
|
+
#
|
36
|
+
# Scenario: Failing to verify that passengers, distance, speed, and electricity intensity are greater than zero
|
37
|
+
# Given a "RailClass" data import fetches results listed in "rail_class_bad"
|
38
|
+
# When a data import verifies "Passengers, distance, speed, and electricity intensity should be greater than zero"
|
39
|
+
# Then the verification should not be successful
|
40
|
+
#
|
41
|
+
# Scenario: Failing to verify that distance units are kilometres
|
42
|
+
# Given a "RailClass" data import fetches results listed in "rail_class_bad"
|
43
|
+
# When a data import verifies "Distance units should be kilometres"
|
44
|
+
# Then the verification should not be successful
|
45
|
+
#
|
46
|
+
# Scenario: Failing to verify that speed units are kilometres per hour
|
47
|
+
# Given a "RailClass" data import fetches results listed in "rail_class_bad"
|
48
|
+
# When a data import verifies "Speed units should be kilometres per hour"
|
49
|
+
# Then the verification should not be successful
|
50
|
+
#
|
51
|
+
# Scenario: Failing to verify that electricity intensity units are kilowatt hours per kilometre
|
52
|
+
# Given a "RailClass" data import fetches results listed in "rail_class_bad"
|
53
|
+
# When a data import verifies "Electricity intensity units should be kilowatt hours per kilometre"
|
54
|
+
# Then the verification should not be successful
|
55
|
+
#
|
56
|
+
# Scenario: Failing to verify that diesel intensity is zero or more
|
57
|
+
# Given a "RailClass" data import fetches results listed in "rail_class_bad"
|
58
|
+
# When a data import verifies "Diesel intensity should be zero or more"
|
59
|
+
# Then the verification should not be successful
|
60
|
+
#
|
61
|
+
# Scenario: Failing to verify that diesel intensity units are litres per kilometre
|
62
|
+
# Given a "RailClass" data import fetches results listed in "rail_class_bad"
|
63
|
+
# When a data import verifies "Diesel intensity units should be litres per kilometre"
|
64
|
+
# Then the verification should not be successful
|
@@ -1,34 +1,34 @@
|
|
1
|
-
Feature: Data import for ShipmentMode
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
1
|
+
# Feature: Data import for ShipmentMode
|
2
|
+
# As a data user
|
3
|
+
# I want to import ShipmentMode data
|
4
|
+
# So that I can perform shipment mode-based calculations
|
5
|
+
#
|
6
|
+
# Scenario: Successfully verifying that route inefficiency factor >= 1
|
7
|
+
# Given a "ShipmentMode" data import fetches results listed in "shipment_mode_good"
|
8
|
+
# When a data import verifies "Route inefficiency factor should be one or more"
|
9
|
+
# Then the verification should be successful
|
10
|
+
#
|
11
|
+
# Scenario: Failing to verify that route inefficiency factor >= 1
|
12
|
+
# Given a "ShipmentMode" data import fetches results listed in "shipment_mode_bad"
|
13
|
+
# When a data import verifies "Route inefficiency factor should be one or more"
|
14
|
+
# Then the verification should not be successful
|
15
|
+
#
|
16
|
+
# Scenario: Successfully verifying that transport emission factor > 0
|
17
|
+
# Given a "ShipmentMode" data import fetches results listed in "shipment_mode_good"
|
18
|
+
# When a data import verifies "Transport emission factor should be greater than zero"
|
19
|
+
# Then the verification should be successful
|
20
|
+
#
|
21
|
+
# Scenario: Failing to verify that transport emission factor > 0
|
22
|
+
# Given a "ShipmentMode" data import fetches results listed in "shipment_mode_bad"
|
23
|
+
# When a data import verifies "Transport emission factor should be greater than zero"
|
24
|
+
# Then the verification should not be successful
|
25
|
+
#
|
26
|
+
# Scenario: Successfully verifying that transport emission factor units is never missing
|
27
|
+
# Given a "ShipmentMode" data import fetches results listed in "shipment_mode_good"
|
28
|
+
# When a data import verifies "Transport emission factor units should never be missing"
|
29
|
+
# Then the verification should be successful
|
30
|
+
#
|
31
|
+
# Scenario: Failing to verify that transport emission factor units is never missing
|
32
|
+
# Given a "ShipmentMode" data import fetches results listed in "shipment_mode_bad"
|
33
|
+
# When a data import verifies "Transport emission factor units should never be missing"
|
34
|
+
# Then the verification should not be successful
|
data/lib/earth/air.rb
CHANGED
@@ -7,6 +7,7 @@ require 'earth/air/airline'
|
|
7
7
|
require 'earth/air/airport'
|
8
8
|
require 'earth/air/bts_aircraft'
|
9
9
|
require 'earth/air/flight_distance_class'
|
10
|
+
require 'earth/air/flight_distance_class_seat_class'
|
10
11
|
require 'earth/air/flight_seat_class'
|
11
12
|
require 'earth/air/flight_segment'
|
12
13
|
|
data/lib/earth/air/data_miner.rb
CHANGED
@@ -5,6 +5,7 @@ require 'earth/air/airline/data_miner'
|
|
5
5
|
require 'earth/air/airport/data_miner'
|
6
6
|
require 'earth/air/bts_aircraft/data_miner'
|
7
7
|
require 'earth/air/flight_distance_class/data_miner'
|
8
|
+
require 'earth/air/flight_distance_class_seat_class/data_miner'
|
8
9
|
require 'earth/air/flight_seat_class/data_miner'
|
9
10
|
require 'earth/air/flight_segment/data_miner'
|
10
11
|
|
@@ -1,6 +1,16 @@
|
|
1
1
|
class FlightDistanceClass < ActiveRecord::Base
|
2
2
|
set_primary_key :name
|
3
|
+
|
4
|
+
def self.find_by_distance(distance)
|
5
|
+
FlightDistanceClass.where('min_distance <= ? AND max_distance > ?', distance, distance)[0]
|
6
|
+
end
|
7
|
+
|
3
8
|
col :name
|
4
9
|
col :distance, :type => :float
|
5
10
|
col :distance_units
|
11
|
+
col :min_distance, :type => :float
|
12
|
+
col :min_distance_units
|
13
|
+
col :max_distance, :type => :float
|
14
|
+
col :max_distance_units
|
15
|
+
col :passengers, :type => :float
|
6
16
|
end
|
@@ -1,9 +1,25 @@
|
|
1
1
|
FlightDistanceClass.class_eval do
|
2
2
|
data_miner do
|
3
|
-
import "
|
3
|
+
import "distance classes from the WRI business travel tool and UK DEFRA/DECC GHG Conversion Factors for Company Reporting",
|
4
4
|
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdFBKM0xWaUhKVkxDRmdBVkE3VklxY2c&hl=en&gid=0&output=csv' do
|
5
5
|
key 'name'
|
6
|
-
store 'distance',
|
6
|
+
store 'distance', :units_field_name => 'distance_units'
|
7
|
+
store 'min_distance', :units_field_name => 'min_distance_units', :nullify => true
|
8
|
+
store 'max_distance', :units_field_name => 'max_distance_units', :nullify => true
|
9
|
+
end
|
10
|
+
|
11
|
+
# FIXME TODO verify that min_distance >= 0
|
12
|
+
# FIXME TODO verify that max_distance > 0
|
13
|
+
# FIXME TODO verify that distance class distance bounds don't overlap
|
14
|
+
|
15
|
+
process "Ensure FlightSegment is populated" do
|
16
|
+
FlightSegment.run_data_miner!
|
17
|
+
end
|
18
|
+
|
19
|
+
process "Calculate passengers for each distance class" do
|
20
|
+
FlightDistanceClass.find_each do |distance_class|
|
21
|
+
distance_class.passengers = FlightSegment.where('distance >= ? AND distance < ?', distance_class.min_distance, distance_class.max_distance).sum(:passengers)
|
22
|
+
end
|
7
23
|
end
|
8
24
|
|
9
25
|
# FIXME TODO verify this
|