wisper_plus 0.1.1 → 0.1.6
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 +4 -4
- data/CHANGELOG.md +11 -1
- data/Gemfile.lock +36 -0
- data/lib/wisper_plus.rb +2 -3
- data/lib/wisper_plus/railtie.rb +61 -15
- data/lib/wisper_plus/version.rb +1 -1
- data/wisper_plus.gemspec +3 -3
- metadata +21 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: baabb826e9732fbf4c23623dc7792153c2f44eb84caf4a4c12899154983c83ad
|
4
|
+
data.tar.gz: c3687921c30c5a1df7eed1bf809382b4bc5fcd2820edde29aeceab8f31395daf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c0f7026ee5aee90a9197f2086152e3c588b706c7f732e1a54b58d3a5672f478a7564fca9ef7acf0dc9cbfc11a3628fd66338b553acb92527dae868442390de7
|
7
|
+
data.tar.gz: 3a7580bcc5d673590485722c0c90062348f0fa52eef60a6b842499d7219f0efdea64d9989af4616f5f1394fccbed0eb4a5d3fa3a1b036663990f953f593adead
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
wisper_plus (0.1.5)
|
5
|
+
activesupport (>= 6.0.3.1)
|
6
|
+
wisper (>= 1.6, < 3.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activesupport (6.1.4)
|
12
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
+
i18n (>= 1.6, < 2)
|
14
|
+
minitest (>= 5.1)
|
15
|
+
tzinfo (~> 2.0)
|
16
|
+
zeitwerk (~> 2.3)
|
17
|
+
concurrent-ruby (1.1.9)
|
18
|
+
i18n (1.8.10)
|
19
|
+
concurrent-ruby (~> 1.0)
|
20
|
+
minitest (5.14.4)
|
21
|
+
rake (13.0.3)
|
22
|
+
tzinfo (2.0.4)
|
23
|
+
concurrent-ruby (~> 1.0)
|
24
|
+
wisper (2.0.1)
|
25
|
+
zeitwerk (2.4.2)
|
26
|
+
|
27
|
+
PLATFORMS
|
28
|
+
ruby
|
29
|
+
|
30
|
+
DEPENDENCIES
|
31
|
+
bundler (>= 1.16, < 3.0)
|
32
|
+
rake (>= 12.3.3)
|
33
|
+
wisper_plus!
|
34
|
+
|
35
|
+
BUNDLED WITH
|
36
|
+
2.2.15
|
data/lib/wisper_plus.rb
CHANGED
@@ -34,7 +34,7 @@ module Wisper
|
|
34
34
|
# pass the set of changes for background jobs to know what changed
|
35
35
|
# see https://github.com/krisleech/wisper-activerecord/issues/17
|
36
36
|
def broadcast_update
|
37
|
-
broadcast(:after_update, self
|
37
|
+
broadcast(:after_update, self) if self.saved_changes?
|
38
38
|
end
|
39
39
|
|
40
40
|
# broadcast MODEL_destroyed to subscribed listeners
|
@@ -72,7 +72,6 @@ module Wisper
|
|
72
72
|
e
|
73
73
|
end
|
74
74
|
end
|
75
|
-
ap event
|
76
75
|
listener&.public_send(event, *args)
|
77
76
|
end
|
78
77
|
end
|
@@ -85,9 +84,9 @@ module Wisper
|
|
85
84
|
end
|
86
85
|
end
|
87
86
|
end
|
87
|
+
Wisper::ActiveJobBroadcaster.register
|
88
88
|
end
|
89
89
|
|
90
|
-
Wisper::ActiveJobBroadcaster.register
|
91
90
|
end
|
92
91
|
|
93
92
|
|
data/lib/wisper_plus/railtie.rb
CHANGED
@@ -2,28 +2,74 @@ require 'rails'
|
|
2
2
|
|
3
3
|
class WisperPlus::Railtie < Rails::Railtie
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
Dir.glob(Rails.root.join('app/models/**/*.rb').to_s) do |filename|
|
9
|
-
next if filename.index('/concerns/')
|
10
|
-
filename = filename.remove(Rails.root.join('app/models/').to_s)[0..-4]
|
11
|
-
klass = filename.camelize.constantize
|
12
|
-
next unless klass.ancestors.include?(ApplicationRecord)
|
5
|
+
def self.subscribe(model_klass, subscriber_klass)
|
6
|
+
model_class = model_klass
|
7
|
+
if model_class != 'Global'
|
13
8
|
begin
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
9
|
+
model_class = model_class.constantize
|
10
|
+
if !model_class.ancestors.include?(ApplicationRecord)
|
11
|
+
# puts "🔸 #{model_class} is not an ActiveRecord model".yellow
|
12
|
+
return
|
18
13
|
end
|
19
|
-
if !
|
20
|
-
puts "🔸 #{
|
14
|
+
if !model_class.ancestors.include?(Wisper::Publisher)
|
15
|
+
puts "🔸 #{model_class} is not including Wisper::ActiveRecord::Publisher. Cannot Subscribe #{subscriber_klass.magenta}.".yellow
|
16
|
+
return
|
21
17
|
end
|
22
18
|
rescue NameError
|
23
|
-
|
19
|
+
model_class = model_class.split("::")
|
20
|
+
model_class.pop
|
21
|
+
if model_class.size.positive?
|
22
|
+
model_class = model_class.join('::')
|
23
|
+
retry
|
24
|
+
else
|
25
|
+
puts "🔸 #{model_klass} not found"
|
26
|
+
return
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
begin
|
32
|
+
subscriber_klass = subscriber_klass.constantize
|
33
|
+
rescue NameError
|
34
|
+
puts "🔸 #{subscriber_klass} not found"
|
35
|
+
end
|
36
|
+
|
37
|
+
begin
|
38
|
+
if model_class != 'Global'
|
39
|
+
model_class.subscribe(subscriber_klass.new, async: false)
|
40
|
+
else
|
41
|
+
Wisper.subscribe(subscriber_klass.new)
|
24
42
|
end
|
43
|
+
rescue NoMethodError
|
44
|
+
puts "🔸 #{model_class}.subscribe() not found"
|
25
45
|
end
|
26
46
|
|
47
|
+
if Rails.env.development?
|
48
|
+
puts "🔹 #{subscriber_klass.to_s.magenta} => #{model_class.to_s.blue}"
|
49
|
+
end
|
27
50
|
end
|
28
51
|
|
52
|
+
config.to_prepare do
|
53
|
+
Wisper.clear if Rails.env.development?
|
54
|
+
|
55
|
+
# AUTOLINK models to subscribers if DB exists
|
56
|
+
if (::ActiveRecord::Base.connection rescue false)
|
57
|
+
# Link any Models to their <Model>Subscriber class
|
58
|
+
Dir.glob(Rails.root.join('app/subscribers/**/*.rb').to_s) do |filename|
|
59
|
+
filename = filename.remove(Rails.root.join('app/subscribers/').to_s)[0..-4]
|
60
|
+
subscriber_klass = filename.classify
|
61
|
+
model_klass = subscriber_klass.chomp("Subscriber")
|
62
|
+
WisperPlus::Railtie.subscribe(model_klass, subscriber_klass)
|
63
|
+
|
64
|
+
subscribers_dir = Rails.root.join('app','subscribers',filename)
|
65
|
+
if subscribers_dir.directory?
|
66
|
+
subscribers_dir.each_child do |fpath|
|
67
|
+
ap fpath
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
|
29
75
|
end
|
data/lib/wisper_plus/version.rb
CHANGED
data/wisper_plus.gemspec
CHANGED
@@ -30,10 +30,10 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
31
|
spec.require_paths = ["lib"]
|
32
32
|
|
33
|
-
spec.add_development_dependency "bundler", "
|
34
|
-
spec.add_development_dependency "rake", "
|
33
|
+
spec.add_development_dependency "bundler", ">= 1.16", '< 3.0'
|
34
|
+
spec.add_development_dependency "rake", ">= 12.3.3"
|
35
35
|
|
36
|
-
spec.add_runtime_dependency 'activesupport',
|
36
|
+
spec.add_runtime_dependency 'activesupport', ">= 6.0.3.1"
|
37
37
|
|
38
38
|
spec.add_dependency 'wisper', '>= 1.6', '< 3.0'
|
39
39
|
end
|
metadata
CHANGED
@@ -1,63 +1,63 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wisper_plus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Sharpe
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.16'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '3.0'
|
20
23
|
type: :development
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '1.16'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '3.0'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: rake
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- - "
|
37
|
+
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
39
|
+
version: 12.3.3
|
34
40
|
type: :development
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
|
-
- - "
|
44
|
+
- - ">="
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
46
|
+
version: 12.3.3
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: activesupport
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
51
|
- - ">="
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
48
|
-
- - "<"
|
49
|
-
- !ruby/object:Gem::Version
|
50
|
-
version: '6'
|
53
|
+
version: 6.0.3.1
|
51
54
|
type: :runtime
|
52
55
|
prerelease: false
|
53
56
|
version_requirements: !ruby/object:Gem::Requirement
|
54
57
|
requirements:
|
55
58
|
- - ">="
|
56
59
|
- !ruby/object:Gem::Version
|
57
|
-
version:
|
58
|
-
- - "<"
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version: '6'
|
60
|
+
version: 6.0.3.1
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: wisper
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- ".travis.yml"
|
92
92
|
- CHANGELOG.md
|
93
93
|
- Gemfile
|
94
|
+
- Gemfile.lock
|
94
95
|
- LICENSE.txt
|
95
96
|
- README.md
|
96
97
|
- Rakefile
|
@@ -104,7 +105,7 @@ homepage: ''
|
|
104
105
|
licenses:
|
105
106
|
- MIT
|
106
107
|
metadata: {}
|
107
|
-
post_install_message:
|
108
|
+
post_install_message:
|
108
109
|
rdoc_options: []
|
109
110
|
require_paths:
|
110
111
|
- lib
|
@@ -119,9 +120,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
120
|
- !ruby/object:Gem::Version
|
120
121
|
version: '0'
|
121
122
|
requirements: []
|
122
|
-
|
123
|
-
|
124
|
-
signing_key:
|
123
|
+
rubygems_version: 3.2.15
|
124
|
+
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: Handy additions to Wisper
|
127
127
|
test_files: []
|