Skip to content
Browse files

Planio <3 GitHub! We now support external repos hosted at Github!

  • Loading branch information...
1 parent c82b5da commit 43d7dc0e6719cc3eaef64bb9c6765fe1c7819fb8 @yeah yeah committed Aug 14, 2012
Showing with 57 additions and 0 deletions.
  1. +17 −0 docs/planio
  2. +14 −0 services/planio.rb
  3. +26 −0 test/planio_test.rb
View
17 docs/planio
@@ -0,0 +1,17 @@
+Planio
+======
+
+Planio &hearts; GitHub! This service hook notifies Planio to fetch new commits from your repository at GitHub whenever you push to it.
+
+Install Notes
+-------------
+
+1. Create a free or paid Planio account at http://plan.io
+2. Logged in to your Planio account, navigate to **Administration** -> **Settings** -> **Repositories** and make sure that the **Enable WS for repository management** checkbox is active and that you have an **API key** set up
+3. Create a project, then navigate to **Settings** -> **Repositories**
+4. Click on **New repository**
+5. Select **Git**, choose an **Identifier**, enter the SSH URL of your GitHub repository in the **Mirror from external URL** field, then click **Create**
+6. Back in your project, head over to the **Repository** tab, find and select the repository you just created in the sidebar
+7. Should you not see the blue instructions screen, click on **Help** on the upper right
+8. Fill in the information from the **Set up web hook** section in the above form here on GitHub and click **Test Hook**, then **Update settings**
+9. Optional: if this GitHub repository is private, click on **Deploy Keys** here on the right and add the SSH public key from the **Set up a public key (deploy key)** section in Planio
View
14 services/planio.rb
@@ -0,0 +1,14 @@
+class Service::Planio < Service
+ string :address, :project, :api_key
+ white_list :address, :project
+
+ def receive_push
+ http.ssl[:verify] = true
+ http.url_prefix = data['address']
+ http_get "sys/fetch_changesets" do |req|
+ req.params['key'] = data['api_key']
+ req.params['id'] = data['project']
+ end
+ end
+end
+
View
26 test/planio_test.rb
@@ -0,0 +1,26 @@
+require File.expand_path('../helper', __FILE__)
+
+class PlanioTest < Service::TestCase
+ def setup
+ @stubs = Faraday::Adapter::Test::Stubs.new
+ end
+
+ def test_push
+ @stubs.get "/a/sys/fetch_changesets" do |env|
+ assert_equal 'r.com', env[:url].host
+ data = Rack::Utils.parse_nested_query(env[:body])
+ assert_equal 'a', env[:params]['key']
+ assert_equal 'p', env[:params]['id']
+ [200, {}, '']
+ end
+
+ svc = service({'address' => 'http://r.com/a/',
+ 'api_key' => 'a', 'project' => 'p'}, :a => 1)
+ svc.receive_push
+ end
+
+ def service(*args)
+ super Service::Planio, *args
+ end
+end
+

0 comments on commit 43d7dc0

Please sign in to comment.
Something went wrong with that request. Please try again.