aether_observatory 0.0.1pre4 → 1.0.1

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.
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: ../../rubocop-powerhome
3
3
  specs:
4
- rubocop-powerhome (0.5.3)
5
- rubocop (= 1.66.1)
4
+ rubocop-powerhome (0.5.5)
5
+ rubocop (= 1.74.0)
6
6
  rubocop-performance
7
7
  rubocop-rails
8
8
  rubocop-rake
@@ -11,77 +11,15 @@ PATH
11
11
  PATH
12
12
  remote: ..
13
13
  specs:
14
- aether_observatory (0.0.1pre4)
14
+ aether_observatory (1.0.1)
15
15
  activemodel (>= 6.0.6.1)
16
16
  activesupport (>= 6.0.6.1)
17
17
 
18
18
  GEM
19
19
  remote: https://rubygems.org/
20
20
  specs:
21
- actioncable (7.1.5.1)
22
- actionpack (= 7.1.5.1)
23
- activesupport (= 7.1.5.1)
24
- nio4r (~> 2.0)
25
- websocket-driver (>= 0.6.1)
26
- zeitwerk (~> 2.6)
27
- actionmailbox (7.1.5.1)
28
- actionpack (= 7.1.5.1)
29
- activejob (= 7.1.5.1)
30
- activerecord (= 7.1.5.1)
31
- activestorage (= 7.1.5.1)
32
- activesupport (= 7.1.5.1)
33
- mail (>= 2.7.1)
34
- net-imap
35
- net-pop
36
- net-smtp
37
- actionmailer (7.1.5.1)
38
- actionpack (= 7.1.5.1)
39
- actionview (= 7.1.5.1)
40
- activejob (= 7.1.5.1)
41
- activesupport (= 7.1.5.1)
42
- mail (~> 2.5, >= 2.5.4)
43
- net-imap
44
- net-pop
45
- net-smtp
46
- rails-dom-testing (~> 2.2)
47
- actionpack (7.1.5.1)
48
- actionview (= 7.1.5.1)
49
- activesupport (= 7.1.5.1)
50
- nokogiri (>= 1.8.5)
51
- racc
52
- rack (>= 2.2.4)
53
- rack-session (>= 1.0.1)
54
- rack-test (>= 0.6.3)
55
- rails-dom-testing (~> 2.2)
56
- rails-html-sanitizer (~> 1.6)
57
- actiontext (7.1.5.1)
58
- actionpack (= 7.1.5.1)
59
- activerecord (= 7.1.5.1)
60
- activestorage (= 7.1.5.1)
61
- activesupport (= 7.1.5.1)
62
- globalid (>= 0.6.0)
63
- nokogiri (>= 1.8.5)
64
- actionview (7.1.5.1)
65
- activesupport (= 7.1.5.1)
66
- builder (~> 3.1)
67
- erubi (~> 1.11)
68
- rails-dom-testing (~> 2.2)
69
- rails-html-sanitizer (~> 1.6)
70
- activejob (7.1.5.1)
71
- activesupport (= 7.1.5.1)
72
- globalid (>= 0.3.6)
73
21
  activemodel (7.1.5.1)
74
22
  activesupport (= 7.1.5.1)
75
- activerecord (7.1.5.1)
76
- activemodel (= 7.1.5.1)
77
- activesupport (= 7.1.5.1)
78
- timeout (>= 0.4.0)
79
- activestorage (7.1.5.1)
80
- actionpack (= 7.1.5.1)
81
- activejob (= 7.1.5.1)
82
- activerecord (= 7.1.5.1)
83
- activesupport (= 7.1.5.1)
84
- marcel (~> 1.0)
85
23
  activesupport (7.1.5.1)
86
24
  base64
87
25
  benchmark (>= 0.3)
@@ -103,26 +41,16 @@ GEM
103
41
  base64 (0.2.0)
104
42
  benchmark (0.4.0)
105
43
  bigdecimal (3.1.8)
106
- builder (3.3.0)
107
44
  byebug (11.1.3)
108
45
  coderay (1.1.3)
109
46
  concurrent-ruby (1.3.4)
110
47
  connection_pool (2.4.1)
111
- crass (1.0.6)
112
48
  csv (3.3.1)
113
- date (3.4.1)
114
49
  diff-lcs (1.5.1)
