notifyor 0.6.0 → 0.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a861fe6c36b3592bf74b9afe711ab8de22618cea
4
- data.tar.gz: ecb693808505195952efaccc89b6a5f96037e2d3
3
+ metadata.gz: 3597469e33a2bf62c10f7203d00db28746972634
4
+ data.tar.gz: 46b3de74767946442236bb8f710269f8746df609
5
5
  SHA512:
6
- metadata.gz: 16cf82af9309476da346619354c0c494d1716b10eecd01f260340903df8f7f178e7f3f933a0c56f601ae0359fa6b48c185594724d4e1c38c90c9ce2fbb420314
7
- data.tar.gz: b9c667ad5bef798beacb48b6d403083bdb63bbd134266f2344969f9aaed79e579a0f16b636774719a0d47b2ee98786fbd0d8f12cfb8d8bbb930b30771360143b
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
- ENV['ssh_host'] = host
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
 
@@ -5,7 +5,7 @@ module Notifyor
5
5
  extend self
6
6
 
7
7
  def create_growl(title, message)
8
- %x(terminal-notifier -title '#{title}' -message '#{message}' -contentImage 'http://i.imgur.com/FrRacwt.png?1')
8
+ %x(terminal-notifier -title '#{title}' -message '#{message}')
9
9
  end
10
10
 
11
11
  end
@@ -15,20 +15,23 @@ module Notifyor
15
15
 
16
16
  def configure_plugin(options = {})
17
17
  configuration = default_configuration.deep_merge(options)
18
- append_callbacks(configuration)
18
+ publish_channels = configuration[:channels] || ['notifyor']
19
+ append_callbacks(configuration, publish_channels)
19
20
  end
20
21
 
21
- def append_callbacks(configuration)
22
- configuration[:only].each do |action|
23
- case action
24
- when :create
25
- self.after_commit -> { ::Notifyor.configuration.redis_connection.publish "notifyor", {message: configuration[:messages][:create].call(self)}.to_json }, on: :create, if: -> { configuration[:only].include? :create }
26
- when :update
27
- self.after_commit -> { ::Notifyor.configuration.redis_connection.publish "notifyor", {message: configuration[:messages][:update].call(self)}.to_json }, on: :update, if: -> { configuration[:only].include? :update }
28
- when :destroy
29
- self.before_destroy -> { ::Notifyor.configuration.redis_connection.publish "notifyor", {message: configuration[:messages][:destroy].call(self)}.to_json }, if: -> { configuration[:only].include? :destroy }
30
- else
31
- #nop
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', model: model.class.model_name.human) },
41
- update: -> (model) { I18n.t('notifyor.model.update', model: model.class.model_name.human) },
42
- destroy: -> (model) { I18n.t('notifyor.model.destroy', model: model.class.model_name.human) }
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('notifyor') do |on|
34
+ @redis_tunnel_connection.subscribe(@redis_channel) do |on|
34
35
  on.message do |channel, msg|
35
- data = ::JSON.parse(msg)
36
- growl_message(data['message'])
36
+ STDERR.write "INFO - Message received on channel: #{channel} \n"
37
+ growl_message(msg)
37
38
  end
38
39
  end
39
40
  end
@@ -1,3 +1,3 @@
1
1
  module Notifyor
2
- VERSION = "0.6.0"
2
+ VERSION = "0.8.0"
3
3
  end
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.6.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-08 00:00:00.000000000 Z
11
+ date: 2016-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis