cinch-deploy 1.0.5 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cinch/plugins/deploy.rb +30 -12
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45a0f8f0d40417a383245e3264d213824248ebd6
4
- data.tar.gz: 4ab32e9c7f8c433696a48a87cbf952c5f4803180
3
+ metadata.gz: 71d6e5426915fbf6bab8a3bd8059733da00c8c15
4
+ data.tar.gz: ebc5ca49e1f3cafcff25f9cd4d2e99810e07d23d
5
5
  SHA512:
6
- metadata.gz: aacb2604aefe74d49edcc4a6f758273976be9a0366478c480bf80cfc03f706d74db29d2129c7ade12add74fa7425c70ebe3b5e15bd5c31c1bce10a438ed59549
7
- data.tar.gz: f4e24bc44220c243b342ada46e00c283868d1200d40141c6d7064512e1e07c67238b64ba190360976d525d4809735ff5d4093880d2ac8b33a7fb7969a71dc3e7
6
+ metadata.gz: 1b9c630db5be4a171b947bf42cbd0b689819eb94e0d5297da33aee3bf34fd791235f69508a8247174fdddaf7b5752a167b7e7a01d7e94c6211445d4bdcdd1d55
7
+ data.tar.gz: 10794d420d1309d15e7958775dddc6a07aec4b87eae762d5c7a914d552fbfd0c472bb87b65408eabed6737f8829d5b42a53d0175f31fc737c1839b81a22522ec
@@ -3,25 +3,43 @@ module Cinch
3
3
  class Deploy
4
4
  include Cinch::Plugin
5
5
 
6
+ def initialize
7
+ @running = {}
8
+ end
9
+
6
10
  listen_to :message
7
11
 
8
12
  def listen(m)
9
- return if @running
10
- @running = true
11
13
  config[:configurations].each do |config|
12
- if config[:channels].include?(m.channel.to_s) and config[:users].include?(m.user.nick) and m.message =~ Regexp.new(config[:trigger])
13
- IO.popen("#{config[:command]} 2>&1") do |handle|
14
- while line = handle.gets
15
- m.reply "#{config[:command]} > #{line}", true
16
- end
17
- end
18
- end
14
+ deploy(m) if can_deploy?(m)
19
15
  end
20
16
  rescue Exception => e
21
- m.reply "#{config[:command]} - exception: #{e.message}", true
22
- puts e.backtrace
17
+ m.reply "exception - #{e.message}", true
18
+ exception(e)
19
+ end
20
+
21
+ private
22
+
23
+ def can_deploy?(m)
24
+ config[:channels].include?(m.channel.to_s) &&
25
+ config[:users].include?(m.user.nick) &&
26
+ m.message =~ Regexp.new(config[:trigger])
27
+ end
28
+
29
+ def deploy(m)
30
+ return if @running[command]
31
+ @running[command] = true
32
+ IO.popen("#{command} 2>&1") do |handle|
33
+ while line = handle.gets
34
+ m.reply "#{command} > #{line}", true
35
+ end
36
+ end
23
37
  ensure
24
- @running = nil
38
+ @running.delete(command)
39
+ end
40
+
41
+ def command
42
+ config[:command]
25
43
  end
26
44
 
27
45
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cinch-deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michal Papis
@@ -54,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
54
  version: '0'
55
55
  requirements: []
56
56
  rubyforge_project:
57
- rubygems_version: 2.1.11
57
+ rubygems_version: 2.2.0
58
58
  signing_key:
59
59
  specification_version: 4
60
60
  summary: A Cinch plugin to start deploy process via irc messages.