earth 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -22,3 +22,4 @@ log
22
22
 
23
23
  ## PROJECT::SPECIFIC
24
24
  Gemfile.lock
25
+ *.gem
data/Gemfile CHANGED
@@ -1,7 +1,3 @@
1
- gem 'data_miner', :path => ENV['LOCAL_DATA_MINER'] if ENV['LOCAL_DATA_MINER']
2
- gem 'mini_record', :path => ENV['LOCAL_MINI_RECORD'] if ENV['LOCAL_MINI_RECORD']
3
- gem 'force_schema', :path => ENV['LOCAL_FORCE_SCHEMA'] if ENV['LOCAL_FORCE_SCHEMA']
4
-
5
1
  source :rubygems
6
2
 
7
3
  gemspec :path => '.'
data/TODO CHANGED
@@ -1,2 +1,3 @@
1
1
  * convert former/current verify blocks into table_warnings warn {...} blocks
2
2
  * convert tests to minitest
3
+ * fix residence fuel price locatable stuff
@@ -37,7 +37,7 @@ Gem::Specification.new do |s|
37
37
  s.add_runtime_dependency 'geokit-rails'
38
38
  s.add_runtime_dependency 'loose_tight_dictionary', '>=0.2.3'
39
39
  s.add_runtime_dependency 'weighted_average', '>=1'
40
- # s.add_runtime_dependency 'mini_record' # need https://github.com/DAddYE/mini_record/pull/7 - for now install manually from https://github.com/seamusabshere/mini_record
40
+ s.add_runtime_dependency 'mini_record-compat' # need https://github.com/DAddYE/mini_record/pull/7
41
41
  s.add_runtime_dependency 'activesupport'
42
42
  s.add_runtime_dependency 'activerecord'
43
43
  s.add_development_dependency 'bundler'
@@ -72,7 +72,7 @@ module Earth
72
72
  options = args.last.is_a?(Hash) ? args.pop.symbolize_keys : {}
73
73
  domains = args.empty? ? [ :all ] : args.map(&:to_sym)
74
74
 
75
- _configure_database_connection
75
+ _warn_unless_mysql_ansi_mode
76
76
  _load_plugins
77
77
  _load_domains domains, options
78
78
  _decorate_resources options
@@ -81,9 +81,10 @@ module Earth
81
81
 
82
82
  private
83
83
 
84
- def _configure_database_connection
84
+ def _warn_unless_mysql_ansi_mode
85
85
  if ActiveRecord::Base.connection.adapter_name =~ /mysql/i
86
- ActiveRecord::Base.connection.execute("SET SQL_MODE = 'PIPES_AS_CONCAT'")
86
+ sql_mode = ActiveRecord::Base.connection.select_value("SELECT @@GLOBAL.sql_mode") + ActiveRecord::Base.connection.select_value("SELECT @@SESSION.sql_mode")
87
+ $stderr.puts "[earth gem] Warning: MySQL detected, but PIPES_AS_CONCAT not set. Importing from scratch will fail. Consider setting sql-mode=ANSI in my.cnf." unless sql_mode =~ /pipes_as_concat/i
87
88
  end
88
89
  end
89
90
 
@@ -107,10 +107,11 @@ AutomobileTypeFuelYearAge.class_eval do
107
107
  end
108
108
 
109
109
  process "Calculate number of vehicles from total travel percent and AutomobileTypeFuelYear" do