115
50
  docile (1.1.5)
116
51
  drb (2.2.1)
117
- erubi (1.13.0)
118
- globalid (1.2.1)
119
- activesupport (>= 6.1)
120
52
  i18n (1.14.6)
121
53
  concurrent-ruby (~> 1.0)
122
- io-console (0.8.0)
123
- irb (1.14.2)
124
- rdoc (>= 4.0.0)
125
- reline (>= 0.4.2)
126
54
  json (2.9.0)
127
55
  language_server-protocol (3.17.0.3)
128
56
  license_finder (7.2.1)
@@ -133,42 +61,11 @@ GEM
133
61
  tomlrb (>= 1.3, < 2.1)
134
62
  with_env (= 1.1.0)
135
63
  xml-simple (~> 1.1.9)
64
+ lint_roller (1.1.0)
136
65
  logger (1.6.3)
137
- loofah (2.23.1)
138
- crass (~> 1.0.2)
139
- nokogiri (>= 1.12.0)
140
- mail (2.8.1)
141
- mini_mime (>= 0.1.1)
142
- net-imap
143
- net-pop
144
- net-smtp
145
- marcel (1.0.4)
146
66
  method_source (1.1.0)
147
- mini_mime (1.1.5)
148
67
  minitest (5.25.4)
149
68
  mutex_m (0.3.0)
150
- net-imap (0.4.18)
151
- date
152
- net-protocol
153
- net-pop (0.1.2)
154
- net-protocol
155
- net-protocol (0.2.2)
156
- timeout
157
- net-smtp (0.5.0)
158
- net-protocol
159
- nio4r (2.7.4)
160
- nokogiri (1.17.2-aarch64-linux)
161
- racc (~> 1.4)
162
- nokogiri (1.17.2-arm-linux)
163
- racc (~> 1.4)
164
- nokogiri (1.17.2-arm64-darwin)
165
- racc (~> 1.4)
166
- nokogiri (1.17.2-x86-linux)
167
- racc (~> 1.4)
168
- nokogiri (1.17.2-x86_64-darwin)
169
- racc (~> 1.4)
170
- nokogiri (1.17.2-x86_64-linux)
171
- racc (~> 1.4)
172
69
  parallel (1.26.3)
173
70
  parser (3.3.6.0)
174
71
  ast (~> 2.4.1)
@@ -179,53 +76,11 @@ GEM
179
76
  pry-byebug (3.10.1)
180
77
  byebug (~> 11.0)
181
78
  pry (>= 0.13, < 0.15)
182
- psych (5.2.1)
183
- date
184
- stringio
185
79
  racc (1.8.1)
186
80
  rack (3.1.8)
187
- rack-session (2.0.0)
188
- rack (>= 3.0.0)
189
- rack-test (2.1.0)
190
- rack (>= 1.3)
191
- rackup (2.2.1)
192
- rack (>= 3)
193
- rails (7.1.5.1)
194
- actioncable (= 7.1.5.1)
195
- actionmailbox (= 7.1.5.1)
196
- actionmailer (= 7.1.5.1)
197
- actionpack (= 7.1.5.1)
198
- actiontext (= 7.1.5.1)
199
- actionview (= 7.1.5.1)
200
- activejob (= 7.1.5.1)
201
- activemodel (= 7.1.5.1)
202
- activerecord (= 7.1.5.1)
203
- activestorage (= 7.1.5.1)
204
- activesupport (= 7.1.5.1)
205
- bundler (>= 1.15.0)
206
- railties (= 7.1.5.1)
207
- rails-dom-testing (2.2.0)
208
- activesupport (>= 5.0.0)
209
- minitest
210
- nokogiri (>= 1.6)
211
- rails-html-sanitizer (1.6.2)
212
- loofah (~> 2.21)
213
- nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
214
- railties (7.1.5.1)
215
- actionpack (= 7.1.5.1)
216
- activesupport (= 7.1.5.1)
217
- irb
218
- rackup (>= 1.0.0)
219
- rake (>= 12.2)
220
- thor (~> 1.0, >= 1.2.2)
221
- zeitwerk (~> 2.6)
222
81
  rainbow (3.1.1)
223
82
  rake (13.2.1)
