Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Fetching latest commit…

Cannot retrieve the latest commit at this time

..
Failed to load latest commit information.
CodePorting-C#2Java.rb
README.md
active_collab.rb
acunote.rb
agile_bench.rb
agilezen.rb
amazon_sns.rb
amqp.rb
apoio.rb
appharbor.rb
asana.rb
backlog.rb
bamboo.rb
basecamp.rb
basecamp_classic.rb
boxcar.rb
buddycloud.rb
bugherd.rb
bugly.rb
bugzilla.rb
buildcoin.rb
campfire.rb
cia.rb
co_op.rb
codeclimate.rb
cube.rb
ducksboard.rb
email.rb
flowdock.rb
fog_bugz.rb
freckle.rb
friend_feed.rb
gemini.rb
gemnasium.rb
geocommit.rb
get_localization.rb
gitlive.rb
grmble.rb
group_talent.rb
grove.rb
habitualist.rb
harvest.rb
hipchat.rb
hubci.rb
icescrum.rb
irc.rb
jabber.rb
jaconda.rb
jenkins_git.rb
jenkins_github.rb
jira.rb
kanbanery.rb
kickoff.rb
leanto.rb
lighthouse.rb
loggly.rb
mantis_bt.rb
masterbranch.rb
mqtt.rb
nodejitsu.rb
notifo.rb
notifymyandroid.rb
ontime.rb
pachube.rb
packagist.rb
pivotal_tracker.rb
planbox.rb
planio.rb
presently.rb
prowl.rb
puppetlinter.rb
pushover.rb
pythonpackages.rb
rails_brakeman.rb
railsbp.rb
rally.rb
rational_team_concert.rb
rdocinfo.rb
read_the_docs.rb
redmine.rb
rubyforge.rb
scrumdo.rb
shiningpanda.rb
slatebox.rb
snowyevening.rb
socialcast.rb
softlayer_messaging.rb
sourcemint.rb
splendid_bacon.rb
sprintly.rb
sqs_queue.rb
stackmob.rb
statusnet.rb
talker.rb
target_process.rb
teamcity.rb
tender.rb
test_pilot.rb
toggl.rb
trac.rb
trajectory.rb
travis.rb
trello.rb
twilio.rb
twitter.rb
unfuddle.rb
web.rb
web_translate_it.rb
yammer.rb
you_track.rb
zendesk.rb
zohoprojects.rb

README.md

Services

This is the directory that all Services go. Creating a Service is simple:

class Service::MyService < Service
  def receive_push
  end
end

Inside the method, you can access the configuration data in a hash named data, and the payload data in a Hash named payload.

Note: A service can respond to more than one event. Currently, only push is supported.

Tip: Check configuration data early.

class Service::MyService < Service
  def receive_push
    if data['username'].to_s.empty?
      raise_config_error "Needs a username"
    end
  end
end

Tip: Use http helpers to make HTTP calls easily.

class Service::MyService < Service
  def receive_push
    # Sets this basic auth info for every request.
    http.basic_auth(data['username'], data['password'])

    # Every request sends JSON.
    http.headers['Content-Type'] = 'application/json'

    # Uses this URL as a prefix for every request.
    http.url_prefix = "https://my-service.com/api"

    payload['commits'].each do |commit|

      # POST https://my-service.com/api/commits.json
      http_post "commits.json", commit.to_json

    end
  end
end

Tip: Test your service like a bossk.

class MyServiceTest < Service::TestCase
  def setup
    @stubs = Faraday::Adapter::Test::Stubs.new
  end

  def test_push
    @stubs.post "/api/create.json" do |env|
      assert_equal 'my-service.com', env[:url].host
      assert_equal 'application/json',
        env[:request_headers]['content-type']
      assert_equal basic_auth("user", "pass"),
        env[:request_headers]['authorization']
      [200, {}, '']
    end

    svc = service :push,
      {'username' => 'user', 'password' => 'pass'}, payload
    svc.receive_push
  end

  def service(*args)
    super Service::MyService, *args
  end
end

Documentation

Each Service needs to have documentation aimed at end users in /docs. See existing services for the format.

Something went wrong with that request. Please try again.