emitter-ruby19 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc ADDED
@@ -0,0 +1,17 @@
1
+ = emitter
2
+
3
+ Base gem for Brighter Planet's carbon model gems. See http://carbon.brighterplanet.com
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 Andy Rossmeissl. See LICENSE for details.
data/lib/emitter.rb ADDED
@@ -0,0 +1,51 @@
1
+ module BrighterPlanet
2
+ module Emitter
3
+ def included(base)
4
+ base.extend ClassMethods
5
+
6
+ emitter_klass = self.to_s.split('::').last.underscore
7
+
8
+ %w{carbon_model characterization data fallback relationships summarization}.each do |component|
9
+ begin
10
+ require "#{emitter_klass}/#{component}"
11
+ rescue LoadError
12
+ end
13
+ end
14
+
15
+ require 'leap'
16
+ require 'cohort_scope'
17
+ base.extend Leap::Subject
18
+ base.send :include, const_get('CarbonModel')
19
+
20
+ require 'characterizable'
21
+ base.send :include, Characterizable
22
+ base.send :include, const_get('Characterization')
23
+ base.add_implicit_characteristics
24
+
25
+ require 'data_miner'
26
+ base.send :include, const_get('Data')
27
+
28
+ if const_defined?('Fallback')
29
+ require 'falls_back_on'
30
+ require 'falls_back_on/active_record_ext'
31
+ base.send :include, const_get('Fallback')
32
+ end
33
+
34
+ if const_defined?('Relationships')
35
+ base.send :include, const_get('Relationships')
36
+ end
37
+
38
+ require 'summary_judgement'
39
+ base.extend SummaryJudgement
40
+ base.send :include, const_get('Summarization')
41
+ end
42
+
43
+ module ClassMethods
44
+ def add_implicit_characteristics
45
+ decisions[:emission].committees.map(&:name).reject { |c| characteristics.keys.unshift(:emission).include? c }.each do |c|
46
+ characterize { has c }
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,13 @@
1
+ namespace :emitter do
2
+ task :rocco do
3
+ require 'rocco'
4
+ end
5
+
6
+ task :docs => :rocco do
7
+ FileUtils.mkdir_p File.join('.', 'doc')
8
+ %w(carbon_model characterization data summarization).each do |file|
9
+ puts "[docs] #{file}.rb"
10
+ File.open(File.join('.', 'doc', "#{file}.html"), 'wb') { |fd| fd.write(Rocco.new(File.join('.', 'lib', File.basename(Dir.pwd), "#{file}.rb")).to_html) }
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+
3
+ describe BrighterPlanet::Emitter do
4
+ describe '.included' do
5
+ before :all do
6
+ require 'active_record'
7
+ class Aircraft < ActiveRecord::Base; end
8
+ class Airship < ActiveRecord::Base; end
9
+
10
+ $:.unshift File.expand_path('fixtures/dirigible/lib', File.dirname(__FILE__))
11
+ require 'dirigible'
12
+ Airship.send :include, BrighterPlanet::Dirigible
13
+ Airship.execute_schema
14
+
15
+ $:.unshift File.expand_path('fixtures/biplane/lib', File.dirname(__FILE__))
16
+ end
17
+
18
+ it 'should include fallback if available' do
19
+ Airship.new.kind_of?(BrighterPlanet::Dirigible::Fallback).
20
+ should be_true
21
+ end
22
+
23
+ it 'should include relationships if available' do
24
+ Airship.new.kind_of?(BrighterPlanet::Dirigible::Relationships).
25
+ should be_true
26
+ end
27
+
28
+ it 'should not include fallback or relationships if there are none' do
29
+ expect do
30
+ require 'biplane'
31
+ Aircraft.send :include, BrighterPlanet::Biplane
32
+ end.should_not raise_error
33
+ end
34
+ end
35
+ end
36
+
@@ -0,0 +1,7 @@
1
+ require 'emitter'
2
+
3
+ module BrighterPlanet
4
+ module Biplane
5
+ extend BrighterPlanet::Emitter
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ module BrighterPlanet
2
+ module Biplane
3
+ module CarbonModel
4
+ def self.included(base)
5
+ base.decide :emission, :with => :characteristics do
6
+ committee :emission do # returns kg CO2e
7
+ quorum 'default' do
8
+ 100.0
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ module BrighterPlanet
2
+ module Biplane
3
+ module Characterization
4
+ def self.included(base)
5
+ base.characterize do
6
+ has :distance
7
+ has :payload
8
+ has :dirigible_class
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ module BrighterPlanet
2
+ module Biplane
3
+ module Data
4
+ def self.included(base)
5
+ base.data_miner do
6
+ schema do
7
+ float :distance
8
+ float :payload
9
+ integer :dirigible_class_id
10
+ end
11
+
12
+ process :run_data_miner_on_belongs_to_associations
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ module BrighterPlanet
2
+ module Biplane
3
+ module Summarization
4
+ def self.included(base)
5
+ base.summarize do |has|
6
+ has.identity 'dirigible'
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ require 'emitter'
2
+
3
+ module BrighterPlanet
4
+ module Dirigible
5
+ extend BrighterPlanet::Emitter
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ module BrighterPlanet
2
+ module Dirigible
3
+ module CarbonModel
4
+ def self.included(base)
5
+ base.decide :emission, :with => :characteristics do
6
+ committee :emission do # returns kg CO2e
7
+ quorum 'default' do
8
+ 100.0
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,13 @@
1
+ module BrighterPlanet
2
+ module Dirigible
3
+ module Characterization
4
+ def self.included(base)
5
+ base.characterize do
6
+ has :distance
7
+ has :payload
8
+ has :dirigible_class
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ module BrighterPlanet
2
+ module Dirigible
3
+ module Data
4
+ def self.included(base)
5
+ base.data_miner do
6
+ schema do
7
+ float :distance
8
+ float :payload
9
+ integer :dirigible_class_id
10
+ end
11
+
12
+ process :run_data_miner_on_belongs_to_associations
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ module BrighterPlanet
2
+ module Dirigible
3
+ module Fallback
4
+ def self.included(base)
5
+ base.falls_back_on :distance => 100
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module BrighterPlanet
2
+ module Dirigible
3
+ module Relationships
4
+ def self.included(base)
5
+ base.belongs_to :dirigible_class
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ module BrighterPlanet
2
+ module Dirigible
3
+ module Summarization
4
+ def self.included(base)
5
+ base.summarize do |has|
6
+ has.identity 'dirigible'
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup
4
+
5
+ require 'sniff'
6
+ Sniff.init File.join(File.dirname(__FILE__), '..', '..')
7
+
8
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
9
+ require 'emitter'
metadata ADDED
@@ -0,0 +1,402 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: emitter-ruby19
3
+ version: !ruby/object:Gem::Version
4
+ hash: 19
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 4
10
+ version: 0.1.4
11
+ platform: ruby
12
+ authors:
13
+ - Andy Rossmeissl
14
+ - Seamus Abshere
15
+ - Ian Hough
16
+ - Matt Kling
17
+ - Derek Kastner
18
+ autorequire:
19
+ bindir: bin
20
+ cert_chain: []
21
+
22
+ date: 2010-09-21 00:00:00 -05:00
23
+ default_executable:
24
+ dependencies:
25
+ - !ruby/object:Gem::Dependency
26
+ name: activerecord
27
+ prerelease: false
28
+ requirement: &id001 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ hash: 7
34
+ segments:
35
+ - 3
36
+ - 0
37
+ - 0
38
+ version: 3.0.0
39
+ type: :development
40
+ version_requirements: *id001
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ prerelease: false
44
+ requirement: &id002 !ruby/object:Gem::Requirement
45
+ none: false
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ hash: 62196359
50
+ segments:
51
+ - 1
52
+ - 0
53
+ - 0
54
+ - beta
55
+ - 2
56
+ version: 1.0.0.beta.2
57
+ type: :development
58
+ version_requirements: *id002
59
+ - !ruby/object:Gem::Dependency
60
+ name: jeweler
61
+ prerelease: false
62
+ requirement: &id003 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ hash: 7
68
+ segments:
69
+ - 1
70
+ - 4
71
+ - 0
72
+ version: 1.4.0
73
+ type: :development
74
+ version_requirements: *id003
75
+ - !ruby/object:Gem::Dependency
76
+ name: rake
77
+ prerelease: false
78
+ requirement: &id004 !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ hash: 3
84
+ segments:
85
+ - 0
86
+ version: "0"
87
+ type: :development
88
+ version_requirements: *id004
89
+ - !ruby/object:Gem::Dependency
90
+ name: rdoc
91
+ prerelease: false
92
+ requirement: &id005 !ruby/object:Gem::Requirement
93
+ none: false
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ hash: 3
98
+ segments:
99
+ - 0
100
+ version: "0"
101
+ type: :development
102
+ version_requirements: *id005
103
+ - !ruby/object:Gem::Dependency
104
+ name: rspec
105
+ prerelease: false
106
+ requirement: &id006 !ruby/object:Gem::Requirement
107
+ none: false
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ hash: 62196417
112
+ segments:
113
+ - 2
114
+ - 0
115
+ - 0
116
+ - beta
117
+ - 17
118
+ version: 2.0.0.beta.17
119
+ type: :development
120
+ version_requirements: *id006
121
+ - !ruby/object:Gem::Dependency
122
+ name: sniff
123
+ prerelease: false
124
+ requirement: &id007 !ruby/object:Gem::Requirement
125
+ none: false
126
+ requirements:
127
+ - - ~>
128
+ - !ruby/object:Gem::Version
129
+ hash: 3
130
+ segments:
131
+ - 0
132
+ - 1
133
+ - 12
134
+ version: 0.1.12
135
+ type: :development
136
+ version_requirements: *id007
137
+ - !ruby/object:Gem::Dependency
138
+ name: activesupport
139
+ prerelease: false
140
+ requirement: &id008 !ruby/object:Gem::Requirement
141
+ none: false
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ hash: 7
146
+ segments:
147
+ - 3
148
+ - 0
149
+ - 0
150
+ version: 3.0.0
151
+ type: :runtime
152
+ version_requirements: *id008
153
+ - !ruby/object:Gem::Dependency
154
+ name: characterizable
155
+ prerelease: false
156
+ requirement: &id009 !ruby/object:Gem::Requirement
157
+ none: false
158
+ requirements:
159
+ - - ">="
160
+ - !ruby/object:Gem::Version
161
+ hash: 63
162
+ segments:
163
+ - 0
164
+ - 0
165
+ - 16
166
+ version: 0.0.16
167
+ type: :runtime
168
+ version_requirements: *id009
169
+ - !ruby/object:Gem::Dependency
170
+ name: cohort_scope
171
+ prerelease: false
172
+ requirement: &id010 !ruby/object:Gem::Requirement
173
+ none: false
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ hash: 17
178
+ segments:
179
+ - 0
180
+ - 0
181
+ - 7
182
+ version: 0.0.7
183
+ type: :runtime
184
+ version_requirements: *id010
185
+ - !ruby/object:Gem::Dependency
186
+ name: data_miner-ruby19
187
+ prerelease: false
188
+ requirement: &id011 !ruby/object:Gem::Requirement
189
+ none: false
190
+ requirements:
191
+ - - ">="
192
+ - !ruby/object:Gem::Version
193
+ hash: 13
194
+ segments:
195
+ - 0
196
+ - 5
197
+ - 3
198
+ version: 0.5.3
199
+ type: :runtime
200
+ version_requirements: *id011
201
+ - !ruby/object:Gem::Dependency
202
+ name: earth
203
+ prerelease: false
204
+ requirement: &id012 !ruby/object:Gem::Requirement
205
+ none: false
206
+ requirements:
207
+ - - ~>
208
+ - !ruby/object:Gem::Version
209
+ hash: 23
210
+ segments:
211
+ - 0
212
+ - 2
213
+ - 0
214
+ version: 0.2.0
215
+ type: :runtime
216
+ version_requirements: *id012
217
+ - !ruby/object:Gem::Dependency
218
+ name: falls_back_on
219
+ prerelease: false
220
+ requirement: &id013 !ruby/object:Gem::Requirement
221
+ none: false
222
+ requirements:
223
+ - - "="
224
+ - !ruby/object:Gem::Version
225
+ hash: 25
226
+ segments:
227
+ - 0
228
+ - 0
229
+ - 3
230
+ version: 0.0.3
231
+ type: :runtime
232
+ version_requirements: *id013
233
+ - !ruby/object:Gem::Dependency
234
+ name: fast_timestamp
235
+ prerelease: false
236
+ requirement: &id014 !ruby/object:Gem::Requirement
237
+ none: false
238
+ requirements:
239
+ - - ">="
240
+ - !ruby/object:Gem::Version
241
+ hash: 23
242
+ segments:
243
+ - 0
244
+ - 0
245
+ - 4
246
+ version: 0.0.4
247
+ type: :runtime
248
+ version_requirements: *id014
249
+ - !ruby/object:Gem::Dependency
250
+ name: leap
251
+ prerelease: false
252
+ requirement: &id015 !ruby/object:Gem::Requirement
253
+ none: false
254
+ requirements:
255
+ - - ">="
256
+ - !ruby/object:Gem::Version
257
+ hash: 9
258
+ segments:
259
+ - 0
260
+ - 4
261
+ - 3
262
+ version: 0.4.3
263
+ type: :runtime
264
+ version_requirements: *id015
265
+ - !ruby/object:Gem::Dependency
266
+ name: summary_judgement
267
+ prerelease: false
268
+ requirement: &id016 !ruby/object:Gem::Requirement
269
+ none: false
270
+ requirements:
271
+ - - ">="
272
+ - !ruby/object:Gem::Version
273
+ hash: 11
274
+ segments:
275
+ - 1
276
+ - 3
277
+ - 8
278
+ version: 1.3.8
279
+ type: :runtime
280
+ version_requirements: *id016
281
+ - !ruby/object:Gem::Dependency
282
+ name: timeframe
283
+ prerelease: false
284
+ requirement: &id017 !ruby/object:Gem::Requirement
285
+ none: false
286
+ requirements:
287
+ - - ">="
288
+ - !ruby/object:Gem::Version
289
+ hash: 15
290
+ segments:
291
+ - 0
292
+ - 0
293
+ - 8
294
+ version: 0.0.8
295
+ type: :runtime
296
+ version_requirements: *id017
297
+ - !ruby/object:Gem::Dependency
298
+ name: weighted_average
299
+ prerelease: false
300
+ requirement: &id018 !ruby/object:Gem::Requirement
301
+ none: false
302
+ requirements:
303
+ - - ">="
304
+ - !ruby/object:Gem::Version
305
+ hash: 23
306
+ segments:
307
+ - 0
308
+ - 0
309
+ - 4
310
+ version: 0.0.4
311
+ type: :runtime
312
+ version_requirements: *id018
313
+ - !ruby/object:Gem::Dependency
314
+ name: rocco
315
+ prerelease: false
316
+ requirement: &id019 !ruby/object:Gem::Requirement
317
+ none: false
318
+ requirements:
319
+ - - ~>
320
+ - !ruby/object:Gem::Version
321
+ hash: 3
322
+ segments:
323
+ - 0
324
+ - 4
325
+ version: "0.4"
326
+ type: :development
327
+ version_requirements: *id019
328
+ description: A software model in Ruby for the greenhouse gas emissions
329
+ email: derek@brighterplanet.com
330
+ executables: []
331
+
332
+ extensions: []
333
+
334
+ extra_rdoc_files:
335
+ - README.rdoc
336
+ files:
337
+ - README.rdoc
338
+ - lib/emitter.rb
339
+ - lib/emitter/tasks.rb
340
+ - spec/emitter_spec.rb
341
+ - spec/fixtures/biplane/lib/biplane/carbon_model.rb
342
+ - spec/fixtures/biplane/lib/biplane/characterization.rb
343
+ - spec/fixtures/biplane/lib/biplane/data.rb
344
+ - spec/fixtures/biplane/lib/biplane/summarization.rb
345
+ - spec/fixtures/biplane/lib/biplane.rb
346
+ - spec/fixtures/dirigible/lib/dirigible/carbon_model.rb
347
+ - spec/fixtures/dirigible/lib/dirigible/characterization.rb
348
+ - spec/fixtures/dirigible/lib/dirigible/data.rb
349
+ - spec/fixtures/dirigible/lib/dirigible/fallback.rb
350
+ - spec/fixtures/dirigible/lib/dirigible/relationships.rb
351
+ - spec/fixtures/dirigible/lib/dirigible/summarization.rb
352
+ - spec/fixtures/dirigible/lib/dirigible.rb
353
+ - spec/spec_helper.rb
354
+ has_rdoc: true
355
+ homepage: http://github.com/brighterplanet/emitter
356
+ licenses: []
357
+
358
+ post_install_message:
359
+ rdoc_options:
360
+ - --charset=UTF-8
361
+ require_paths:
362
+ - lib
363
+ required_ruby_version: !ruby/object:Gem::Requirement
364
+ none: false
365
+ requirements:
366
+ - - ">="
367
+ - !ruby/object:Gem::Version
368
+ hash: 3
369
+ segments:
370
+ - 0
371
+ version: "0"
372
+ required_rubygems_version: !ruby/object:Gem::Requirement
373
+ none: false
374
+ requirements:
375
+ - - ">="
376
+ - !ruby/object:Gem::Version
377
+ hash: 3
378
+ segments:
379
+ - 0
380
+ version: "0"
381
+ requirements: []
382
+
383
+ rubyforge_project:
384
+ rubygems_version: 1.3.7
385
+ signing_key:
386
+ specification_version: 3
387
+ summary: The mother of all carbon models
388
+ test_files:
389
+ - spec/emitter_spec.rb
390
+ - spec/fixtures/biplane/lib/biplane/carbon_model.rb
391
+ - spec/fixtures/biplane/lib/biplane/characterization.rb
392
+ - spec/fixtures/biplane/lib/biplane/data.rb
393
+ - spec/fixtures/biplane/lib/biplane/summarization.rb
394
+ - spec/fixtures/biplane/lib/biplane.rb
395
+ - spec/fixtures/dirigible/lib/dirigible/carbon_model.rb
396
+ - spec/fixtures/dirigible/lib/dirigible/characterization.rb
397
+ - spec/fixtures/dirigible/lib/dirigible/data.rb
398
+ - spec/fixtures/dirigible/lib/dirigible/fallback.rb
399
+ - spec/fixtures/dirigible/lib/dirigible/relationships.rb
400
+ - spec/fixtures/dirigible/lib/dirigible/summarization.rb
401
+ - spec/fixtures/dirigible/lib/dirigible.rb
402
+ - spec/spec_helper.rb