110
- AutomobileTypeFuelYearAge.all.each do |record|
111
- record.vehicles = record.total_travel_percent * record.type_fuel_year.total_travel / record.annual_distance
112
- record.save
113
- end
110
+ total_travel = "(SELECT t1.total_travel FROM #{AutomobileTypeFuelYear.quoted_table_name} AS t1 WHERE t1.name = #{quoted_table_name}.type_fuel_year_name)"
111
+ update_all(
112
+ %{vehicles = total_travel_percent * #{total_travel} / annual_distance},
113
+ %{annual_distance > 0}
114
+ )
114
115
  end
115
116
  end
116
117
  end
@@ -12,12 +12,16 @@ AutomobileTypeYear.class_eval do
12
12
  AutomobileTypeFuelYear.run_data_miner!
13
13
  end
14
14
 
15
+ process "Set units" do
16
+ update_all :hfc_emission_factor_units => 'kilograms_co2e_per_litre'
17
+ end
18
+
15
19
  process "Calculate HFC emission factor from AutomobileTypeFuelYear" do
16
- AutomobileTypeYear.all.each do |record|
17
- record.hfc_emission_factor = record.hfc_emissions / record.type_fuel_years.sum('fuel_consumption')
18
- record.hfc_emission_factor_units = "kilograms_co2e_per_litre"
19
- record.save
20
- end
20
+ total_fuel_consumption = "(SELECT SUM(src.fuel_consumption) FROM #{AutomobileTypeFuelYear.quoted_table_name} AS src WHERE src.type_year_name = #{quoted_table_name}.name)"
21
+ update_all(
22
+ %{hfc_emission_factor = hfc_emissions / #{total_fuel_consumption}},
23
+ %{#{total_fuel_consumption} > 0}
24
+ )
21
25
  end
22
26
  end
23
27
  end
@@ -1,3 +1,3 @@
1
1
  module Earth
2
- VERSION = "0.6.0"
2
+ VERSION = "0.6.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: earth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -15,7 +15,7 @@ date: 2011-06-06 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: data_miner
18
- requirement: &2168455600 !ruby/object:Gem::Requirement
18
+ requirement: &2154695800 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: '1.3'
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *2168455600
26
+ version_requirements: *2154695800
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: to_regexp
29
- requirement: &2168455180 !ruby/object:Gem::Requirement
29
+ requirement: &2164269760 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: '0'
35
35
  type: :runtime
36
36
  prerelease: false
37
- version_requirements: *2168455180
37
+ version_requirements: *2164269760
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: cohort_scope
40
- requirement: &2161928740 !ruby/object:Gem::Requirement
40
+ requirement: &2164269300 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ! '>='
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: '0'
46
46
  type: :runtime
47
47
  prerelease: false
48
- version_requirements: *2161928740
48
+ version_requirements: *2164269300
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: table_warnings
51
- requirement: &2161928240 !ruby/object:Gem::Requirement
51
+ requirement: &2164268800 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ! '>='
@@ -56,10 +56,10 @@ dependencies:
56
56
  version: 0.0.6
57
57
  type: :runtime
58
58
  prerelease: false
59
- version_requirements: *2161928240
59
+ version_requirements: *2164268800
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: remote_table
62
- requirement: &2161927740 !ruby/object:Gem::Requirement
62
+ requirement: &2164268300 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ! '>='
@@ -67,10 +67,10 @@ dependencies:
67
67
  version: 1.2.3
68
68
  type: :runtime
69
69
  prerelease: false
70
- version_requirements: *2161927740
70
+ version_requirements: *2164268300
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: falls_back_on
73
- requirement: &2161927360 !ruby/object:Gem::Requirement
73
+ requirement: &2164267920 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
76
  - - ! '>='
@@ -78,10 +78,10 @@ dependencies:
78
78
  version: '0'
79
79
  type: :runtime
80
80
  prerelease: false
81
- version_requirements: *2161927360
81
+ version_requirements: *2164267920
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: fixed_width-multibyte
84
- requirement: &2161926900 !ruby/object:Gem::Requirement
84
+ requirement: &2164267460 !ruby/object:Gem::Requirement
85
85
  none: false
86
86
  requirements:
87
87
  - - ! '>='
@@ -89,10 +89,10 @@ dependencies:
89
89
  version: '0'
90
90
  type: :runtime
91
91
  prerelease: false
92
- version_requirements: *2161926900
92
+ version_requirements: *2164267460
93
93
  - !ruby/object:Gem::Dependency
94
94
  name: geokit-rails
95
- requirement: &2161926480 !ruby/object:Gem::Requirement
95
+ requirement: &2164267040 !ruby/object:Gem::Requirement
96
96
  none: false
97
97
  requirements:
98
98
  - - ! '>='
@@ -100,10 +100,10 @@ dependencies:
100
100
  version: '0'
101
101
  type: :runtime
102
102
  prerelease: false
103
- version_requirements: *2161926480
103
+ version_requirements: *2164267040
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: loose_tight_dictionary
106
- requirement: &2161925980 !ruby/object:Gem::Requirement
106
+ requirement: &2164266540 !ruby/object:Gem::Requirement
107
107
  none: false
108
108
  requirements:
109
109
  - - ! '>='
@@ -111,10 +111,10 @@ dependencies:
111
111
  version: 0.2.3
112
112
  type: :runtime
113
113
  prerelease: false
114
- version_requirements: *2161925980
114
+ version_requirements: *2164266540
115
115
  - !ruby/object:Gem::Dependency
116
116
  name: weighted_average
117
- requirement: &2161925480 !ruby/object:Gem::Requirement
117
+ requirement: &2164266040 !ruby/object:Gem::Requirement
118
118
  none: false
119
119
  requirements:
120
120
  - - ! '>='
@@ -122,10 +122,21 @@ dependencies:
122
122
  version: '1'
123
123
  type: :runtime
124
124
  prerelease: false
125
- version_requirements: *2161925480
125
+ version_requirements: *2164266040
126
+ - !ruby/object:Gem::Dependency
127
+ name: mini_record-compat
128
+ requirement: &2164265660 !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :runtime
135
+ prerelease: false
136
+ version_requirements: *2164265660
126
137
  - !ruby/object:Gem::Dependency
127
138
  name: activesupport
128
- requirement: &2161925100 !ruby/object:Gem::Requirement
139
+ requirement: &2164265200 !ruby/object:Gem::Requirement
129
140
  none: false
130
141
  requirements:
131
142
  - - ! '>='
@@ -133,10 +144,10 @@ dependencies:
133
144
  version: '0'
134
145
  type: :runtime
135
146
  prerelease: false
136
- version_requirements: *2161925100
147
+ version_requirements: *2164265200
137
148
  - !ruby/object:Gem::Dependency
138
149
  name: activerecord
139
- requirement: &2161924640 !ruby/object:Gem::Requirement
150
+ requirement: &2164264780 !ruby/object:Gem::Requirement
140
151
  none: false
141
152
  requirements:
142
153
  - - ! '>='
@@ -144,10 +155,10 @@ dependencies:
144
155
  version: '0'
145
156
  type: :runtime
146
157
  prerelease: false
147
- version_requirements: *2161924640
158
+ version_requirements: *2164264780
148
159
  - !ruby/object:Gem::Dependency
149
160
  name: bundler
150
- requirement: &2161924220 !ruby/object:Gem::Requirement
161
+ requirement: &2164264360 !ruby/object:Gem::Requirement
151
162
  none: false
152
163
  requirements:
153
164
  - - ! '>='
@@ -155,10 +166,10 @@ dependencies:
155
166
  version: '0'
156
167
  type: :development
157
168
  prerelease: false
158
- version_requirements: *2161924220
169
+ version_requirements: *2164264360
159
170
  - !ruby/object:Gem::Dependency
160
171
  name: bueller
161
- requirement: &2161923800 !ruby/object:Gem::Requirement
172
+ requirement: &2164263940 !ruby/object:Gem::Requirement
162
173
  none: false
163
174
  requirements:
164
175
  - - ! '>='
@@ -166,10 +177,10 @@ dependencies:
166
177
  version: '0'
167
178
  type: :development
168
179
  prerelease: false
169
- version_requirements: *2161923800
180
+ version_requirements: *2164263940
170
181
  - !ruby/object:Gem::Dependency
171
182
  name: cucumber
172
- requirement: &2161923380 !ruby/object:Gem::Requirement
183
+ requirement: &2164263520 !ruby/object:Gem::Requirement
173
184
  none: false
174
185
  requirements:
175
186
  - - ! '>='
@@ -177,10 +188,10 @@ dependencies:
177
188
  version: '0'
178
189
  type: :development
179
190
  prerelease: false
180
- version_requirements: *2161923380
191
+ version_requirements: *2164263520
181
192
  - !ruby/object:Gem::Dependency
182
193
  name: rake
183
- requirement: &2161922960 !ruby/object:Gem::Requirement
194
+ requirement: &2164263100 !ruby/object:Gem::Requirement
184
195
  none: false
185
196
  requirements:
186
197
  - - ! '>='
@@ -188,10 +199,10 @@ dependencies:
188
199
  version: '0'
189
200
  type: :development
190
201
  prerelease: false
191
- version_requirements: *2161922960
202
+ version_requirements: *2164263100
192
203
  - !ruby/object:Gem::Dependency
193
204
  name: rdoc
194
- requirement: &2161922540 !ruby/object:Gem::Requirement
205
+ requirement: &2164262680 !ruby/object:Gem::Requirement
195
206
  none: false
196
207
  requirements:
197
208
  - - ! '>='
@@ -199,10 +210,10 @@ dependencies:
199
210
  version: '0'
200
211
  type: :development
201
212
  prerelease: false
202
- version_requirements: *2161922540
213
+ version_requirements: *2164262680
203
214
  - !ruby/object:Gem::Dependency
204
215
  name: rspec
205
- requirement: &2161922120 !ruby/object:Gem::Requirement
216
+ requirement: &2164262260 !ruby/object:Gem::Requirement
206
217
  none: false
207
218
  requirements:
208
219
  - - ! '>='
@@ -210,10 +221,10 @@ dependencies:
210
221
  version: '0'
211
222
  type: :development
212
223
  prerelease: false
213
- version_requirements: *2161922120
224
+ version_requirements: *2164262260
214
225
  - !ruby/object:Gem::Dependency
215
226
  name: sqlite3-ruby
216
- requirement: &2161921700 !ruby/object:Gem::Requirement
227
+ requirement: &2164261840 !ruby/object:Gem::Requirement
217
228
  none: false
218
229
  requirements:
219
230
  - - ! '>='
@@ -221,10 +232,10 @@ dependencies:
221
232
  version: '0'
222
233
  type: :development
223
234
  prerelease: false
224
- version_requirements: *2161921700
235
+ version_requirements: *2164261840
225
236
  - !ruby/object:Gem::Dependency
226
237
  name: mysql
227
- requirement: &2161921280 !ruby/object:Gem::Requirement
238
+ requirement: &2164277780 !ruby/object:Gem::Requirement
228
239
  none: false
229
240
  requirements:
230
241
  - - ! '>='
@@ -232,10 +243,10 @@ dependencies:
232
243
  version: '0'
233
244
  type: :development
234
245
  prerelease: false
235
- version_requirements: *2161921280
246
+ version_requirements: *2164277780
236
247
  - !ruby/object:Gem::Dependency
237
248
  name: pg
238
- requirement: &2161937220 !ruby/object:Gem::Requirement
249
+ requirement: &2164277360 !ruby/object:Gem::Requirement
239
250
  none: false
240
251
  requirements:
241
252
  - - ! '>='
@@ -243,7 +254,7 @@ dependencies:
243
254
  version: '0'
244
255
  type: :development
245
256
  prerelease: false
246
- version_requirements: *2161937220
257
+ version_requirements: *2164277360
247
258
  description: An earth-simulation environment with ActiveRecord models and data
248
259
  email: andy@rossmeissl.net
249
260
  executables: