0.01
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Five services are supported for now: Basecamp, Campfire, FriendFeed, LightHouse and Twitter.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0
 Project Readme

Introduction¶ ↑

Post commit allows you to notify several services with a simple and elegant DSL. It currently supports 5 services:

  • Basecamp

  • Campfire

  • FriendFeed

  • LightHouse

  • Twitter

  • URL

Usage¶ ↑

To install Post Commit run the command

sudo gem install post_commit

and you’re good to go!

Basecamp¶ ↑

To send a Basecamp message you have to inform your subdomain, API token and project id.

post_commit :basecamp do
  authorize :subdomain => "mycompany", :token => "492bfe53dcd3", :project => 12345, :ssl => true
  post "Some title", "Some message"
end

Campfire¶ ↑

To send a Campfire message you have to inform your subdomain, API token and room id.

post_commit :campfire do
  authorize :subdomain => "mycompany", :token => "ec930a0f7fb1", :room => 12345
  post "Some message"
end

The Campfire hook supports 3 message types: text, paste and twitter.

post "Some message"
post "Some message", :type => :text
post "Some pasted code", :type => :paste
post "http://twitter.com/johndoe/statuses/12345", :type => :twitter

FriendFeed¶ ↑

To send a FriendFeed message you have to inform your username and API token.

post_commit :friendfeed do
  authorize :username => "johndoe", :token => "wow39dupa"
  post "Check it out this page", :url => "http://example.com"
end

LightHouse¶ ↑

To send a LightHouse message you have to inform your subdomain, API token and project id.

post_commit :lighthouse do
  authorize :subdomain => "mycompany", :token => "2aad05e8b", :project => 12345
  post "Some title", "Some message"
end

Twitter¶ ↑

To send a Twitter message you have to inform your username and password.

post_commit :twitter do
  authorize :username => "johndoe", :password => "mypass"
  post "Hi Twitter!"
end

The Twitter hook supports public and direct messages.

post "Hi Twitter!"
post "Hi Twitter!", :type => :status
post "Mary, check this out! http://example.com", :type => :direct_message, :screen_name => "marydoe"
post "Mary, check this out! http://example.com", :type => :direct_message, :user_id => 12345

URL¶ ↑

To send a message to an arbitrary URL, use the :url.

post_commit :url do
  post "http://example.com", :status => "pending", :id => 1234, :service => "yourapp"
end

If you need a basic authorization, just inform the username and password.

post_commit :url do
  authorize :username => "johndoe", :password => "mypass"
  post "http://example.com", :status => "running", :id => 1234, :service => "yourapp"
end

You can post data encoded as JSON or XML. Just set the :data_type option.

post_commit :url do
  set :data_type, :json
  set :data_type, :xml
end

To post a XML, your params hash need to be a multi-level hash. For instance, the hash {:message => { :title => "Some title", :body => "Some message" }} will be converted to

<message>
  <title>Some title</title>
  <body>Some message</body>
</message>

Gotcha: to send a normal POST, you have to specify a flat hash. So {:a => 1} is ok, but {:a => {:b => 1}} will fail.

Creating new hooks¶ ↑

To create a new hook, you can extend the PostCommit::Hooks::Base class, to bootstrap your own class.

class Email < PostCommit::Hooks::Base
  def post(message, to)
    ActionMailer::Base.smtp_settings = credentials

    # send the message
  end
end

Your new hook will be register automatically. By downcasing the class name. So, LightHouse will be registered as :lighthouse. To register this hook will other name, you just have to call the PostCommit::Hooks.register method.

PostCommit::Hooks.register :email, Email

Then you can use it through the post_commit method.

post_commit :email do
  authorize :address => "example.com", :user_name => "noreply", :password => "mypass", :authentication => :plain
  post "Some message", "mary@doe.com"
end

The authorize accepts anything you want. In this case, we’re providing all SMTP info we want to use. You can use the credentials attribute to retrieve these settings.

To-Do¶ ↑

  • Receive post commits

  • Create IRC hook

  • Create Jabber hook

  • Create email hook

  • All hooks should use the :url hook

Maintainer¶ ↑

Contributing¶ ↑

Once you’ve made your great commits:

  1. Fork the project at github.com/fnando/post_commit

  2. Create a topic branch - git checkout -b my_branch

  3. Push to your branch - git push origin my_branch

  4. Create an Issue with a link to your branch

  5. That’s it!

Please respect the indentation rules. And always use 2 spaces.

License¶ ↑

(The MIT License)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.