post2irc 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,15 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- post2irc (0.0.1)
5
- cinch
4
+ post2irc (0.0.2)
6
5
  cinch
6
+ json
7
7
  sinatra
8
8
 
9
9
  GEM
10
10
  remote: http://rubygems.org/
11
11
  specs:
12
12
  cinch (2.0.3)
13
+ json (1.6.1)
13
14
  rack (1.4.1)
14
15
  rack-protection (1.2.0)
15
16
  rack
data/README.textile ADDED
@@ -0,0 +1,26 @@
1
+ Post2irc gem by by javier ramirez
2
+ ======================================
3
+
4
+ This gem will start a sinatra script that will listen to posts and will publish the contents to an irc channel. No authentication is provided.
5
+
6
+ You can just install the gem and run the provided post2irc command with appropriate parameters
7
+
8
+ post2irc "irc.freenode.net" "6667" "#your_channel" "nickname" "0.0.0.0" "8080"
9
+
10
+
11
+ This would connect to the irc server "irc.freenode.net" at port 6667 entering the channel "#your_channel" using the nickname "nickname"
12
+
13
+ The local webserver would listen on the 0.0.0.0 interface at port 8080
14
+
15
+ Now you can issue a post like this
16
+
17
+ curl -X POST http://localhost:8080?q=hi
18
+
19
+ and you should see the bot saying "hi" on IRC
20
+
21
+
22
+ There is a built-in service hook for bitbucket, so you can receive alerts of your commits on irc. Go to the admin of your bitbucket repository, look for services and select the POST service. Now just enter this value for the URL
23
+ http://your_url:8080/sources/bitbucket/service
24
+
25
+ Of course both the url and port must be accessible from the internet
26
+
data/bin/post2irc CHANGED
@@ -3,6 +3,7 @@
3
3
  begin
4
4
  require 'cinch'
5
5
  require 'sinatra'
6
+ require 'json'
6
7
  require 'post2irc'
7
8
  rescue LoadError => e
8
9
  require 'rubygems'
@@ -10,6 +11,7 @@ rescue LoadError => e
10
11
  $:.unshift(path) if File.directory?(path) && !$:.include?(path)
11
12
  require 'cinch'
12
13
  require 'sinatra'
14
+ require 'json'
13
15
  require 'post2irc'
14
16
  end
15
17
 
@@ -9,8 +9,26 @@ class SinatraListener < Sinatra::Base
9
9
  self.run!
10
10
  end
11
11
 
12
+ def string_cleaner(message)
13
+ #remove all non printable characters and replace with a dot
14
+ message.gsub /[^[:print:]]/m, "."
15
+ end
16
+
12
17
  post "/" do
13
- Ircbot.report params[:q]
18
+ Ircbot.report string_cleaner(params[:q])
19
+ end
20
+
21
+ post "/sources/bitbucket/service" do
22
+ unless params[:payload].nil?
23
+ payload=JSON.parse params[:payload]
24
+ puts payload
25
+ messages_authors=payload['commits'].map{|c| "#{c['message']} (#{c['author']})"}.join(',') rescue nil
26
+ base_uri=payload['canon_url']
27
+ repository_uri=payload['repository']['absolute_url']
28
+ repository_name=payload['repository']['name']
29
+
30
+ Ircbot.report string_cleaner( [repository_name, messages_authors, "#{base_uri}#{repository_uri}"].compact.join(' :: ') )
31
+ end
14
32
  end
15
33
  end
16
34
 
@@ -1,4 +1,4 @@
1
1
  module Post2irc
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
4
4
 
data/lib/post2irc.rb CHANGED
@@ -2,6 +2,7 @@ require "post2irc/version"
2
2
 
3
3
  require 'cinch'
4
4
  require 'sinatra'
5
+ require 'json'
5
6
 
6
7
  require 'post2irc/ircbot'
7
8
  require 'post2irc/sinatra_listener'
Binary file
data/post2irc.gemspec CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  # specify any dependencies here; for example:
22
22
  s.add_dependency "sinatra"
23
23
  s.add_dependency "cinch"
24
- s.add_runtime_dependency "cinch"
24
+ s.add_dependency "json"
25
25
  s.required_ruby_version = '>= 1.9.1'
26
26
  end
27
27
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: post2irc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-08-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
16
- requirement: &80546200 !ruby/object:Gem::Requirement
16
+ requirement: &74975570 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *80546200
24
+ version_requirements: *74975570
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: cinch
27
- requirement: &80538470 !ruby/object:Gem::Requirement
27
+ requirement: &74974310 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *80538470
35
+ version_requirements: *74974310
36
36
  - !ruby/object:Gem::Dependency
37
- name: cinch
38
- requirement: &80538060 !ruby/object:Gem::Requirement
37
+ name: json
38
+ requirement: &74973690 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *80538060
46
+ version_requirements: *74973690
47
47
  description: This gem will start a sinatra script that will listen to posts and will
48
48
  publish the contents to an irc channel. No authentication is provided.
49
49
  email:
@@ -55,6 +55,7 @@ extra_rdoc_files: []
55
55
  files:
56
56
  - Gemfile
57
57
  - Gemfile.lock
58
+ - README.textile
58
59
  - Rakefile
59
60
  - bin/post2irc
60
61
  - lib/post2irc.rb
@@ -62,6 +63,7 @@ files:
62
63
  - lib/post2irc/sinatra_listener.rb
63
64
  - lib/post2irc/version.rb
64
65
  - pkg/post2irc-0.0.1.gem
66
+ - pkg/post2irc-0.0.2.gem
65
67
  - post2irc.gemspec
66
68
  homepage: http://javier-ramirez.com
67
69
  licenses: []