224
- rdoc (6.9.1)
225
- psych (>= 4.0.0)
226
83
  regexp_parser (2.9.3)
227
- reline (0.6.0)
228
- io-console (~> 0.5)
229
84
  rexml (3.4.0)
230
85
  rspec (3.13.0)
231
86
  rspec-core (~> 3.13.0)
@@ -240,17 +95,18 @@ GEM
240
95
  diff-lcs (>= 1.2.0, < 2.0)
241
96
  rspec-support (~> 3.13.0)
242
97
  rspec-support (3.13.2)
243
- rubocop (1.66.1)
98
+ rubocop (1.74.0)
244
99
  json (~> 2.3)
245
- language_server-protocol (>= 3.17.0)
100
+ language_server-protocol (~> 3.17.0.2)
101
+ lint_roller (~> 1.1.0)
246
102
  parallel (~> 1.10)
247
103
  parser (>= 3.3.0.2)
248
104
  rainbow (>= 2.2.2, < 4.0)
249
- regexp_parser (>= 2.4, < 3.0)
250
- rubocop-ast (>= 1.32.2, < 2.0)
105
+ regexp_parser (>= 2.9.3, < 3.0)
106
+ rubocop-ast (>= 1.38.0, < 2.0)
251
107
  ruby-progressbar (~> 1.7)
252
- unicode-display_width (>= 2.4.0, < 3.0)
253
- rubocop-ast (1.37.0)
108
+ unicode-display_width (>= 2.4.0, < 4.0)
109
+ rubocop-ast (1.39.0)
254
110
  parser (>= 3.3.1.0)
255
111
  rubocop-performance (1.23.0)
256
112
  rubocop (>= 1.48.1, < 2.0)
@@ -272,21 +128,15 @@ GEM
272
128
  json (>= 1.8, < 3)
273
129
  simplecov-html (~> 0.10.0)
274
130
  simplecov-html (0.10.2)
275
- stringio (3.1.2)
276
131
  thor (1.3.2)
277
- timeout (0.4.3)
278
132
  tomlrb (2.0.3)
279
133
  tzinfo (2.0.6)
280
134
  concurrent-ruby (~> 1.0)
281
135
  unicode-display_width (2.6.0)
282
- websocket-driver (0.7.6)
283
- websocket-extensions (>= 0.1.0)
284
- websocket-extensions (0.1.5)
285
136
  with_env (1.1.0)
286
137
  xml-simple (1.1.9)
287
138
  rexml
288
139
  yard (0.9.21)
289
- zeitwerk (2.6.18)
290
140
 
291
141
  PLATFORMS
292
142
  aarch64-linux
@@ -297,13 +147,14 @@ PLATFORMS
297
147
  x86_64-linux
298
148
 
299
149
  DEPENDENCIES
150
+ activemodel (~> 7.1.3)
151
+ activesupport (~> 7.1.3)
300
152
  aether_observatory!
301
153
  appraisal (~> 2.5.0)
302
154
  bundler (~> 2.1)
303
155
  license_finder (~> 7.0)
304
156
  pry (>= 0.14)
305
157
  pry-byebug (= 3.10.1)
306
- rails (~> 7.1.3)
307
158
  rake (~> 13.0)
308
159
  rspec (~> 3.0)
309
160
  rubocop-powerhome!
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AetherObservatory
4
+ module Backend
5
+ module Memory
6
+ module_function
7
+
8
+ def instrumented
9
+ @instrumented ||= []
10
+ end
11
+
12
+ def subscribed
13
+ @subscribed ||= {}
14
+ end
15
+
16
+ def instrument(event)
17
+ instrumented << event
18
+ end
19
+
20
+ def subscribe(topic, event)
21
+ subscribed[topic] ||= []
22
+ subscribed[topic] << event
23
+ end
24
+
25
+ def unsubscribe(topic)
26
+ subscribed.delete(topic)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AetherObservatory
4
+ module Backend
5
+ module Notifications
6
+ module_function
7
+
8
+ def instrument(event)
9
+ event.names.each do |event_name|
10
+ ActiveSupport::Notifications.instrument(event_name, event)
11
+ end
12
+ end
13
+
14
+ def subscribe(topic, event, *_args)
15
+ ActiveSupport::Notifications.subscribe(topic) do |*args|
16
+ event.name.constantize.new(ActiveSupport::Notifications::Event.new(*args)).process
17
+ end
18
+ end
19
+
20
+ def unsubscribe(topic)
21
+ ActiveSupport::Notifications.unsubscribe(topic)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -4,8 +4,6 @@ module AetherObservatory
4
4
  module Configuration
