notifyor 0.3.1 → 0.3.2
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 +14 -2
- data/lib/notifyor/configuration.rb +4 -1
- data/lib/notifyor/errors/ssh_error.rb +6 -0
- data/lib/notifyor/growl/adapters/terminal_notifier.rb +1 -1
- data/lib/notifyor/plugin.rb +1 -1
- data/lib/notifyor/remote/connection.rb +20 -4
- data/lib/notifyor/version.rb +1 -1
- data/spec/test_app/config/initializers/notifyor.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0b21b40fea27da456c9d5861f5186571379f7ef
|
4
|
+
data.tar.gz: 3e2eaa99002718566ad4b315c5f0455801eb0158
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2aab52e0d9708cd1abb8cc591212ee57cb172271586a7ded0370491b99b04b10b0f1c1167f5019224ec6cf10557603e33f2a4b788a58b0b4209a0bfef36b5022
|
7
|
+
data.tar.gz: 39f3a39d4ee3d0d94d7b8bfca06deb21fe5ae6fe5edd5accdf6c80c7a911bff6e45d682cf3e2faa6fdc0adccdc7b572ce685c7cc4470aa01f0d9c764ca87f3f0
|
data/lib/notifyor/cli.rb
CHANGED
@@ -20,7 +20,19 @@ 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
|
+
::Notifyor.configuration.ssh_host = host
|
24
|
+
end
|
25
|
+
|
26
|
+
opts.on('--ssh-password password', 'Provide the ssh password for the deployment/remote server') do |password|
|
27
|
+
::Notifyor.configuration.ssh_password = password
|
28
|
+
end
|
29
|
+
|
30
|
+
opts.on('--ssh-port port', 'Provide the ssh port for the deployment/remote server') do |port|
|
31
|
+
::Notifyor.configuration.ssh_port = port
|
32
|
+
end
|
33
|
+
|
34
|
+
opts.on('--ssh-user user', 'Provide the ssh user for the deployment/remote server') do |user|
|
35
|
+
::Notifyor.configuration.ssh_user = user
|
24
36
|
end
|
25
37
|
end.parse!
|
26
38
|
end
|
@@ -28,7 +40,7 @@ module Notifyor
|
|
28
40
|
def check_notifications
|
29
41
|
loop do
|
30
42
|
::Notifyor.configuration.notifyor_models.each do |model|
|
31
|
-
connection = Notifyor::Remote::Connection.new
|
43
|
+
connection = Notifyor::Remote::Connection.new
|
32
44
|
connection.growl_message(model.tableize)
|
33
45
|
end
|
34
46
|
sleep 5
|
@@ -5,12 +5,15 @@ module Notifyor
|
|
5
5
|
attr_accessor :redis_connection
|
6
6
|
attr_accessor :notifyor_models
|
7
7
|
attr_accessor :ssh_host
|
8
|
+
attr_accessor :ssh_user
|
9
|
+
attr_accessor :ssh_password
|
10
|
+
attr_accessor :ssh_port
|
8
11
|
|
9
12
|
def initialize
|
10
13
|
@redis_connection = ::Redis.new
|
11
14
|
Redis::Objects.redis = ::ConnectionPool.new(size: 5, timeout: 5) { @redis_connection }
|
12
15
|
@notifyor_models = Set.new
|
13
|
-
@
|
16
|
+
@ssh_port = 22
|
14
17
|
end
|
15
18
|
end
|
16
19
|
end
|
@@ -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}' -contentImage 'http://i.imgur.com/FrRacwt.png?1')
|
9
9
|
end
|
10
10
|
|
11
11
|
end
|
data/lib/notifyor/plugin.rb
CHANGED
@@ -19,7 +19,7 @@ module Notifyor
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def append_callbacks
|
22
|
-
self.send(:
|
22
|
+
self.send(:before_create, -> { self.class.events << I18n.t('notifyor.model.create', model: self.model_name.human) })
|
23
23
|
self.send(:before_destroy, -> { self.class.events << I18n.t('notifyor.model.delete', model: self.model_name.human) })
|
24
24
|
end
|
25
25
|
|
@@ -1,17 +1,33 @@
|
|
1
1
|
require 'redis-objects'
|
2
|
+
require 'notifyor'
|
2
3
|
require 'notifyor/growl'
|
3
4
|
require 'notifyor/util/formatter'
|
5
|
+
require 'notifyor/errors/ssh_error'
|
4
6
|
module Notifyor
|
5
7
|
module Remote
|
6
8
|
class Connection
|
7
|
-
attr_accessor :ssh_host
|
8
9
|
|
9
|
-
def initialize
|
10
|
-
@ssh_host = ssh_host
|
10
|
+
def initialize
|
11
|
+
@ssh_host = ::Notifyor.configuration.ssh_host
|
12
|
+
@ssh_password = ::Notifyor.configuration.ssh_password
|
13
|
+
@ssh_port = ::Notifyor.configuration.ssh_port
|
14
|
+
@ssh_user = ::Notifyor.configuration.ssh_user
|
15
|
+
end
|
16
|
+
|
17
|
+
def build_ssh_cmd
|
18
|
+
if @ssh_host.blank?
|
19
|
+
raise ::Notifyor::Errors::SSHError, "no ssh host provided. Provide a host with the --ssh-host option or set it in your configuration."
|
20
|
+
end
|
21
|
+
ssh_cmd = @ssh_user.present? ? "ssh #{@ssh_user}:#{@ssh_password}@#{@ssh_host}" : "ssh #{@ssh_host}"
|
22
|
+
ssh_cmd + " -p#{@ssh_port ? @ssh_port : 22}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def build_redis_cmd(model_name)
|
26
|
+
"redis-cli LPOP notifyor:#{model_name}"
|
11
27
|
end
|
12
28
|
|
13
29
|
def retrieve_value(model_name)
|
14
|
-
%x(
|
30
|
+
%x(#{build_ssh_cmd} '#{build_redis_cmd(model_name)}')
|
15
31
|
end
|
16
32
|
|
17
33
|
def growl_message(model_name)
|
data/lib/notifyor/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notifyor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erwin Schens
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- lib/notifyor.rb
|
111
111
|
- lib/notifyor/cli.rb
|
112
112
|
- lib/notifyor/configuration.rb
|
113
|
+
- lib/notifyor/errors/ssh_error.rb
|
113
114
|
- lib/notifyor/growl.rb
|
114
115
|
- lib/notifyor/growl/adapters/terminal_notifier.rb
|
115
116
|
- lib/notifyor/plugin.rb
|