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.
@@ -137,7 +137,7 @@ class CIJoe
137
137
  output = pipe.read
138
138
  end
139
139
 
140
- Process.waitpid(build.pid)
140
+ Process.waitpid(build.pid, 1)
141
141
  status = $?.exitstatus.to_i
142
142
  puts "#{Time.now.to_i}: Built #{build.short_sha}: status=#{status}"
143
143
 
@@ -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 "\tuser = your@campfire.email"
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
- :user => campfire_config.user.to_s,
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 user pass room ).all? do |key|
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
- :username => config[:user],
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
@@ -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[:ref].to_s.split('/').last
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
@@ -1,3 +1,3 @@
1
1
  class CIJoe
2
- Version = VERSION = "0.8.0"
2
+ Version = VERSION = "0.8.1"
3
3
  end
@@ -0,0 +1,8 @@
1
+ { "jobs": [
2
+ <% if joe.last_build %>
3
+ {"name":"<%= joe.project %>",
4
+ "url":"<%= joe.url %>",
5
+ "color":"<%= joe.last_build.status.to_s == "failed" ? 'red' : 'blue' %>"
6
+ }
7
+ <% end %>
8
+ ]}
@@ -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: 63
4
+ hash: 61
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 0
10
- version: 0.8.0
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-04 00:00:00 -08:00
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