active_subscriber 0.1.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.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +35 -0
- data/DEVELOPMENT_PLAN.md +275 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +304 -0
- data/INSTALLATION_GUIDE.md +193 -0
- data/LICENSE.txt +21 -0
- data/README.md +287 -0
- data/REQUIREMENTS.md +60 -0
- data/Rakefile +12 -0
- data/lib/active_subscriber/base.rb +138 -0
- data/lib/active_subscriber/configuration.rb +53 -0
- data/lib/active_subscriber/engine.rb +49 -0
- data/lib/active_subscriber/helpers/analytics_helper.rb +54 -0
- data/lib/active_subscriber/loader.rb +54 -0
- data/lib/active_subscriber/publisher.rb +107 -0
- data/lib/active_subscriber/registry.rb +125 -0
- data/lib/active_subscriber/subscriber_job.rb +24 -0
- data/lib/active_subscriber/version.rb +5 -0
- data/lib/active_subscriber.rb +52 -0
- data/lib/generators/active_subscriber/install_generator.rb +32 -0
- data/lib/generators/active_subscriber/subscriber_generator.rb +50 -0
- data/lib/generators/active_subscriber/templates/README +32 -0
- data/lib/generators/active_subscriber/templates/initializer.rb +21 -0
- data/lib/generators/active_subscriber/templates/subscriber.rb +41 -0
- metadata +128 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class <%= class_name %>Subscriber < ActiveSubscriber::Base
|
|
4
|
+
<% if has_events? -%>
|
|
5
|
+
subscribe_to <%= events_list %>
|
|
6
|
+
<% end -%>
|
|
7
|
+
<% if has_patterns? -%>
|
|
8
|
+
subscribe_to_pattern <%= patterns_list %>
|
|
9
|
+
<% end -%>
|
|
10
|
+
|
|
11
|
+
# Lifecycle callbacks (optional)
|
|
12
|
+
# before_handle_event :setup
|
|
13
|
+
# after_handle_event :cleanup
|
|
14
|
+
# around_handle_event :with_timing
|
|
15
|
+
|
|
16
|
+
<% if has_events? -%>
|
|
17
|
+
<%= handler_methods %>
|
|
18
|
+
<% else -%>
|
|
19
|
+
def handle_all_events(event_name, data)
|
|
20
|
+
# Handle all events that match subscribed patterns
|
|
21
|
+
Rails.logger.info "<%= class_name %>Subscriber: Handling #{event_name} event"
|
|
22
|
+
end
|
|
23
|
+
<% end -%>
|
|
24
|
+
|
|
25
|
+
private
|
|
26
|
+
|
|
27
|
+
# def setup
|
|
28
|
+
# # Called before handling any event
|
|
29
|
+
# end
|
|
30
|
+
|
|
31
|
+
# def cleanup
|
|
32
|
+
# # Called after handling any event
|
|
33
|
+
# end
|
|
34
|
+
|
|
35
|
+
# def with_timing
|
|
36
|
+
# start_time = Time.current
|
|
37
|
+
# yield
|
|
38
|
+
# duration = Time.current - start_time
|
|
39
|
+
# Rails.logger.info "<%= class_name %>Subscriber: Event handled in #{duration}ms"
|
|
40
|
+
# end
|
|
41
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: active_subscriber
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Andrea Fomera
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: activesupport
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '6.0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '6.0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: rails
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '6.0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '6.0'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: rspec
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '3.0'
|
|
47
|
+
type: :development
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '3.0'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: rspec-rails
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - "~>"
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '5.0'
|
|
61
|
+
type: :development
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - "~>"
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '5.0'
|
|
68
|
+
description: ActiveSubscriber provides a clean interface for implementing the publisher-subscriber
|
|
69
|
+
pattern in Rails applications using ActiveSupport Notifications, with automatic
|
|
70
|
+
subscriber discovery and lifecycle callbacks.
|
|
71
|
+
email:
|
|
72
|
+
- afomera@hey.com
|
|
73
|
+
executables: []
|
|
74
|
+
extensions: []
|
|
75
|
+
extra_rdoc_files: []
|
|
76
|
+
files:
|
|
77
|
+
- ".rspec"
|
|
78
|
+
- CHANGELOG.md
|
|
79
|
+
- DEVELOPMENT_PLAN.md
|
|
80
|
+
- Gemfile
|
|
81
|
+
- Gemfile.lock
|
|
82
|
+
- INSTALLATION_GUIDE.md
|
|
83
|
+
- LICENSE.txt
|
|
84
|
+
- README.md
|
|
85
|
+
- REQUIREMENTS.md
|
|
86
|
+
- Rakefile
|
|
87
|
+
- lib/active_subscriber.rb
|
|
88
|
+
- lib/active_subscriber/base.rb
|
|
89
|
+
- lib/active_subscriber/configuration.rb
|
|
90
|
+
- lib/active_subscriber/engine.rb
|
|
91
|
+
- lib/active_subscriber/helpers/analytics_helper.rb
|
|
92
|
+
- lib/active_subscriber/loader.rb
|
|
93
|
+
- lib/active_subscriber/publisher.rb
|
|
94
|
+
- lib/active_subscriber/registry.rb
|
|
95
|
+
- lib/active_subscriber/subscriber_job.rb
|
|
96
|
+
- lib/active_subscriber/version.rb
|
|
97
|
+
- lib/generators/active_subscriber/install_generator.rb
|
|
98
|
+
- lib/generators/active_subscriber/subscriber_generator.rb
|
|
99
|
+
- lib/generators/active_subscriber/templates/README
|
|
100
|
+
- lib/generators/active_subscriber/templates/initializer.rb
|
|
101
|
+
- lib/generators/active_subscriber/templates/subscriber.rb
|
|
102
|
+
homepage: https://github.com/afomera/active_subscriber
|
|
103
|
+
licenses:
|
|
104
|
+
- MIT
|
|
105
|
+
metadata:
|
|
106
|
+
allowed_push_host: https://rubygems.org
|
|
107
|
+
homepage_uri: https://github.com/afomera/active_subscriber
|
|
108
|
+
source_code_uri: https://github.com/afomera/active_subscriber
|
|
109
|
+
changelog_uri: https://github.com/afomera/active_subscriber/blob/main/CHANGELOG.md
|
|
110
|
+
rdoc_options: []
|
|
111
|
+
require_paths:
|
|
112
|
+
- lib
|
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: 2.7.0
|
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
|
+
requirements:
|
|
120
|
+
- - ">="
|
|
121
|
+
- !ruby/object:Gem::Version
|
|
122
|
+
version: '0'
|
|
123
|
+
requirements: []
|
|
124
|
+
rubygems_version: 4.0.3
|
|
125
|
+
specification_version: 4
|
|
126
|
+
summary: Pub/sub pattern implementation using ActiveSupport Notifications for Rails
|
|
127
|
+
applications
|
|
128
|
+
test_files: []
|