cijoe 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/cijoe.rb +1 -1
- data/lib/cijoe/campfire.rb +4 -7
- data/lib/cijoe/server.rb +12 -1
- data/lib/cijoe/version.rb +1 -1
- data/lib/cijoe/views/json.erb +8 -0
- data/test/test_cijoe_server.rb +20 -0
- metadata +5 -4
data/lib/cijoe.rb
CHANGED
data/lib/cijoe/campfire.rb
CHANGED
|
@@ -15,8 +15,7 @@ class CIJoe
|
|
|
15
15
|
puts "Can't load Campfire notifier."
|
|
16
16
|
puts "Please add the following to your project's .git/config:"
|
|
17
17
|
puts "[campfire]"
|
|
18
|
-
puts "\
|
|
19
|
-
puts "\tpass = passw0rd"
|
|
18
|
+
puts "\ttoken = your_api_token"
|
|
20
19
|
puts "\tsubdomain = whatever"
|
|
21
20
|
puts "\troom = Awesomeness"
|
|
22
21
|
puts "\tssl = false"
|
|
@@ -27,15 +26,14 @@ class CIJoe
|
|
|
27
26
|
campfire_config = Config.new('campfire', @project_path)
|
|
28
27
|
@config ||= {
|
|
29
28
|
:subdomain => campfire_config.subdomain.to_s,
|
|
30
|
-
:
|
|
31
|
-
:pass => campfire_config.pass.to_s,
|
|
29
|
+
:token => campfire_config.token.to_s,
|
|
32
30
|
:room => campfire_config.room.to_s,
|
|
33
31
|
:ssl => campfire_config.ssl.to_s.strip == 'true'
|
|
34
32
|
}
|
|
35
33
|
end
|
|
36
34
|
|
|
37
35
|
def self.valid_config?
|
|
38
|
-
%w( subdomain
|
|
36
|
+
%w( subdomain token room ).all? do |key|
|
|
39
37
|
!config[key.intern].empty?
|
|
40
38
|
end
|
|
41
39
|
end
|
|
@@ -51,8 +49,7 @@ class CIJoe
|
|
|
51
49
|
@room ||= begin
|
|
52
50
|
config = Campfire.config
|
|
53
51
|
campfire = Tinder::Campfire.new(config[:subdomain],
|
|
54
|
-
:
|
|
55
|
-
:password => config[:pass],
|
|
52
|
+
:token => config[:token],
|
|
56
53
|
:ssl => config[:ssl] || false)
|
|
57
54
|
campfire.find_room_by_name(config[:room])
|
|
58
55
|
end
|
data/lib/cijoe/server.rb
CHANGED
|
@@ -28,7 +28,7 @@ class CIJoe
|
|
|
28
28
|
|
|
29
29
|
post '/?' do
|
|
30
30
|
payload = YAML.load(params[:payload].to_s) || {}
|
|
31
|
-
pushed_branch = payload[
|
|
31
|
+
pushed_branch = payload['ref'].to_s.split('/').last
|
|
32
32
|
|
|
33
33
|
# Only build if we were given an explicit branch via `?branch=blah`,
|
|
34
34
|
# no payload exists (we're probably testing), or the payload exists and
|
|
@@ -40,6 +40,17 @@ class CIJoe
|
|
|
40
40
|
redirect request.path
|
|
41
41
|
end
|
|
42
42
|
|
|
43
|
+
get '/api/json' do
|
|
44
|
+
response = [200, {'Content-Type' => 'application/json'}]
|
|
45
|
+
response_json = erb(:json, {}, :joe => joe)
|
|
46
|
+
if params[:jsonp]
|
|
47
|
+
response << params[:jsonp] + '(' + response_json + ')'
|
|
48
|
+
else
|
|
49
|
+
response << response_json
|
|
50
|
+
end
|
|
51
|
+
response
|
|
52
|
+
end
|
|
53
|
+
|
|
43
54
|
|
|
44
55
|
helpers do
|
|
45
56
|
include Rack::Utils
|
data/lib/cijoe/version.rb
CHANGED
data/test/test_cijoe_server.rb
CHANGED
|
@@ -64,6 +64,26 @@ class TestCIJoeServer < Test::Unit::TestCase
|
|
|
64
64
|
assert_equal current_build, app.joe.current_build
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
+
def test_jsonp_should_return_plain_json_without_param
|
|
68
|
+
app.joe.last_build = build :failed
|
|
69
|
+
get "/api/json"
|
|
70
|
+
assert_equal 200, last_response.status
|
|
71
|
+
assert_equal 'application/json', last_response.content_type
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def test_jsonp_should_return_jsonp_with_param
|
|
75
|
+
app.joe.last_build = build :failed
|
|
76
|
+
get "/api/json?jsonp=fooberz"
|
|
77
|
+
puts last_response.inspect
|
|
78
|
+
assert_equal 200, last_response.status
|
|
79
|
+
assert_equal 'application/json', last_response.content_type
|
|
80
|
+
assert_match /^fooberz\(/, last_response.body
|
|
81
|
+
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def test_should_not_barf_when_no_build
|
|
85
|
+
end
|
|
86
|
+
|
|
67
87
|
# Create a new, fake build. All we care about is status.
|
|
68
88
|
|
|
69
89
|
def build status
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cijoe
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 61
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 8
|
|
9
|
-
-
|
|
10
|
-
version: 0.8.
|
|
9
|
+
- 1
|
|
10
|
+
version: 0.8.1
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Chris Wanstrath
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2011-02-
|
|
18
|
+
date: 2011-02-06 00:00:00 -08:00
|
|
19
19
|
default_executable:
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|
|
@@ -81,6 +81,7 @@ files:
|
|
|
81
81
|
- lib/cijoe/public/screen.css
|
|
82
82
|
- lib/cijoe/server.rb
|
|
83
83
|
- lib/cijoe/version.rb
|
|
84
|
+
- lib/cijoe/views/json.erb
|
|
84
85
|
- lib/cijoe/views/template.erb
|
|
85
86
|
- lib/cijoe.rb
|
|
86
87
|
- bin/cijoe
|