post2irc 0.9.0 → 0.9.1

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.
data/Gemfile.lock CHANGED
@@ -1,10 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- post2irc (0.0.2)
4
+ post2irc (0.9.1)
5
5
  cinch
6
6
  json
7
7
  sinatra
8
+ xml-simple
8
9
 
9
10
  GEM
10
11
  remote: http://rubygems.org/
@@ -19,6 +20,7 @@ GEM
19
20
  rack-protection (~> 1.2)
20
21
  tilt (~> 1.3, >= 1.3.3)
21
22
  tilt (1.3.3)
23
+ xml-simple (1.1.1)
22
24
 
23
25
  PLATFORMS
24
26
  ruby
data/README.textile CHANGED
@@ -24,6 +24,11 @@ There is a built-in service hook for bitbucket, so you can receive alerts of you
24
24
 
25
25
  http://your_url:8080/public/sources/bitbucket/service
26
26
 
27
+
28
+ There us a built-in service hook for pivotal tracker, so you can receive notifications on story changes on irc. Go to the admin of your pivotal repository, look for project/integrations and add a webhook pointing to
29
+
30
+ http://your_url:8080/public/sources/pivotal/webhook
31
+
27
32
  Of course both the url and port must be accessible from the internet
28
33
 
29
34
 
data/bin/post2irc CHANGED
@@ -2,16 +2,18 @@
2
2
 
3
3
  begin
4
4
  require 'cinch'
5
- require 'sinatra'
5
+ require 'sinatra/base'
6
6
  require 'json'
7
+ require 'xmlsimple'
7
8
  require 'post2irc'
8
9
  rescue LoadError => e
9
10
  require 'rubygems'
10
11
  path = File.expand_path '../../lib', __FILE__
11
12
  $:.unshift(path) if File.directory?(path) && !$:.include?(path)
12
13
  require 'cinch'
13
- require 'sinatra'
14
+ require 'sinatra/base'
14
15
  require 'json'
16
+ require 'xmlsimple'
15
17
  require 'post2irc'
16
18
  end
17
19
 
@@ -1,10 +1,5 @@
1
1
  class Ircbot
2
2
  def self.start(server, port, channels, nickname)
3
- puts "XXX start"
4
- puts server
5
- puts port
6
- puts channels
7
- puts nickname
8
3
  @@channels = channels.split(',')
9
4
  @@bot = Cinch::Bot.new do
10
5
  configure do |c|
@@ -22,12 +22,12 @@ class SinatraListener < Sinatra::Base
22
22
  end
23
23
 
24
24
  post "/:prefix" do
25
- return UNAUTHORIZED unless authorized?(params[:prefix])
25
+ halt UNAUTHORIZED unless authorized?(params[:prefix])
26
26
  Ircbot.report string_cleaner(params[:q])
27
27
  end
28
28
 
29
29
  post "/:prefix/sources/bitbucket/service" do
30
- return UNAUTHORIZED unless authorized?(params[:prefix])
30
+ halt UNAUTHORIZED unless authorized?(params[:prefix])
31
31
  unless params[:payload].nil?
32
32
  payload=JSON.parse params[:payload]
33
33
  puts payload
@@ -36,8 +36,21 @@ class SinatraListener < Sinatra::Base
36
36
  repository_uri=payload['repository']['absolute_url']
37
37
  repository_name=payload['repository']['name']
38
38
 
39
- Ircbot.report string_cleaner( [repository_name, messages_authors, "#{base_uri}#{repository_uri}"].compact.join(' :: ') )
39
+ Ircbot.report string_cleaner( ['bitbucket', repository_name, messages_authors, "#{base_uri}#{repository_uri}"].compact.join(' :: ') )
40
40
  end
41
41
  end
42
+
43
+ post "/:prefix/sources/pivotal/webhook" do
44
+ halt UNAUTHORIZED unless authorized?(params[:prefix])
45
+ activity = XmlSimple.xml_in request.body.read
46
+
47
+ event_type = activity['event_type']
48
+ author = activity['author']
49
+ description = activity['description']
50
+ #we get the URLs and remove the /services/v3 so they will be accessed via direct link
51
+ stories_urls =activity['stories'].map{|s1| s1['story'].map{|s2| s2['url'] } }.flatten.join(' , ').gsub('/services/v3','') rescue nil
52
+
53
+ Ircbot.report string_cleaner( ['pivotal', event_type, author, description, stories_urls].compact.join(' :: ') )
54
+ end
42
55
  end
43
56
 
@@ -1,4 +1,4 @@
1
1
  module Post2irc
2
- VERSION = "0.9.0"
2
+ VERSION = "0.9.1"
3
3
  end
4
4
 
data/lib/post2irc.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  require "post2irc/version"
2
2
 
3
3
  require 'cinch'
4
- require 'sinatra'
4
+ require 'sinatra/base'
5
5
  require 'json'
6
+ require 'xmlsimple'
6
7
 
7
8
  require 'post2irc/ircbot'
8
9
  require 'post2irc/sinatra_listener'
data/post2irc.gemspec CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.add_dependency "sinatra"
23
23
  s.add_dependency "cinch"
24
24
  s.add_dependency "json"
25
+ s.add_dependency "xml-simple"
25
26
  s.required_ruby_version = '>= 1.9.1'
26
27
  end
27
28
 
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.9.0
4
+ version: 0.9.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-08-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sinatra
16
- requirement: &71760210 !ruby/object:Gem::Requirement
16
+ requirement: &82039780 !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: *71760210
24
+ version_requirements: *82039780
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: cinch
27
- requirement: &71758950 !ruby/object:Gem::Requirement
27
+ requirement: &82039410 !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: *71758950
35
+ version_requirements: *82039410
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: json
38
- requirement: &71758330 !ruby/object:Gem::Requirement
38
+ requirement: &82038880 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,18 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *71758330
46
+ version_requirements: *82038880
47
+ - !ruby/object:Gem::Dependency
48
+ name: xml-simple
49
+ requirement: &82038320 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *82038320
47
58
  description: This gem will start a sinatra script that will listen to posts and will
48
59
  publish the contents to an irc channel. No authentication is provided.
49
60
  email: