Skip to content

Commit

Permalink
Merge pull request #42 from badges/travis-has-svg
Browse files Browse the repository at this point in the history
Travis now serves up its own SVG badges
  • Loading branch information
Sam Pikesley committed Mar 21, 2014
2 parents 2db127b + 93ef5a5 commit 094225c
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 13 deletions.
3 changes: 2 additions & 1 deletion config/services.yaml
@@ -1,7 +1,8 @@
travis:
alt_text: Build Status
scheme: https
url_path: travis-ci.org
badge_slug: travis
offers_svg: true

coveralls:
alt_text: Coverage Status
Expand Down
2 changes: 1 addition & 1 deletion features/badger.feature
Expand Up @@ -8,7 +8,7 @@ Feature: Badge robot
When I successfully run `badger badge /tmp/wow_repo`
Then the output should contain:
"""
[![Build Status](http://img.shields.io/travis/doge/wow.svg)](https://travis-ci.org/doge/wow)
[![Build Status](https://travis-ci.org/doge/wow.svg)](https://travis-ci.org/doge/wow)
[![Dependency Status](http://img.shields.io/gemnasium/doge/wow.svg)](https://gemnasium.com/doge/wow)
[![Coverage Status](http://img.shields.io/coveralls/doge/wow.svg)](https://coveralls.io/r/doge/wow)
[![Code Climate](http://img.shields.io/codeclimate/github/doge/wow.svg)](https://codeclimate.com/github/doge/wow)
Expand Down
2 changes: 1 addition & 1 deletion features/png.feature
Expand Up @@ -8,7 +8,7 @@ Feature: Badge robot
When I successfully run `badger badge /tmp/wow_repo --png `
Then the output should contain:
"""
[![Build Status](http://img.shields.io/travis/doge/wow.png)](https://travis-ci.org/doge/wow)
[![Build Status](https://travis-ci.org/doge/wow.png)](https://travis-ci.org/doge/wow)
[![Dependency Status](http://img.shields.io/gemnasium/doge/wow.png)](https://gemnasium.com/doge/wow)
[![Coverage Status](http://img.shields.io/coveralls/doge/wow.png)](https://coveralls.io/r/doge/wow)
[![Code Climate](http://img.shields.io/codeclimate/github/doge/wow.png)](https://codeclimate.com/github/doge/wow)
Expand Down
2 changes: 1 addition & 1 deletion features/services.feature
Expand Up @@ -8,7 +8,7 @@ Feature: Get service badges
When I successfully run `badger badge /tmp/wow_repo`
Then the output should contain:
"""
[![Build Status](http://img.shields.io/travis/doge/wow.svg)](https://travis-ci.org/doge/wow)
[![Build Status](https://travis-ci.org/doge/wow.svg)](https://travis-ci.org/doge/wow)
"""
And the output should not contain:
"""
Expand Down
2 changes: 1 addition & 1 deletion features/ssh-remote.feature
Expand Up @@ -8,7 +8,7 @@ Feature: Badge robot
When I successfully run `badger badge /tmp/wow_repo`
Then the output should contain:
"""
[![Build Status](http://img.shields.io/travis/doge/wow.svg)](https://travis-ci.org/doge/wow)
[![Build Status](https://travis-ci.org/doge/wow.svg)](https://travis-ci.org/doge/wow)
[![Dependency Status](http://img.shields.io/gemnasium/doge/wow.svg)](https://gemnasium.com/doge/wow)
[![Coverage Status](http://img.shields.io/coveralls/doge/wow.svg)](https://coveralls.io/r/doge/wow)
[![Code Climate](http://img.shields.io/codeclimate/github/doge/wow.svg)](https://codeclimate.com/github/doge/wow)
Expand Down
19 changes: 16 additions & 3 deletions lib/badger/service.rb
Expand Up @@ -4,9 +4,22 @@ def self.badge name, github_slug
return nil unless params = Config.instance.services[name]
params = Config.instance.services[name]

badge_url = 'http://%s/%s/%s' % [
Config.instance.config['badge_service'],
params['badge_slug'],
scheme = params['scheme'] ||= 'http'
case params['offers_svg']
when true
base_url = '%s://%s' % [
scheme,
params['url_path']
]
else
base_url = 'http://%s/%s' % [
Config.instance.config['badge_service'],
params['badge_slug']
]
end

badge_url = '%s/%s' % [
base_url,
github_slug
]
target_url = 'https://%s/%s' % [
Expand Down
10 changes: 5 additions & 5 deletions spec/badger_spec.rb
Expand Up @@ -39,13 +39,13 @@ module Badger
context 'service badges' do
it 'should have a travis badge' do
@badger.add 'travis'
@badger[0].should == "[![Build Status](http://img.shields.io/travis/doge/wow.svg)](https://travis-ci.org/doge/wow)"
@badger[0].should == "[![Build Status](https://travis-ci.org/doge/wow.svg)](https://travis-ci.org/doge/wow)"
end

it 'should have a travis badge and a gemnasium badge' do
@badger.add 'travis'
@badger.add 'gemnasium'
@badger[0].should == "[![Build Status](http://img.shields.io/travis/doge/wow.svg)](https://travis-ci.org/doge/wow)"
@badger[0].should == "[![Build Status](https://travis-ci.org/doge/wow.svg)](https://travis-ci.org/doge/wow)"
@badger[1].should == "[![Dependency Status](http://img.shields.io/gemnasium/doge/wow.svg)](https://gemnasium.com/doge/wow)"
@badger.length.should == 2
end
Expand Down Expand Up @@ -107,7 +107,7 @@ module Badger
@badger.add 'codeclimate'
@badger.license 'mit'
@badger.to_s.should ==
%{[![Build Status](http://img.shields.io/travis/doge/wow.svg)](https://travis-ci.org/doge/wow)
%{[![Build Status](https://travis-ci.org/doge/wow.svg)](https://travis-ci.org/doge/wow)
[![Code Climate](http://img.shields.io/codeclimate/github/doge/wow.svg)](https://codeclimate.com/github/doge/wow)
[![License](http://img.shields.io/:license-mit-blue.svg)](http://doge.mit-license.org)
}
Expand All @@ -117,13 +117,13 @@ module Badger
it 'should work with a "-" in the remote name' do
@badger = Badger.new 'https://github.com/pikesley/diabetes-dashboard.git'
@badger.add 'travis'
@badger[0].should == '[![Build Status](http://img.shields.io/travis/pikesley/diabetes-dashboard.svg)](https://travis-ci.org/pikesley/diabetes-dashboard)'
@badger[0].should == '[![Build Status](https://travis-ci.org/pikesley/diabetes-dashboard.svg)](https://travis-ci.org/pikesley/diabetes-dashboard)'
end

it 'should let me choose a different badge type' do
@badger.badge_type 'png'
@badger.add 'travis'
@badger[0].should == '[![Build Status](http://img.shields.io/travis/doge/wow.png)](https://travis-ci.org/doge/wow)'
@badger[0].should == '[![Build Status](https://travis-ci.org/doge/wow.png)](https://travis-ci.org/doge/wow)'
end
end
end

0 comments on commit 094225c

Please sign in to comment.