forked from github/github-services
/
travis.rb
51 lines (41 loc) · 937 Bytes
/
travis.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
class Service::Travis < Service
default_events :push, :pull_request, :issue_comment, :public, :member
string :user, :token, :domain
white_list :domain, :user
def receive_event
http.ssl[:verify] = false
http.basic_auth user, token
http.headers['X-GitHub-Event'] = event.to_s
http_post travis_url, :payload => payload.to_json
end
def travis_url
"#{scheme}://#{domain}"
end
def user
if data['user'].to_s == ''
payload['repository']['owner']['name']
else
data['user']
end.strip
end
def token
data['token'].to_s.strip
end
def scheme
domain_parts.size == 1 ? 'http' : domain_parts.first
end
def domain
domain_parts.last
end
protected
def full_domain
if data['domain'].present?
data['domain']
else
'http://notify.travis-ci.org'
end.strip
end
def domain_parts
@domain_parts ||= full_domain.split('://')
end
end