wonkavision 0.5.4 → 0.5.9
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/CHANGELOG.rdoc +28 -16
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -21
- data/Rakefile +47 -47
- data/lib/wonkavision.rb +75 -74
- data/lib/wonkavision/acts_as_oompa_loompa.rb +22 -22
- data/lib/wonkavision/event_binding.rb +21 -21
- data/lib/wonkavision/event_context.rb +9 -9
- data/lib/wonkavision/event_coordinator.rb +75 -75
- data/lib/wonkavision/event_handler.rb +15 -15
- data/lib/wonkavision/event_namespace.rb +79 -79
- data/lib/wonkavision/event_path_segment.rb +35 -35
- data/lib/wonkavision/message_mapper.rb +30 -30
- data/lib/wonkavision/message_mapper/indifferent_access.rb +30 -26
- data/lib/wonkavision/message_mapper/map.rb +241 -153
- data/lib/wonkavision/persistence/mongo_mapper_adapter.rb +32 -32
- data/lib/wonkavision/persistence/mongoid_adapter.rb +32 -0
- data/lib/wonkavision/plugins.rb +30 -30
- data/lib/wonkavision/plugins/business_activity.rb +92 -92
- data/lib/wonkavision/plugins/business_activity/event_binding.rb +15 -15
- data/lib/wonkavision/plugins/callbacks.rb +182 -182
- data/lib/wonkavision/plugins/event_handling.rb +111 -111
- data/lib/wonkavision/plugins/timeline.rb +79 -79
- data/lib/wonkavision/version.rb +3 -3
- data/test/business_activity_test.rb +31 -31
- data/test/event_handler_test.rb +68 -69
- data/test/event_namespace_test.rb +108 -108
- data/test/event_path_segment_test.rb +41 -41
- data/test/log/test.log +817 -18354
- data/test/map_test.rb +315 -201
- data/test/message_mapper_test.rb +20 -20
- data/test/test_activity_models.rb +72 -72
- data/test/test_helper.rb +70 -63
- data/test/timeline_test.rb +55 -61
- data/test/wonkavision_test.rb +9 -9
- metadata +72 -12
- data/wonkavision.gemspec +0 -97
data/CHANGELOG.rdoc
CHANGED
@@ -1,16 +1,28 @@
|
|
1
|
-
==0.5.
|
2
|
-
*
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
*
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
1
|
+
== 0.5.9
|
2
|
+
* Fixed indifferent access module to include delete in its indifferentness.
|
3
|
+
|
4
|
+
==0.5.8
|
5
|
+
* Added Mongoid integration, changed tests to use Mongoid integration instead of MongoMapper integration.
|
6
|
+
* Split Date and Time directives in MessageMapper to be specific, instead of always converting to time
|
7
|
+
==0.5.7
|
8
|
+
* Added robust text formatting to message mapper
|
9
|
+
|
10
|
+
==0.5.5
|
11
|
+
* Changed 'map' to 'child' to avoid conflicts when serializing to JSON
|
12
|
+
|
13
|
+
==0.5.4
|
14
|
+
* Added ability to specify correlation_ids per event binding in addition to a global correlation specification, so
|
15
|
+
certain messages can be correlated to the business activity using arbitrary event / model id pairs.
|
16
|
+
|
17
|
+
==0.5.3
|
18
|
+
* Added 'array' expression to mapping DSL to allow for the easy mapping of collection of items from incoming messages
|
19
|
+
|
20
|
+
== 0.5.2
|
21
|
+
* Added callbacks to event handler, before_event and after_event. Refactored event handling hierarchy to be a little
|
22
|
+
less functional and a little more object oriented.
|
23
|
+
|
24
|
+
== 0.5.1
|
25
|
+
* Ensure that subscriptions to an event namespace will only get notified once per incoming message
|
26
|
+
|
27
|
+
== 0.5.0
|
28
|
+
* Initial release
|
data/Gemfile
ADDED
data/LICENSE.txt
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
The MIT LICENSE
|
2
|
-
|
3
|
-
Copyright (c) 2010 Nathan Stults
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
1
|
+
The MIT LICENSE
|
2
|
+
|
3
|
+
Copyright (c) 2010 Nathan Stults
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
22
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
CHANGED
@@ -1,48 +1,48 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake'
|
3
|
-
require 'rake/testtask'
|
4
|
-
require 'rake/rdoctask'
|
5
|
-
|
6
|
-
begin
|
7
|
-
require 'jeweler'
|
8
|
-
require File.dirname(__FILE__) + "/lib/wonkavision/version"
|
9
|
-
|
10
|
-
Jeweler::Tasks.new do |s|
|
11
|
-
s.name = "wonkavision"
|
12
|
-
s.version = Wonkavision::VERSION
|
13
|
-
s.summary = "Simple Business Activity Monitoring"
|
14
|
-
s.description = "Wonkavision is a small gem that allows you to publish"
|
15
|
-
s.email = "hereiam@sonic.net"
|
16
|
-
s.homepage = "http://github.com/PlasticLizard/wonkavision"
|
17
|
-
s.authors = ["Nathan Stults"]
|
18
|
-
s.has_rdoc = false #=>Should be true, someday
|
19
|
-
s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
|
20
|
-
s.files = FileList["[A-Z]*", "{bin,lib,test}/**/*"]
|
21
|
-
|
22
|
-
s.add_dependency('activesupport', '>= 2.3')
|
23
|
-
|
24
|
-
s.add_development_dependency('shoulda', '2.10.3')
|
25
|
-
end
|
26
|
-
|
27
|
-
Jeweler::GemcutterTasks.new
|
28
|
-
|
29
|
-
rescue LoadError => ex
|
30
|
-
puts "Jeweler not available. Install it for jeweler-related tasks with: sudo gem install jeweler"
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
Rake::TestTask.new do |t|
|
35
|
-
t.libs << 'libs' << 'test'
|
36
|
-
t.pattern = 'test/**/*_test.rb'
|
37
|
-
t.verbose = false
|
38
|
-
end
|
39
|
-
|
40
|
-
Rake::RDocTask.new do |rdoc|
|
41
|
-
rdoc.rdoc_dir = 'rdoc'
|
42
|
-
rdoc.title = 'test'
|
43
|
-
rdoc.options << '--line-numbers' << '--inline-source'
|
44
|
-
rdoc.rdoc_files.include('README*')
|
45
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
46
|
-
end
|
47
|
-
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rake/rdoctask'
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'jeweler'
|
8
|
+
require File.dirname(__FILE__) + "/lib/wonkavision/version"
|
9
|
+
|
10
|
+
Jeweler::Tasks.new do |s|
|
11
|
+
s.name = "wonkavision"
|
12
|
+
s.version = Wonkavision::VERSION
|
13
|
+
s.summary = "Simple Business Activity Monitoring"
|
14
|
+
s.description = "Wonkavision is a small gem that allows you to publish"
|
15
|
+
s.email = "hereiam@sonic.net"
|
16
|
+
s.homepage = "http://github.com/PlasticLizard/wonkavision"
|
17
|
+
s.authors = ["Nathan Stults"]
|
18
|
+
s.has_rdoc = false #=>Should be true, someday
|
19
|
+
s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
|
20
|
+
s.files = FileList["[A-Z]*", "{bin,lib,test}/**/*"]
|
21
|
+
|
22
|
+
s.add_dependency('activesupport', '>= 2.3')
|
23
|
+
|
24
|
+
s.add_development_dependency('shoulda', '2.10.3')
|
25
|
+
end
|
26
|
+
|
27
|
+
Jeweler::GemcutterTasks.new
|
28
|
+
|
29
|
+
rescue LoadError => ex
|
30
|
+
puts "Jeweler not available. Install it for jeweler-related tasks with: sudo gem install jeweler"
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
Rake::TestTask.new do |t|
|
35
|
+
t.libs << 'libs' << 'test'
|
36
|
+
t.pattern = 'test/**/*_test.rb'
|
37
|
+
t.verbose = false
|
38
|
+
end
|
39
|
+
|
40
|
+
Rake::RDocTask.new do |rdoc|
|
41
|
+
rdoc.rdoc_dir = 'rdoc'
|
42
|
+
rdoc.title = 'test'
|
43
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
44
|
+
rdoc.rdoc_files.include('README*')
|
45
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
46
|
+
end
|
47
|
+
|
48
48
|
task :default => :test
|
data/lib/wonkavision.rb
CHANGED
@@ -1,74 +1,75 @@
|
|
1
|
-
require "rubygems"
|
2
|
-
require "active_support"
|
3
|
-
require "active_support/hash_with_indifferent_access" unless defined?(HashWithIndifferentAccess)
|
4
|
-
|
5
|
-
dir = File.dirname(__FILE__)
|
6
|
-
["support",
|
7
|
-
"plugins",
|
8
|
-
"event_path_segment",
|
9
|
-
"event",
|
10
|
-
"event_context",
|
11
|
-
"event_namespace",
|
12
|
-
"event_coordinator",
|
13
|
-
"event_binding",
|
14
|
-
"event_handler",
|
15
|
-
"message_mapper/indifferent_access",
|
16
|
-
"message_mapper/map",
|
17
|
-
"message_mapper",
|
18
|
-
"plugins/callbacks",
|
19
|
-
"plugins/event_handling",
|
20
|
-
"plugins/business_activity/event_binding",
|
21
|
-
"plugins/business_activity",
|
22
|
-
"plugins/timeline",
|
23
|
-
"acts_as_oompa_loompa",
|
24
|
-
"persistence/mongo_mapper_adapter"
|
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
|
-
args.
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
1
|
+
require "rubygems"
|
2
|
+
require "active_support"
|
3
|
+
require "active_support/hash_with_indifferent_access" unless defined?(HashWithIndifferentAccess)
|
4
|
+
|
5
|
+
dir = File.dirname(__FILE__)
|
6
|
+
["support",
|
7
|
+
"plugins",
|
8
|
+
"event_path_segment",
|
9
|
+
"event",
|
10
|
+
"event_context",
|
11
|
+
"event_namespace",
|
12
|
+
"event_coordinator",
|
13
|
+
"event_binding",
|
14
|
+
"event_handler",
|
15
|
+
"message_mapper/indifferent_access",
|
16
|
+
"message_mapper/map",
|
17
|
+
"message_mapper",
|
18
|
+
"plugins/callbacks",
|
19
|
+
"plugins/event_handling",
|
20
|
+
"plugins/business_activity/event_binding",
|
21
|
+
"plugins/business_activity",
|
22
|
+
"plugins/timeline",
|
23
|
+
"acts_as_oompa_loompa",
|
24
|
+
"persistence/mongo_mapper_adapter",
|
25
|
+
"persistence/mongoid_adapter"].each {|lib|require File.join(dir,'wonkavision',lib)}
|
26
|
+
|
27
|
+
#require File.join(dir,"cubicle","mongo_mapper","aggregate_plugin") if defined?(MongoMapper::Document)
|
28
|
+
|
29
|
+
module Wonkavision
|
30
|
+
|
31
|
+
# def self.register_cubicle_directory(directory_path, recursive=true)
|
32
|
+
# searcher = "#{recursive ? "*" : "**/*"}.rb"
|
33
|
+
# Dir[File.join(directory_path,searcher)].each {|cubicle| require cubicle}
|
34
|
+
# end
|
35
|
+
|
36
|
+
class << self
|
37
|
+
|
38
|
+
attr_accessor :event_path_separator
|
39
|
+
|
40
|
+
def event_coordinator
|
41
|
+
@event_coordinator ||= Wonkavision::EventCoordinator.new
|
42
|
+
end
|
43
|
+
|
44
|
+
def event_path_separator
|
45
|
+
@event_path_separator ||= '/'
|
46
|
+
end
|
47
|
+
|
48
|
+
def namespace_wildcard_character
|
49
|
+
@namespace_wildcard_character = "*"
|
50
|
+
end
|
51
|
+
|
52
|
+
def is_absolute_path(path)
|
53
|
+
path.to_s[0..0] == event_path_separator
|
54
|
+
end
|
55
|
+
|
56
|
+
def normalize_event_path(event_path)
|
57
|
+
event_path.to_s.split(event_path_separator).map{|s|s.underscore}.join(event_path_separator)
|
58
|
+
end
|
59
|
+
|
60
|
+
def join (*args)
|
61
|
+
args.map!{|segment|normalize_event_path(segment)}
|
62
|
+
args.reject{|segment|segment.blank?}.join(event_path_separator)
|
63
|
+
end
|
64
|
+
|
65
|
+
def split(event_path)
|
66
|
+
event_path.split(event_path_separator)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
class WonkavisionError < StandardError #:nodoc:
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
end
|
@@ -1,22 +1,22 @@
|
|
1
|
-
module Wonkavision
|
2
|
-
module ActsAsOompaLoompa
|
3
|
-
|
4
|
-
def acts_as_event_handler
|
5
|
-
include Wonkavision::EventHandler
|
6
|
-
end
|
7
|
-
|
8
|
-
def acts_as_business_activity(opts={})
|
9
|
-
acts_as_event_handler
|
10
|
-
use Wonkavision::Plugins::BusinessActivity, opts
|
11
|
-
end
|
12
|
-
|
13
|
-
def acts_as_timeline(opts={})
|
14
|
-
acts_as_business_activity(opts)
|
15
|
-
use Wonkavision::Plugins::Timeline, opts
|
16
|
-
end
|
17
|
-
|
18
|
-
def acts_like_a_child(opts={})
|
19
|
-
raise "I don't want to include any plugins!" if (1 + rand(10)) % 3 == 0
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
1
|
+
module Wonkavision
|
2
|
+
module ActsAsOompaLoompa
|
3
|
+
|
4
|
+
def acts_as_event_handler
|
5
|
+
include Wonkavision::EventHandler
|
6
|
+
end
|
7
|
+
|
8
|
+
def acts_as_business_activity(opts={})
|
9
|
+
acts_as_event_handler
|
10
|
+
use Wonkavision::Plugins::BusinessActivity, opts
|
11
|
+
end
|
12
|
+
|
13
|
+
def acts_as_timeline(opts={})
|
14
|
+
acts_as_business_activity(opts)
|
15
|
+
use Wonkavision::Plugins::Timeline, opts
|
16
|
+
end
|
17
|
+
|
18
|
+
def acts_like_a_child(opts={})
|
19
|
+
raise "I don't want to include any plugins!" if (1 + rand(10)) % 3 == 0
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,22 +1,22 @@
|
|
1
|
-
module Wonkavision
|
2
|
-
|
3
|
-
class EventBinding
|
4
|
-
attr_reader :name, :events, :options
|
5
|
-
|
6
|
-
def initialize(name,handler,*args)
|
7
|
-
args.flatten!
|
8
|
-
@options = args.extract_options!
|
9
|
-
@handler = handler
|
10
|
-
@name = name
|
11
|
-
@events = []
|
12
|
-
args = [@name] if args.blank? || args.flatten.blank?
|
13
|
-
@events = args.flatten.map{|evt_name|@handler.event_path(evt_name)}
|
14
|
-
end
|
15
|
-
|
16
|
-
def subscribe_to_events(&block)
|
17
|
-
@events.each do |event|
|
18
|
-
Wonkavision.event_coordinator.subscribe(event,&block)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
1
|
+
module Wonkavision
|
2
|
+
|
3
|
+
class EventBinding
|
4
|
+
attr_reader :name, :events, :options
|
5
|
+
|
6
|
+
def initialize(name,handler,*args)
|
7
|
+
args.flatten!
|
8
|
+
@options = args.extract_options!
|
9
|
+
@handler = handler
|
10
|
+
@name = name
|
11
|
+
@events = []
|
12
|
+
args = [@name] if args.blank? || args.flatten.blank?
|
13
|
+
@events = args.flatten.map{|evt_name|@handler.event_path(evt_name)}
|
14
|
+
end
|
15
|
+
|
16
|
+
def subscribe_to_events(&block)
|
17
|
+
@events.each do |event|
|
18
|
+
Wonkavision.event_coordinator.subscribe(event,&block)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
22
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module Wonkavision
|
2
|
-
class EventContext
|
3
|
-
attr_accessor :data, :path, :binding, :callback
|
4
|
-
|
5
|
-
def initialize(data,path,binding,callback)
|
6
|
-
@data, @path, @binding, @callback = data, path, binding, callback
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
1
|
+
module Wonkavision
|
2
|
+
class EventContext
|
3
|
+
attr_accessor :data, :path, :binding, :callback
|
4
|
+
|
5
|
+
def initialize(data,path,binding,callback)
|
6
|
+
@data, @path, @binding, @callback = data, path, binding, callback
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|