Skip to content

Commit

Permalink
Merge branch 'andyburke-0ea07df'
Browse files Browse the repository at this point in the history
  • Loading branch information
technoweenie committed Nov 18, 2010
2 parents b4989e6 + 5762ff2 commit 5952657
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 7 deletions.
3 changes: 2 additions & 1 deletion CONTRIBUTORS
Expand Up @@ -2,6 +2,7 @@ Thanks to the following people for making this possible
-------------------------------------------------------

- Arun Thampi
- Andy Burke
- Blake Mizerany
- Brandon Keepers
- Bryan Drewery
Expand Down Expand Up @@ -39,4 +40,4 @@ Thanks to the following people for making this possible
- Nicholas Seemiller, Mark Michael, Glen Ivey
- Jason Salaz
- Sebastian Staudt
- Robert Boyd
- Robert Boyd
19 changes: 19 additions & 0 deletions docs/grmble
@@ -0,0 +1,19 @@
Grmble
========

Install Notes
-------------

1. room_api_url should be your room's API url from your room's admin page
Eg: http://grmble.com/api/room/ROOMKEY
2. token should be the API key from your room's admin page

Developer Notes
---------------

data
- room_api_url
- token

payload
- refer to docs/github_payload
15 changes: 10 additions & 5 deletions github-services.rb
Expand Up @@ -82,7 +82,7 @@ def service(name)
# redact sensitive info in hook_data hash
hook_data = data || params[:data]
hook_payload = payload || params[:payload]
%w[password token].each { |key| hook_data[key] &&= '<redacted>' }
#%w[password token].each { |key| hook_data[key] &&= '<redacted>' }
owner = hook_payload['repository']['owner']['name'] rescue nil
repo = hook_payload['repository']['name'] rescue nil
report_exception boom,
Expand Down Expand Up @@ -115,8 +115,6 @@ def shorten_url(url)
end

def report_exception(exception, other)
# run only in github's production environment
return if HOSTNAME != 'sh1.rs.github.com'

backtrace = Array(exception.backtrace)[0..500]

Expand All @@ -143,8 +141,15 @@ def report_exception(exception, other)
# optional
other.each { |key, value| data[key.to_s] = value.to_s }

Net::HTTP.new('aux1', 9292).
post('/haystack/async', "json=#{Rack::Utils.escape(data.to_json)}")
if HOSTNAME == 'sh1.rs.github.com'
# run only in github's production environment
Net::HTTP.new('aux1', 9292).
post('/haystack/async', "json=#{Rack::Utils.escape(data.to_json)}")
else
$stderr.puts data[ 'message' ]
$stderr.puts data[ 'backtrace' ]
end

rescue => boom
$stderr.puts "reporting exception failed:"
$stderr.puts "#{boom.class}: #{boom}"
Expand Down
3 changes: 2 additions & 1 deletion script/deliver_payload
Expand Up @@ -15,4 +15,5 @@ hash = eval(payload_file.read)
data_json = JSON.generate(hash["data"])
payload_json = JSON.generate(hash["payload"])

exec "curl --data-binary 'data=#{data_json}&payload=#{payload_json}' http://localhost:8080/#{ARGV[0]}/"
File.open( "docs/payload_data", 'w' ) { |f| f.write( "data=#{data_json}&payload=#{payload_json}" ) }
exec "curl --data-binary @docs/payload_data http://localhost:8080/#{ARGV[0]}/"
25 changes: 25 additions & 0 deletions services/grmble.rb
@@ -0,0 +1,25 @@
service :grmble do |data, payload|
url = URI.parse("#{data['room_api_url']}/msg/")
repository = payload[ 'repository' ][ 'name' ]
branch = payload[ 'ref_name' ]
commits = payload[ 'commits' ]

$stdout.puts url

commits.each do |commit|
message = {
'nickname' => 'github',
'content' => "[#{repository}/#{branch}] #{commit['message']} - #{commit['author']['name']} #{commit['url']}",
'apiKey' => data[ 'token' ],
'type' => 'message',
}


req = Net::HTTP::Post.new( url.path )
req.set_form_data( 'message' => JSON.generate( message ) )

http = Net::HTTP.new( url.host, url.port )
http.use_ssl = true if url.port == 443 || url.instance_of?( URI::HTTPS )
http.start { |http| http.request( req ) }
end
end

0 comments on commit 5952657

Please sign in to comment.