Skip to content

Commit

Permalink
Merge pull request #77 from badges/dependency-ci
Browse files Browse the repository at this point in the history
Support @andrew 's new Dependency CI thing
  • Loading branch information
Sam Pikesley authored Jul 11, 2016
2 parents a0f549d + 509154a commit d6f6e2e
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 3 deletions.
6 changes: 6 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ codeclimate:
url_path: codeclimate.com/github
badge_slug: codeclimate/github

dependencyci:
alt_text: Dependency CI
service_root: dependencyci.com/github
url_path: github/doge
suffix: badge

pulls:
alt_text: Pending Pull-Requests
service_root: githubbadges.herokuapp.com
Expand Down
18 changes: 18 additions & 0 deletions features/dependency-ci.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Feature: Dependency CI support

Background:
Given git remote is "https://github.com/doge/wow"

@travis @gemnasium @coveralls @gemspec @mit
Scenario: Get a Dep CI badge
When I successfully run `badger badge --dci /tmp/wow_repo`
Then the output should contain:
"""
[![Build Status](http://img.shields.io/travis/doge/wow.svg?style=flat-square)](https://travis-ci.org/doge/wow)
[![Dependency Status](http://img.shields.io/gemnasium/doge/wow.svg?style=flat-square)](https://gemnasium.com/doge/wow)
[![Dependency CI](http://dependencyci.com/github/doge/wow/badge?style=flat-square)](http://dependencyci.com/github/doge/wow)
[![Coverage Status](http://img.shields.io/coveralls/doge/wow.svg?style=flat-square)](https://coveralls.io/r/doge/wow)
[![Code Climate](http://img.shields.io/codeclimate/github/doge/wow.svg?style=flat-square)](https://codeclimate.com/github/doge/wow)
[![Gem Version](http://img.shields.io/gem/v/suchgem.svg?style=flat-square)](https://rubygems.org/gems/suchgem)
[![License](http://img.shields.io/:license-mit-blue.svg?style=flat-square)](http://doge.mit-license.org)
"""
2 changes: 1 addition & 1 deletion lib/badger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
require 'badger/helpers'
require 'badger/badge'
require 'badger/bonus'

require 'badger/dependencyci'
2 changes: 1 addition & 1 deletion lib/badger/badge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def Badger.badge text, badge_url, target_url
badge_url = "%s.%s" % [
badge_url,
Config.instance.config['badge_type']
] unless text == 'Repo Size'
] unless ['Repo Size', 'Dependency CI'].include? text

badge_style = Config.instance.config['badge_style']
badge_url = "%s?style=%s" % [
Expand Down
4 changes: 4 additions & 0 deletions lib/badger/badger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ def rubygem name
self << Rubygem.badge(name)
end

def dependencyci
self << DependencyCI.badge(github_slug)
end

def bonus
self.uniq!
self << Bonus.badge(self)
Expand Down
2 changes: 2 additions & 0 deletions lib/badger/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def version
method_option :png, :type => :boolean, :default => false, :desc => 'Generate PNG badges instead of the default SVG (because sometimes Github does caching things)'
method_option :pulls, :type => :boolean, :default => false, :desc => 'Generate Github pull-request and issue-count badges'
method_option :size, :type => :boolean, :default => false, :desc => 'Generate repo size badge'
method_option :dci, :type => :boolean, :default => false, :desc => 'Include a Dependency CI badge (experimental)'
method_option :style, :type => :string, :default => 'flat-square', :desc => "Choose a different badge style (currently supported: #{Config.instance.config['valid_styles'].join ', '})"

def badge dir = '.'
Expand All @@ -26,6 +27,7 @@ def badge dir = '.'

@badger.add 'travis' if Badger.has_travis? dir
@badger.add 'gemnasium' if Badger.has_gemfile? dir
@badger.dependencyci if options[:dci]
@badger.add 'coveralls' if Badger.has_coveralls? dir
@badger.add 'codeclimate' if @badger.any?

Expand Down
16 changes: 16 additions & 0 deletions lib/badger/dependencyci.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module Badger
class DependencyCI
def self.badge name
badge_url = 'http://%s/github/%s/badge' % [
'dependencyci.com',
name
]

target_url = 'http://dependencyci.com/github/%s' % [
name
]

Badger.badge 'Dependency CI', badge_url, target_url
end
end
end
2 changes: 1 addition & 1 deletion lib/badger/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Badger
VERSION = "0.14.0"
VERSION = "0.15.0"
end
6 changes: 6 additions & 0 deletions spec/services_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ module Badger
expect(@badger.length).to eq 2
end

it 'has a dependencyci badge' do
@badger.dependencyci
expect(@badger[0]).to eq "[![Dependency CI](http://dependencyci.com/github/doge/wow/badge)](http://dependencyci.com/github/doge/wow)"
expect(@badger.length).to eq 1
end

it 'handles an unknown service gracefully' do
@badger.add 'doge-service'
expect(@badger.length).to eq 0
Expand Down

0 comments on commit d6f6e2e

Please sign in to comment.