5
5
  include ActiveSupport::Configurable
6
6
 
7
- config_accessor(:logger) do
8
- defined?(Rails) ? Rails.logger : Logger.new($stdout)
9
- end
7
+ config_accessor :logger
10
8
  end
11
9
  end
@@ -7,6 +7,8 @@ module AetherObservatory
7
7
  include ActiveModel::AttributeAssignment
8
8
  include ActiveModel::Attributes
9
9
 
10
+ class_attribute :backend, default: AetherObservatory::Backend::Notifications
11
+
10
12
  class << self
11
13
  def inherited(subclass)
12
14
  super
@@ -14,14 +16,7 @@ module AetherObservatory
14
16
  end
15
17
 
16
18
  def create(**attributes)
17
- event = new(**attributes)
18
- event_names_with_prefix.each do |event_name_parts|
19
- event_name = event_name_parts.filter_map do |part|
20
- event.instance_exec(&part) unless part.nil?
21
- end.join(".")
22
- logger.debug("[#{name}] Create event for topic: [#{event_name}]")
23
- ActiveSupport::Notifications.instrument(event_name, event)
24
- end
19
+ backend.instrument new(**attributes)
25
20
 
26
21
  nil
27
22
  end
@@ -51,7 +46,7 @@ module AetherObservatory
51
46
  def logger(value = nil)
52
47
  @logger = value if value.present?
53
48
 
54
- @logger || AetherObservatory.config.logger
49
+ @logger || AetherObservatory.config.logger || Logger.new(nil)
55
50
  end
56
51
  end
57
52
 
@@ -62,5 +57,12 @@ module AetherObservatory
62
57
  super()
63
58
  assign_attributes(attributes) if attributes
64
59
  end
60
+
61
+ def names
62
+ prefix = instance_exec(&self.class.event_prefix) if self.class.event_prefix
63
+ self.class.event_names.map do |event_name|
64
+ [prefix, instance_exec(&event_name)].compact.join(".")
65
+ end
66
+ end
65
67
  end
66
68
  end
@@ -2,6 +2,8 @@
2
2
 
3
3
  module AetherObservatory
4
4
  class ObserverBase
5
+ class_attribute :backend, default: AetherObservatory::Backend::Notifications
6
+
5
7
  class << self
6
8
  def inherited(subclass)
7
9
  super
@@ -74,9 +76,7 @@ module AetherObservatory
74
76
 
75
77
  logger.debug("[#{name}] Registering subscription to topic: #{topic.inspect}")
76
78
 
77
- subscriptions[topic] = ActiveSupport::Notifications.subscribe(topic) do |*args|
78
- name.constantize.new(ActiveSupport::Notifications::Event.new(*args)).process
79
- end
79
+ subscriptions[topic] = backend.subscribe(topic, self)
80
80
  end
81
81
 
82
82
  def unregister_subscription_to(topic)
@@ -84,13 +84,13 @@ module AetherObservatory
84
84
 
85
85
  logger.debug("[#{name}] Unregistering subscription to topic: #{topic.inspect}")
86
86
 
87
- ActiveSupport::Notifications.unsubscribe(subscriptions.delete(topic))
87
+ backend.unsubscribe(subscriptions.delete(topic))
88
88
  end
89
89
 
90
90
  def logger(value = nil)
91
91
  @logger = value if value.present?
92
92
 
93
- @logger || AetherObservatory.config.logger
93
+ @logger || AetherObservatory.config.logger || Logger.new(nil)
94
94
  end
95
95
  end
