publicist 1.0.0

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.
@@ -0,0 +1 @@
1
+ gemdev
@@ -0,0 +1 @@
1
+ 1.9.3-p392
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in publicist.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Jason Harrelson
2
+
3
+ MIT License
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
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,23 @@
1
+ # Publicist
2
+
3
+ A pub/sub framework for loosley coupled communicatiion between Ruby objects.
4
+
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'publicist'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install publicist
19
+
20
+
21
+ ## Usage
22
+
23
+ Coming soon...
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,7 @@
1
+ require "publicist/version"
2
+
3
+ module Publicist
4
+
5
+ autoload :Publisher, 'publicist/publisher'
6
+
7
+ end
@@ -0,0 +1,86 @@
1
+ module Publicist
2
+ module Publisher
3
+
4
+ def self.included( other_module )
5
+ other_module.extend ClassMethods
6
+ end
7
+
8
+ module ClassMethods
9
+
10
+ def publications
11
+ @publications ||= []
12
+ end
13
+
14
+ def publishes( *publications )
15
+ publications.each do |publication|
16
+ self.publications << publication
17
+ define_method publication do |*args|
18
+ subscriptions[publication].each do |subscriber_proc|
19
+ subscriber_proc.call( *args )
20
+ end
21
+ end
22
+ end
23
+ self
24
+ end
25
+
26
+ end
27
+
28
+ #my_collaborator.subscribe :some_publication_name, subscriber_object
29
+ #my_collaborator.subscribe :some_publication_name, jason,
30
+ #subscriber_object => :subscriber_method,
31
+ #another_subscriber => :his_method
32
+ #my_collaborator.subscribe :some_publication_name, {subscriber_object => :subscriber_method,
33
+ #another_subscriber => :his_method}
34
+ #my_collaborator.subscribe :log_event, Rails.logger => :warn
35
+ #my_collaborator.subscribe :log_event do |options|
36
+ ## Do something here on the event
37
+ #Rails.logger.warn options[:message]
38
+ #end
39
+ #my_collaborator.subscribe :log_event, lambda { |options|
40
+ # Rails.logger.warn options[:message]
41
+ #}, another_collaborator => :do_something
42
+ #
43
+ def subscribe!( publication, *subscribers, &last_subscriber )
44
+ unless self.class.publications.include?( publication )
45
+ raise ArgumentError.new( "#{self.class.name} does not publish #{publication.inspect}" )
46
+ end
47
+
48
+ subscribe( publication, *subscribers, &last_subscriber )
49
+ end
50
+
51
+ def subscribe( publication, *subscribers, &last_subscriber )
52
+ redirected_subscribers = subscribers.extract_options!
53
+ default_subscribers = subscribers
54
+
55
+ self.subscriptions[publication] ||= []
56
+
57
+ default_subscribers.each do |subscriber_object_or_proc|
58
+ subscriber_method = publication
59
+ if subscriber_object_or_proc.respond_to?( subscriber_method )
60
+ self.subscriptions[publication] << lambda { |*arguments|
61
+ subscriber_object_or_proc.send( subscriber_method, *arguments )
62
+ }
63
+ elsif subscriber_object_or_proc.respond_to?( :call )
64
+ self.subscriptions[publication] << subscriber_object_or_proc
65
+ else
66
+ raise ArgumentError.new( "Expected subscriber to respond to ##{subscriber_method} or #call" )
67
+ end
68
+ end
69
+ self.subscriptions[publication] << last_subscriber if last_subscriber
70
+
71
+ redirected_subscribers.each do |subscriber_object, subscriber_method|
72
+ self.subscriptions[publication] << lambda { |*arguments|
73
+ subscriber_object.send( subscriber_method, *arguments )
74
+ }
75
+ end
76
+ self
77
+ end
78
+
79
+ protected
80
+
81
+ def subscriptions
82
+ @subscriptions ||= {}
83
+ end
84
+
85
+ end
86
+ end
@@ -0,0 +1,3 @@
1
+ module Publicist
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'publicist/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "publicist"
8
+ spec.version = Publicist::VERSION
9
+ spec.authors = ["C. Jason Harrelson"]
10
+ spec.email = ["jason@lookforwardenterprises.com"]
11
+ spec.description = %q{A pub/sub framework for loosley coupled communicatiion between Ruby objects.}
12
+ spec.summary = %q{A pub/sub framework for Ruby objects.}
13
+ spec.homepage = "https://github.com/ninja-loss/publicist"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: publicist
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - C. Jason Harrelson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-08-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: A pub/sub framework for loosley coupled communicatiion between Ruby objects.
47
+ email:
48
+ - jason@lookforwardenterprises.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .ruby-gemset
54
+ - .ruby-version
55
+ - Gemfile
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - lib/publicist.rb
60
+ - lib/publicist/publisher.rb
61
+ - lib/publicist/version.rb
62
+ - publicist.gemspec
63
+ homepage: https://github.com/ninja-loss/publicist
64
+ licenses:
65
+ - MIT
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ segments:
77
+ - 0
78
+ hash: 985090995080734904
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ segments:
86
+ - 0
87
+ hash: 985090995080734904
88
+ requirements: []
89
+ rubyforge_project:
90
+ rubygems_version: 1.8.25
91
+ signing_key:
92
+ specification_version: 3
93
+ summary: A pub/sub framework for Ruby objects.
94
+ test_files: []