Skip to content

Commit

Permalink
Merge pull request #68 from badges/size-badge
Browse files Browse the repository at this point in the history
Support size badge
  • Loading branch information
Sam Pikesley committed Jun 4, 2015
2 parents 2cf2b3d + a5e687d commit 15a025a
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 2 deletions.
7 changes: 7 additions & 0 deletions config/services.yaml
Expand Up @@ -30,3 +30,10 @@ issues:
service_root: githubbadges.herokuapp.com
url_path: github.com
suffix: issues

size:
alt_text: Repo Size
service_root: reposs.herokuapp.com
url_path: github.com
# REST? Fuck REST
ugly_cruft: ?path=
19 changes: 19 additions & 0 deletions features/size.feature
@@ -0,0 +1,19 @@
Feature: Github issues and PRs

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

@travis @gemnasium @coveralls @gemspec @mit
Scenario: Include 'size' badge
When I successfully run `badger badge --size /tmp/wow_repo`
Then the output should contain:
"""
[![Build Status](http://img.shields.io/travis/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)
[![Repo Size](http://reposs.herokuapp.com/?path=doge/wow.svg)](https://github.com/doge/wow)
[![Gem Version](http://img.shields.io/gem/v/suchgem.svg)](https://rubygems.org/gems/suchgem)
[![License](http://img.shields.io/:license-mit-blue.svg)](http://doge.mit-license.org)
[![Badges](http://img.shields.io/:badges-8/8-ff6799.svg)](https://github.com/badges/badgerbadgerbadger)
"""
3 changes: 3 additions & 0 deletions lib/badger/cli.rb
Expand Up @@ -14,6 +14,7 @@ def version
long_desc File.read File.join File.dirname( __FILE__), '..', '..', 'DESC.md'
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 :style, :type => :string, :default => nil, :desc => "Choose a different badge style (currently supported: #{Config.instance.config['valid_styles'].join ', '})"

def badge dir = '.'
Expand All @@ -31,6 +32,8 @@ def badge dir = '.'
@badger.add 'issues' if options[:pulls]
@badger.add 'pulls' if options[:pulls]

@badger.add 'size' if options[:size]

if gemspec_params = Badger.search_gemspec(dir)
@badger.rubygem gemspec_params[:rubygem]
if gemspec_params[:licenses]
Expand Down
3 changes: 2 additions & 1 deletion lib/badger/service.rb
Expand Up @@ -17,8 +17,9 @@ def self.badge name, github_slug
]
end

badge_url = '%s/%s' % [
badge_url = '%s/%s%s' % [
base_url,
params['ugly_cruft'],
github_slug
]

Expand Down
2 changes: 1 addition & 1 deletion lib/badger/version.rb
@@ -1,3 +1,3 @@
module Badger
VERSION = "0.12.0"
VERSION = "0.13.0"
end
20 changes: 20 additions & 0 deletions spec/size_spec.rb
@@ -0,0 +1,20 @@
require 'spec_helper'

module Badger
describe Badger do
before :each do
@badger = Badger.new "https://github.com/doge/wow"
end

after :each do
Config.instance.reset!
end

context 'size badge' do
it 'has a size badge' do
@badger.add 'size'
expect(@badger[0]).to eq '[![Repo Size](http://reposs.herokuapp.com/?path=doge/wow.svg)](https://github.com/doge/wow)'
end
end
end
end

0 comments on commit 15a025a

Please sign in to comment.