notifyor 0.3.1 → 0.3.2

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: 18ab8b7e2791a9d95c00dc7a739d23b2022135e7
4
- data.tar.gz: f283a8c0f16dd22e39288fc49a54348a11b178f5
3
+ metadata.gz: c0b21b40fea27da456c9d5861f5186571379f7ef
4
+ data.tar.gz: 3e2eaa99002718566ad4b315c5f0455801eb0158
5
5
  SHA512:
6
- metadata.gz: 9fef1442cd600794cd96ba16a85e1af9ff7a8b4d4bf1e4ad43d5237a556221d7a6b15cab33aa38b3a9218c9483caf9fc1ab086c45c28d4030786bbcb24e8beb5
7
- data.tar.gz: 25f2afe9f262a6311472fbf419e303340cd6c82522307ca3a1583a2c239d04274f50e0837734feff4d1cd2fc8d4115eb5007b38db50561f463e6b9db7a67c1bc
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
- ENV['ssh_host'] = host
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(::Notifyor.configuration.ssh_host)
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
- @ssh_host = 'localhost'
16
+ @ssh_port = 22
14
17
  end
15
18
  end
16
19
  end
@@ -0,0 +1,6 @@
1
+ module Notifyor
2
+ module Errors
3
+ class SSHError < StandardError
4
+ end
5
+ end
6
+ 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
@@ -19,7 +19,7 @@ module Notifyor
19
19
  end
20
20
 
21
21
  def append_callbacks
22
- self.send(:before_save, -> { self.class.events << I18n.t('notifyor.model.create', model: self.model_name.human) })
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(ssh_host)
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(ssh #{@ssh_host} 'redis-cli LPOP notifyor:#{model_name}')
30
+ %x(#{build_ssh_cmd} '#{build_redis_cmd(model_name)}')
15
31
  end
16
32
 
17
33
  def growl_message(model_name)
@@ -1,3 +1,3 @@
1
1
  module Notifyor
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
@@ -1,3 +1,4 @@
1
1
  Notifyor.configure do |config|
2
2
  config.ssh_host = 'rossbruch'
3
+ config.ssh_port = 10110
3
4
  end
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.1
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