96
96
 
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AetherObservatory
4
+ class Railtie < Rails::Railtie
5
+ initializer "aether_observatory.logger" do
6
+ AetherObservatory.config.logger ||= Rails.logger
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rspec/expectations"
4
+ require "aether_observatory/backend/memory"
5
+
6
+ RSpec::Matchers.define :create_event do |expected, **attrs|
7
+ match do |actual|
8
+ actual.call
9
+
10
+ AetherObservatory::Backend::Memory.instrumented.any? do |event|
11
+ (event.is_a?(expected) && attrs.empty?) || RSpec::Matchers::BuiltIn::HaveAttributes.new(attrs).matches?(event)
12
+ end
13
+ end
14
+
15
+ failure_message do |*|
16
+ "Block did not create a #{expected.inspect} #{attrs_message}"
17
+ end
18
+
19
+ failure_message_when_negated do |*|
20
+ "Block created event(s) #{expected.inspect} #{attrs_message}"
21
+ end
22
+
23
+ def supports_block_expectations?
24
+ true
25
+ end
26
+
27
+ def attrs_message
28
+ return unless expected[1].any?
29
+
30
+ expected[1].inspect
31
+ end
32
+ end
33
+
34
+ module AetherObservatory
35
+ module Rspec
36
+ module EventHelper
37
+ def self.included(base)
38
+ base.before { AetherObservatory::Backend::Memory.instrumented.clear }
39
+ base.around do |example|
40
+ current_backend = AetherObservatory::EventBase.backend
41
+ AetherObservatory::EventBase.backend = AetherObservatory::Backend::Memory
42
+ example.run
43
+ ensure
44
+ AetherObservatory::EventBase.backend = current_backend
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "aether_observatory/rspec/event_matcher"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AetherObservatory
4
- VERSION = "0.0.1pre4"
4
+ VERSION = "1.0.1"
5
5
  end
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "active_support/all"
4
+ require "aether_observatory/backend/notifications"
4
5
  require "aether_observatory/configuration"
6
+ require "aether_observatory/railtie" if defined?(Rails)
5
7
 
6
8
  module AetherObservatory
7
9
  mattr_accessor :configuration, default: Configuration
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aether_observatory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1pre4
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Terry Finn
8
8
  - Justin Stanczak
9
- autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2024-12-17 00:00:00.000000000 Z
11
+ date: 1980-01-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activemodel
@@ -174,13 +173,16 @@ extensions: []
174
173
  extra_rdoc_files: []
175
174
  files:
176
175
  - ".rubocop.yml"
176
+ - ".rubocop_todo.yml"
177
177
  - Appraisals
178
178
  - Gemfile
179
+ - Gemfile.lock
179
180
  - Rakefile
180
181
  - aether_observatory.gemspec
181
182
  - doc/dependency_decisions.yml
182
183
  - docs/CHANGELOG.md
183
184
  - docs/README.md
185
+ - gemfiles/.bundle/config
184
186
  - gemfiles/rails_6_0.gemfile
185
187
  - gemfiles/rails_6_0.gemfile.lock
186
188
  - gemfiles/rails_6_1.gemfile
@@ -191,9 +193,14 @@ files:
191
193
  - gemfiles/rails_7_1.gemfile.lock
192
194
  - lib/aether_observatory.rb
193
195
  - lib/aether_observatory/README.md
196
+ - lib/aether_observatory/backend/memory.rb
197
+ - lib/aether_observatory/backend/notifications.rb
194
198
  - lib/aether_observatory/configuration.rb
195
199
  - lib/aether_observatory/event_base.rb
196
200
  - lib/aether_observatory/observer_base.rb
201
+ - lib/aether_observatory/railtie.rb
202
+ - lib/aether_observatory/rspec.rb
203
+ - lib/aether_observatory/rspec/event_helper.rb
197
204
  - lib/aether_observatory/version.rb
198
205
  - mkdocs.yml
199
206
  homepage: https://github.com/powerhome/power-tools
@@ -204,7 +211,6 @@ metadata:
204
211
  homepage_uri: https://github.com/powerhome/power-tools
205
212
  source_code_uri: https://github.com/powerhome/power-tools
206
213
  changelog_uri: https://github.com/powerhome/power-tools/blob/main/packages/aether_observatory/docs/CHANGELOG.md
207
- post_install_message:
208
214
  rdoc_options: []
209
215
  require_paths:
210
216
  - lib
@@ -219,8 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
225
  - !ruby/object:Gem::Version
220
226
  version: '0'
221
227
  requirements: []
222
- rubygems_version: 3.5.22
223
- signing_key:
228
+ rubygems_version: 3.6.9
224
229
  specification_version: 4
225
230
  summary: Aether Observatory
226
231
  test_files: []