wisper_plus 0.1.3 → 0.1.4
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 +8 -1
- data/lib/wisper_plus/railtie.rb +58 -16
- data/lib/wisper_plus/version.rb +1 -1
- data/wisper_plus.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b983012a8318f5055600e1ec96302dcb8eb1b24563d5b0ad6650d686dfebd53
|
4
|
+
data.tar.gz: 9a5bbd463fec537212d446dda329d198d451eb7f5bb5726ef6c77f40a9c86986
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76026e2a0de474cca4e9de38a473b819365025214f44d36f1894e9edc1f3db73cdff14881facf14270bbe89717f95d495b30807d894172b3e0ddd04fa24ead20
|
7
|
+
data.tar.gz: a7483b72f8a6c451bdad41a4f5931109e88c5ec4e7f0d320b7a787f0652cb0c4db90fa45f124fb1a06ef56e4d2ac6377ddff049e0304c41ffcba8789ef8951cf
|
data/CHANGELOG.md
CHANGED
data/lib/wisper_plus/railtie.rb
CHANGED
@@ -2,32 +2,74 @@ require 'rails'
|
|
2
2
|
|
3
3
|
class WisperPlus::Railtie < Rails::Railtie
|
4
4
|
|
5
|
+
def self.subscribe(model_klass, subscriber_klass)
|
6
|
+
model_class = model_klass
|
7
|
+
if model_class != 'Global'
|
8
|
+
begin
|
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
|
13
|
+
end
|
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
|
17
|
+
end
|
18
|
+
rescue NameError
|
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)
|
42
|
+
end
|
43
|
+
rescue NoMethodError
|
44
|
+
puts "🔸 #{model_class}.subscribe() not found"
|
45
|
+
end
|
46
|
+
|
47
|
+
if Rails.env.development?
|
48
|
+
puts "🔹 #{subscriber_klass.to_s.magenta} => #{model_class.to_s.blue}"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
5
52
|
config.to_prepare do
|
6
53
|
Wisper.clear if Rails.env.development?
|
7
54
|
|
8
55
|
# AUTOLINK models to subscribers if DB exists
|
9
56
|
if (::ActiveRecord::Base.connection rescue false)
|
10
57
|
# Link any Models to their <Model>Subscriber class
|
11
|
-
Dir.glob(Rails.root.join('app/
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
if !klass.ancestors.include?(Wisper::Publisher)
|
23
|
-
puts "🔸 #{klass} is not including Wisper::ActiveRecord::Publisher".yellow
|
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
|
24
68
|
end
|
25
|
-
rescue NameError
|
26
|
-
# ignore
|
27
69
|
end
|
28
70
|
end
|
29
71
|
end
|
30
|
-
|
31
72
|
end
|
32
73
|
|
74
|
+
|
33
75
|
end
|
data/lib/wisper_plus/version.rb
CHANGED
data/wisper_plus.gemspec
CHANGED
@@ -30,7 +30,7 @@ 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", "
|
33
|
+
spec.add_development_dependency "bundler", ">= 1.16"
|
34
34
|
spec.add_development_dependency "rake", "~> 10.0"
|
35
35
|
|
36
36
|
spec.add_runtime_dependency 'activesupport', '>= 3', '< 6'
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
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.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Sharpe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-01-
|
11
|
+
date: 2019-01-25 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
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.16'
|
27
27
|
- !ruby/object:Gem::Dependency
|