earth 0.3.14 → 0.3.15
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
CHANGED
|
@@ -4,8 +4,8 @@ require "earth/version"
|
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new do |s|
|
|
6
6
|
s.name = "earth"
|
|
7
|
-
s.version
|
|
8
|
-
s.date = "2011-01-
|
|
7
|
+
s.version = "0.3.15"
|
|
8
|
+
s.date = "2011-01-28"
|
|
9
9
|
s.platform = Gem::Platform::RUBY
|
|
10
10
|
s.authors = ["Seamus Abshere", "Derek Kastner", "Andy Rossmeissl"]
|
|
11
11
|
s.email = %q{andy@rossmeissl.net}
|
|
@@ -2,12 +2,16 @@ FlightSeatClass.class_eval do
|
|
|
2
2
|
data_miner do
|
|
3
3
|
schema Earth.database_options do
|
|
4
4
|
string 'name'
|
|
5
|
+
string 'distance_class_name'
|
|
6
|
+
string 'seat_class_name'
|
|
5
7
|
float 'multiplier'
|
|
6
8
|
end
|
|
7
9
|
|
|
8
10
|
import "a list of Brighter Planet-defined seat classes and pre-calculated multipliers",
|
|
9
11
|
:url => 'https://spreadsheets.google.com/pub?key=0AoQJbWqPrREqdG5zSER1QmFVVkhNcTM2cmhCMEJtWVE&hl=en&single=true&gid=0&output=csv' do
|
|
10
12
|
key 'name'
|
|
13
|
+
store 'distance_class_name'
|
|
14
|
+
store 'seat_class_name'
|
|
11
15
|
store 'multiplier'
|
|
12
16
|
end
|
|
13
17
|
|
|
@@ -46,9 +46,9 @@ AutomobileFuelType.class_eval do
|
|
|
46
46
|
fuel_types = AutomobileFuelType.arel_table
|
|
47
47
|
|
|
48
48
|
AutomobileFuelType.all.each do |fuel_type|
|
|
49
|
-
current_name = fuel_type.
|
|
49
|
+
current_name = fuel_type.name
|
|
50
50
|
|
|
51
|
-
if
|
|
51
|
+
if fuel_type.fuel_name_for_efs.present?
|
|
52
52
|
co2_factor_sql = fuel_years.project(fuel_years[:co2_emission_factor]).where(fuel_years[:fuel_common_name].eq(fuel_types[:fuel_name_for_efs]).and(fuel_years[:year].eq(latest_year))).to_sql
|
|
53
53
|
ch4_factor_sql = AutomobileTypeFuelYear.weighted_average_relation(:ch4_emission_factor, :weighted_by => :total_travel).where(type_fuel_years[:fuel_common_name].eq(fuel_types[:fuel_name_for_efs]).and(type_fuel_years[:year].eq(latest_year))).to_sql
|
|
54
54
|
n2o_factor_sql = AutomobileTypeFuelYear.weighted_average_relation(:n2o_emission_factor, :weighted_by => :total_travel).where(type_fuel_years[:fuel_common_name].eq(fuel_types[:fuel_name_for_efs]).and(type_fuel_years[:year].eq(latest_year))).to_sql
|
|
@@ -57,12 +57,12 @@ AutomobileFuelType.class_eval do
|
|
|
57
57
|
connection.execute %{
|
|
58
58
|
UPDATE automobile_fuel_types
|
|
59
59
|
SET emission_factor = (((#{co2_factor_sql}) * #{co2_gwp} * (1 - blend_portion)) + ((#{ch4_factor_sql}) * #{ch4_gwp}) + ((#{n2o_factor_sql}) * #{n2o_gwp}) + (#{hfc_factor_sql}))
|
|
60
|
-
WHERE automobile_fuel_types.
|
|
60
|
+
WHERE automobile_fuel_types.name = '#{current_name}'
|
|
61
61
|
}
|
|
62
62
|
connection.execute %{
|
|
63
63
|
UPDATE automobile_fuel_types
|
|
64
64
|
SET emission_factor_units = 'kilograms_co2e_per_litre'
|
|
65
|
-
WHERE automobile_fuel_types.
|
|
65
|
+
WHERE automobile_fuel_types.name = '#{current_name}'
|
|
66
66
|
}
|
|
67
67
|
end
|
|
68
68
|
end
|
|
@@ -77,6 +77,11 @@ AutomobileFuelType.class_eval do
|
|
|
77
77
|
SET emission_factor = #{electricity_ef}
|
|
78
78
|
WHERE automobile_fuel_types.name = 'electricity'
|
|
79
79
|
}
|
|
80
|
+
connection.execute %{
|
|
81
|
+
UPDATE automobile_fuel_types
|
|
82
|
+
SET emission_factor_units = 'kilograms_co2e_per_kilowatt_hour'
|
|
83
|
+
WHERE automobile_fuel_types.name = 'electricity'
|
|
84
|
+
}
|
|
80
85
|
end
|
|
81
86
|
|
|
82
87
|
verify "Annual distance and emission factor should be greater than zero" do
|
|
@@ -438,7 +438,8 @@ AutomobileMakeModelYearVariant.class_eval do
|
|
|
438
438
|
update_all "make_model_year_name = CONCAT(make_name, ' ', name, ' ', year)"
|
|
439
439
|
end
|
|
440
440
|
|
|
441
|
-
|
|
441
|
+
# Note: need to divide by 0.425143707 b/c equation is designed for miles / gallon not km / l
|
|
442
|
+
process "Calculate adjusted fuel efficiency using the latest EPA equations from EPA Fuel Economy Trends report Appendix A including conversion from miles per gallon to kilometres per litre" do
|
|
442
443
|
update_all 'fuel_efficiency_city = 1 / ((0.003259 / 0.425143707) + (1.1805 / raw_fuel_efficiency_city))'
|
|
443
444
|
update_all 'fuel_efficiency_highway = 1 / ((0.001376 / 0.425143707) + (1.3466 / raw_fuel_efficiency_highway))'
|
|
444
445
|
end
|
data/lib/earth/inflectors.rb
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
ActiveSupport::Inflector.inflections do |inflect|
|
|
2
|
-
inflect.uncountable
|
|
2
|
+
inflect.uncountable 'aircraft'
|
|
3
3
|
inflect.uncountable 'commons'
|
|
4
4
|
inflect.uncountable 'food'
|
|
5
5
|
inflect.uncountable 'shelter'
|
|
6
6
|
inflect.uncountable 'transportation'
|
|
7
|
-
inflect.uncountable '
|
|
7
|
+
inflect.uncountable 'species'
|
|
8
8
|
inflect.irregular 'foot', 'feet'
|
|
9
|
+
inflect.plural /(gas)\z/i, '\1es'
|
|
10
|
+
inflect.singular /(gas)es\z/i, '\1'
|
|
9
11
|
end
|
metadata
CHANGED
|
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
|
5
5
|
segments:
|
|
6
6
|
- 0
|
|
7
7
|
- 3
|
|
8
|
-
-
|
|
9
|
-
version: 0.3.
|
|
8
|
+
- 15
|
|
9
|
+
version: 0.3.15
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Seamus Abshere
|
|
@@ -16,7 +16,7 @@ autorequire:
|
|
|
16
16
|
bindir: bin
|
|
17
17
|
cert_chain: []
|
|
18
18
|
|
|
19
|
-
date: 2011-01-
|
|
19
|
+
date: 2011-01-28 00:00:00 -05:00
|
|
20
20
|
default_executable:
|
|
21
21
|
dependencies:
|
|
22
22
|
- !ruby/object:Gem::Dependency
|
|
@@ -507,7 +507,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
507
507
|
requirements:
|
|
508
508
|
- - ">="
|
|
509
509
|
- !ruby/object:Gem::Version
|
|
510
|
-
hash:
|
|
510
|
+
hash: -661468781
|
|
511
511
|
segments:
|
|
512
512
|
- 0
|
|
513
513
|
version: "0"
|
|
@@ -516,7 +516,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
516
516
|
requirements:
|
|
517
517
|
- - ">="
|
|
518
518
|
- !ruby/object:Gem::Version
|
|
519
|
-
hash:
|
|
519
|
+
hash: -661468781
|
|
520
520
|
segments:
|
|
521
521
|
- 0
|
|
522
522
|
version: "0"
|