emitter 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/emitter.rb +26 -16
- metadata +4 -4
data/lib/emitter.rb
CHANGED
@@ -1,43 +1,53 @@
|
|
1
1
|
module BrighterPlanet
|
2
2
|
module Emitter
|
3
|
+
REQUIRED_COMPONENTS = %w{carbon_model characterization data summarization}
|
4
|
+
OPTIONAL_COMPONENTS = %w{fallback relationships}
|
3
5
|
def included(base)
|
4
6
|
base.extend ClassMethods
|
5
7
|
|
6
|
-
|
8
|
+
common_name = self.to_s.split('::').last.underscore
|
9
|
+
common_camel = common_name.camelcase
|
7
10
|
|
8
|
-
|
11
|
+
REQUIRED_COMPONENTS.each do |component|
|
12
|
+
require "#{common_name}/#{component}"
|
13
|
+
end
|
14
|
+
|
15
|
+
extra = []
|
16
|
+
OPTIONAL_COMPONENTS.each do |component|
|
9
17
|
begin
|
10
|
-
require "#{
|
18
|
+
require "#{common_name}/#{component}"
|
19
|
+
extra << component
|
11
20
|
rescue LoadError
|
21
|
+
# Oh well, we shouldn't need it.
|
12
22
|
end
|
13
23
|
end
|
14
24
|
|
15
25
|
require 'leap'
|
16
26
|
require 'cohort_scope'
|
17
|
-
base.extend Leap::Subject
|
18
|
-
base.send :include,
|
27
|
+
base.extend ::Leap::Subject
|
28
|
+
base.send :include, "::BrighterPlanet::#{common_camel}::CarbonModel".constantize
|
19
29
|
|
20
30
|
require 'characterizable'
|
21
|
-
base.send :include, Characterizable
|
22
|
-
base.send :include,
|
31
|
+
base.send :include, ::Characterizable
|
32
|
+
base.send :include, "::BrighterPlanet::#{common_camel}::Characterization".constantize
|
23
33
|
base.add_implicit_characteristics
|
24
34
|
|
25
35
|
require 'data_miner'
|
26
|
-
base.send :include,
|
36
|
+
base.send :include, "::BrighterPlanet::#{common_camel}::Data".constantize
|
37
|
+
|
38
|
+
require 'summary_judgement'
|
39
|
+
base.extend ::SummaryJudgement
|
40
|
+
base.send :include, "::BrighterPlanet::#{common_camel}::Summarization".constantize
|
27
41
|
|
28
|
-
if
|
42
|
+
if extra.include? 'fallback'
|
29
43
|
require 'falls_back_on'
|
30
44
|
require 'falls_back_on/active_record_ext'
|
31
|
-
base.send :include,
|
45
|
+
base.send :include, "::BrighterPlanet::#{common_camel}::Fallback".constantize
|
32
46
|
end
|
33
47
|
|
34
|
-
if
|
35
|
-
base.send :include,
|
48
|
+
if extra.include? 'relationships'
|
49
|
+
base.send :include, "::BrighterPlanet::#{common_camel}::Relationships".constantize
|
36
50
|
end
|
37
|
-
|
38
|
-
require 'summary_judgement'
|
39
|
-
base.extend SummaryJudgement
|
40
|
-
base.send :include, const_get('Summarization')
|
41
51
|
end
|
42
52
|
|
43
53
|
module ClassMethods
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emitter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 5
|
10
|
+
version: 0.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andy Rossmeissl
|
@@ -19,7 +19,7 @@ autorequire:
|
|
19
19
|
bindir: bin
|
20
20
|
cert_chain: []
|
21
21
|
|
22
|
-
date: 2010-09-
|
22
|
+
date: 2010-09-30 00:00:00 -05:00
|
23
23
|
default_executable:
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|