omnes 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/omnes.rb ADDED
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "omnes/bus"
4
+ require "omnes/event"
5
+ require "omnes/subscriber"
6
+ require "omnes/version"
7
+
8
+ # Pub/sub library for Ruby.
9
+ #
10
+ # There're two ways to make use of the pub/sub features Omnes provides:
11
+ #
12
+ # - Standalone, through an {Omnes::Bus} instance.
13
+ # - Mixing in the behavior in another class by including the {Omnes} module.
14
+ #
15
+ # Refer to {Omnes::Bus} documentation for the available methods. The only
16
+ # difference for the mixing use case is that the methods are directly called in
17
+ # the including instance.
18
+ #
19
+ # ```
20
+ # class MyClass
21
+ # include Omnes
22
+ #
23
+ # def initialize
24
+ # register(:foo)
25
+ # end
26
+ #
27
+ # def call
28
+ # publish(:foo, bar: :baz)
29
+ # end
30
+ # end
31
+ # ```
32
+ #
33
+ # Refer to {Omnes::Subscriber} for how to provide event handlers through methods
34
+ # defined in a class.
35
+ module Omnes
36
+ # Shortcut to access the configuration for different Omnes components
37
+ #
38
+ # TODO: Make automation for it
39
+ #
40
+ # @return [Omnes::Config]
41
+ def self.config
42
+ Config
43
+ end
44
+
45
+ # Wrapper for the configuration of Omnes components
46
+ module Config
47
+ # {Omnes::Subscriber} configuration
48
+ #
49
+ # @return [Dry::Configurable::Config]
50
+ def self.subscriber
51
+ Omnes::Subscriber.config.tap do |klass|
52
+ klass.define_singleton_method(:adapter) do
53
+ Module.new do
54
+ def self.sidekiq
55
+ Omnes::Subscriber::Adapter::Sidekiq.config
56
+ end
57
+
58
+ def self.active_job
59
+ Omnes::Subscriber::Adapter::ActiveJob.config
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+ # {Omnes::Event} configuration
67
+ #
68
+ # @return [Dry::Configurable::Config]
69
+ def self.event
70
+ Omnes::Event.config
71
+ end
72
+ end
73
+
74
+ # @api private
75
+ def self.included(klass)
76
+ klass.define_method(:omnes_bus) { @omnes_bus ||= Bus.new(cal_loc_start: 2) }
77
+ Bus.instance_methods(false).each do |method|
78
+ klass.define_method(method) do |*args, **kwargs, &block|
79
+ omnes_bus.send(method, *args, **kwargs, &block)
80
+ end
81
+ end
82
+ end
83
+ end
data/omnes.gemspec ADDED
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/omnes/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "omnes"
7
+ spec.version = Omnes::VERSION
8
+ spec.authors = ["Marc Busqué"]
9
+ spec.email = ["marc@lamarciana.com"]
10
+
11
+ spec.summary = "Pub/Sub for ruby"
12
+ spec.description = <<~MSG
13
+ Omnes is a Ruby library implementing the publish-subscribe pattern. This
14
+ pattern allows senders of messages to be decoupled from their receivers. An
15
+ Event Bus acts as a middleman where events are published while interested
16
+ parties can subscribe to them.
17
+ MSG
18
+ spec.homepage = "https://github.com/nebulab/omnes"
19
+ spec.license = "MIT"
20
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
21
+
22
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
23
+
24
+ spec.metadata["homepage_uri"] = spec.homepage
25
+ spec.metadata["source_code_uri"] = spec.homepage
26
+ spec.metadata["changelog_uri"] = "#{spec.homepage}/CHANGELOG.md"
27
+
28
+ spec.metadata["rubygems_mfa_required"] = "true"
29
+
30
+ # Specify which files should be added to the gem when it is released.
31
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
33
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
34
+ end
35
+ spec.bindir = "exe"
36
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
+ spec.require_paths = ["lib"]
38
+
39
+ spec.add_dependency "dry-configurable", "~> 0.14"
40
+
41
+ spec.add_development_dependency "activejob", "~> 7.0"
42
+ spec.add_development_dependency "redcarpet", "~> 3.5"
43
+ spec.add_development_dependency "sidekiq", "~> 6.4"
44
+ spec.add_development_dependency "yard", "~> 0.9"
45
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omnes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Marc Busqué
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-03-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dry-configurable
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.14'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: activejob
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '7.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '7.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: redcarpet
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.5'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sidekiq
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '6.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '6.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.9'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.9'
83
+ description: |
84
+ Omnes is a Ruby library implementing the publish-subscribe pattern. This
85
+ pattern allows senders of messages to be decoupled from their receivers. An
86
+ Event Bus acts as a middleman where events are published while interested
87
+ parties can subscribe to them.
88
+ email:
89
+ - marc@lamarciana.com
90
+ executables: []
91
+ extensions: []
92
+ extra_rdoc_files: []
93
+ files:
94
+ - ".github/workflows/lint.yml"
95
+ - ".github/workflows/test.yml"
96
+ - ".gitignore"
97
+ - ".rspec"
98
+ - ".rubocop.yml"
99
+ - ".travis.yml"
100
+ - ".yardopts"
101
+ - CHANGELOG.md
102
+ - CODE_OF_CONDUCT.md
103
+ - Gemfile
104
+ - Gemfile.lock
105
+ - LICENSE.txt
106
+ - README.md
107
+ - Rakefile
108
+ - bin/console
109
+ - bin/setup
110
+ - lib/omnes.rb
111
+ - lib/omnes/bus.rb
112
+ - lib/omnes/errors.rb
113
+ - lib/omnes/event.rb
114
+ - lib/omnes/execution.rb
115
+ - lib/omnes/publication.rb
116
+ - lib/omnes/registry.rb
117
+ - lib/omnes/subscriber.rb
118
+ - lib/omnes/subscriber/adapter.rb
119
+ - lib/omnes/subscriber/adapter/active_job.rb
120
+ - lib/omnes/subscriber/adapter/method.rb
121
+ - lib/omnes/subscriber/adapter/method/errors.rb
122
+ - lib/omnes/subscriber/adapter/sidekiq.rb
123
+ - lib/omnes/subscriber/errors.rb
124
+ - lib/omnes/subscriber/state.rb
125
+ - lib/omnes/subscription.rb
126
+ - lib/omnes/unstructured_event.rb
127
+ - lib/omnes/version.rb
128
+ - omnes.gemspec
129
+ homepage: https://github.com/nebulab/omnes
130
+ licenses:
131
+ - MIT
132
+ metadata:
133
+ allowed_push_host: https://rubygems.org
134
+ homepage_uri: https://github.com/nebulab/omnes
135
+ source_code_uri: https://github.com/nebulab/omnes
136
+ changelog_uri: https://github.com/nebulab/omnes/CHANGELOG.md
137
+ rubygems_mfa_required: 'true'
138
+ post_install_message:
139
+ rdoc_options: []
140
+ require_paths:
141
+ - lib
142
+ required_ruby_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: 2.7.0
147
+ required_rubygems_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ requirements: []
153
+ rubygems_version: 3.2.20
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: Pub/Sub for ruby
157
+ test_files: []