Skip to content
This repository has been archived by the owner on Dec 1, 2018. It is now read-only.

Commit

Permalink
Fix #1: allow to define shield style
Browse files Browse the repository at this point in the history
  • Loading branch information
jirutka committed Jun 7, 2014
1 parent 8673db0 commit ecc253d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ Well, I put together [shields.io](http://shields.io/), [Heroku](https://heroku.c
Usage
-----

https://maven-badges.herokuapp.com/maven-central/{group_id}/{artifact_id}/badge.(svg|png)
https://maven-badges.herokuapp.com/maven-central/{group_id}/{artifact_id}/badge.(svg|png)?style={style}

For an example:
For example:

[![Maven Central](https://maven-badges.herokuapp.com/maven-central/cz.jirutka.rsql/rsql-parser/badge.svg)](https://maven-badges.herokuapp.com/maven-central/cz.jirutka.rsql/rsql-parser)

[![Maven Central](https://maven-badges.herokuapp.com/maven-central/cz.jirutka.rsql/rsql-parser/badge.svg)](https://maven-badges.herokuapp.com/maven-central/cz.jirutka.rsql/rsql-parser)

[![Maven Central](https://maven-badges.herokuapp.com/maven-central/cz.jirutka.rsql/rsql-parser/badge.svg?style=flat)](https://maven-badges.herokuapp.com/maven-central/cz.jirutka.rsql/rsql-parser)

[![Maven Central](https://maven-badges.herokuapp.com/maven-central/cz.jirutka.rsql/rsql-parser/badge.svg?style=flat)](https://maven-badges.herokuapp.com/maven-central/cz.jirutka.rsql/rsql-parser)

License
-------
Expand Down
4 changes: 2 additions & 2 deletions lib/shields.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class Shields

base_uri 'img.shields.io'

def self.badge_image(subject, status, color, format='svg')
resp = get("/badge/#{encode(subject)}-#{encode(status)}-#{color}.#{format}")
def self.badge_image(subject, status, color, format='svg', style='default')
resp = get("/badge/#{encode(subject)}-#{encode(status)}-#{color}.#{format}?style=#{style}")

raise HTTParty::ResponseError.new(resp) unless resp.code == 200
resp.body
Expand Down
5 changes: 4 additions & 1 deletion lib/web.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require_relative 'shields'

DEFAULT_SUBJECT = 'maven central'
DEFAULT_STYLE = 'default'
PROJECT_SITE = 'https://github.com/jirutka/maven-badges'

configure :production do
Expand Down Expand Up @@ -30,7 +31,9 @@
color = :lightgray
end

Shields.badge_image(subject, version, color, format)
style = params[:style] || DEFAULT_STYLE

Shields.badge_image(subject, version, color, format, style)
end

# Returns the artifact's last version number in plain text
Expand Down

0 comments on commit ecc253d

Please sign in to comment.