notifyor 0.6.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/notifyor/cli.rb +5 -1
- data/lib/notifyor/growl/adapters/terminal_notifier.rb +1 -1
- data/lib/notifyor/plugin.rb +18 -15
- data/lib/notifyor/remote/connection.rb +8 -7
- data/lib/notifyor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3597469e33a2bf62c10f7203d00db28746972634
|
4
|
+
data.tar.gz: 46b3de74767946442236bb8f710269f8746df609
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b686b1365d83e0e2560bfb2c177c3c794626640d6175ac4d5071da2d131347c6c3840b546d571b331646d87f7eb4f63f2c661063d371c33fd34651663f55b522
|
7
|
+
data.tar.gz: ce8de342bce81bea3ef428cbc7b0b335b5459a4b05327011c89d4be8f4e5286517cc9fc16e82816a31ef378f6e9ebde07eadfe65ac8e4f7f3f4d4b17d940e402
|
data/lib/notifyor/cli.rb
CHANGED
@@ -20,7 +20,7 @@ module Notifyor
|
|
20
20
|
end
|
21
21
|
|
22
22
|
opts.on('--ssh-host host', 'Provide the host address to your deployment/remote server') do |host|
|
23
|
-
|
23
|
+
ENV['ssh_host'] = host
|
24
24
|
end
|
25
25
|
|
26
26
|
opts.on('--ssh-port port', 'Provide the ssh port for the deployment/remote server') do |port|
|
@@ -38,6 +38,10 @@ module Notifyor
|
|
38
38
|
opts.on('--redis-port redis_port', 'Provide the ssh user for the deployment/remote server') do |redis_port|
|
39
39
|
ENV['ssh_redis_port'] = redis_port
|
40
40
|
end
|
41
|
+
|
42
|
+
opts.on('--channel [channel]', 'Provide channel on which notifyor should listen.') do |channel|
|
43
|
+
ENV['channel'] = channel
|
44
|
+
end
|
41
45
|
end.parse!
|
42
46
|
end
|
43
47
|
|
data/lib/notifyor/plugin.rb
CHANGED
@@ -15,20 +15,23 @@ module Notifyor
|
|
15
15
|
|
16
16
|
def configure_plugin(options = {})
|
17
17
|
configuration = default_configuration.deep_merge(options)
|
18
|
-
|
18
|
+
publish_channels = configuration[:channels] || ['notifyor']
|
19
|
+
append_callbacks(configuration, publish_channels)
|
19
20
|
end
|
20
21
|
|
21
|
-
def append_callbacks(configuration)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
22
|
+
def append_callbacks(configuration, publish_channels)
|
23
|
+
publish_channels.each do |channel|
|
24
|
+
configuration[:only].each do |action|
|
25
|
+
case action
|
26
|
+
when :create
|
27
|
+
self.after_commit -> { ::Notifyor.configuration.redis_connection.publish channel, configuration[:messages][:create].call(self) }, on: :create, if: -> { configuration[:only].include? :create }
|
28
|
+
when :update
|
29
|
+
self.after_commit -> { ::Notifyor.configuration.redis_connection.publish channel, configuration[:messages][:update].call(self) }, on: :update, if: -> { configuration[:only].include? :update }
|
30
|
+
when :destroy
|
31
|
+
self.before_destroy -> { ::Notifyor.configuration.redis_connection.publish channel, configuration[:messages][:destroy].call(self) }, if: -> { configuration[:only].include? :destroy }
|
32
|
+
else
|
33
|
+
#nop
|
34
|
+
end
|
32
35
|
end
|
33
36
|
end
|
34
37
|
end
|
@@ -37,9 +40,9 @@ module Notifyor
|
|
37
40
|
{
|
38
41
|
only: [:create, :destroy, :update],
|
39
42
|
messages: {
|
40
|
-
create: -> (model) { I18n.t('notifyor.model.create'
|
41
|
-
update: -> (model) { I18n.t('notifyor.model.update'
|
42
|
-
destroy: -> (model) { I18n.t('notifyor.model.destroy'
|
43
|
+
create: -> (model) { I18n.t('notifyor.model.create') },
|
44
|
+
update: -> (model) { I18n.t('notifyor.model.update') },
|
45
|
+
destroy: -> (model) { I18n.t('notifyor.model.destroy') }
|
43
46
|
}
|
44
47
|
}
|
45
48
|
end
|
@@ -8,11 +8,12 @@ module Notifyor
|
|
8
8
|
class Connection
|
9
9
|
|
10
10
|
def initialize
|
11
|
-
@ssh_host = ENV['ssh_host']
|
12
|
-
@ssh_port = ENV['ssh_port']
|
11
|
+
@ssh_host = ENV['ssh_host'] || 'localhost'
|
12
|
+
@ssh_port = ENV['ssh_port'] || '22'
|
13
13
|
@ssh_user = ENV['ssh_user']
|
14
|
-
@tunnel_port = ENV['ssh_tunnel_port']
|
15
|
-
@redis_port = ENV['ssh_redis_port']
|
14
|
+
@tunnel_port = ENV['ssh_tunnel_port'] || '2000'
|
15
|
+
@redis_port = ENV['ssh_redis_port'] || '6379'
|
16
|
+
@redis_channel = ENV['channel'] || 'notifyor'
|
16
17
|
@ssh_gateway = nil
|
17
18
|
@redis_tunnel_connection = nil
|
18
19
|
end
|
@@ -30,10 +31,10 @@ module Notifyor
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def subscribe_to_redis
|
33
|
-
@redis_tunnel_connection.subscribe(
|
34
|
+
@redis_tunnel_connection.subscribe(@redis_channel) do |on|
|
34
35
|
on.message do |channel, msg|
|
35
|
-
|
36
|
-
growl_message(
|
36
|
+
STDERR.write "INFO - Message received on channel: #{channel} \n"
|
37
|
+
growl_message(msg)
|
37
38
|
end
|
38
39
|
end
|
39
40
|
end
|
data/lib/notifyor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notifyor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erwin Schens
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|