<commit_before>project-badge
=============

Create fancy badges for your projects in plain JS.

# Usage

## In the browser
Download [badge.js](https://raw.githubusercontent.com/hmil/project-badge/master/dist/badge.js), and start having fun with badges !

```html
<html>
  <body>
    <script src="badge.js"></script>
    <script>
      var myBadge = new badge.Boolean({
        text: 'cookies',
        status: true,
        statusText: 'baked !'
      });
      
      document.body.appendChild(myBadge.asDOMNode());
    </script>
  </body>
</html>
```
Et voilà, a shiny custom badge in just two lines of code and 3 config parameters.  
![Le wild badge appears in the browser](https://raw.githubusercontent.com/hmil/project-badge/master/images/badge_in_browser.png)

## In node
This module is available as an npm package `npm install project-package`  
You should check out [node-canvas](https://github.com/Automattic/node-canvas) which provides a compatible canvas API in node.
Actually, it's what's being used in [node-project-badge](https://github.com/hmil/node-project-badge) to provide a CLI badge generator.

# One badge for every thing

Progress:
```javascript
var myBadge = new badge.Progress({
  text: 'baking',
  progress: 32,
});
```
![Progress badge 32%](https://raw.githubusercontent.com/hmil/project-badge/master/images/baking32.png) ![Progress badge 55%](https://raw.githubusercontent.com/hmil/project-badge/master/images/baking55.png) ![Progress badge 87%](https://raw.githubusercontent.com/hmil/project-badge/master/images/baking87.png)  
*Common usage: code coverage*

```javascript
var myBadge = new badge.Info({
  text: 'baking time',
  info: '12\'30'
});
```
![Info badge](https://raw.githubusercontent.com/hmil/project-badge/master/images/baking_time.png)  
*Common usage: package verison, date of last build*

```javascript
var myBadge = new badge.Boolean({
  text: 'taste',
  status: true,
  successText: 'yummy',
  failureText: 'yuck !'
});
myBadge.renderTo(ctx, 0, 0);
myBadge.status = false;
myBadge.renderTo(ctx, 120, 0);
```
![Boolean badge](https://raw.githubusercontent.com/hmil/project-badge/master/images/taste.png)  
*Common usage: build: passing/failure*

# API Reference

## badge.Boolean

A badge that can take two states (namely 'failure' and 'success') depending
on the value of 'status'<commit_msg>Document badge.config()<commit_after>project-badge
=============

Create fancy badges for your projects in plain JS.

# Usage

## In the browser
Download [badge.js](https://raw.githubusercontent.com/hmil/project-badge/master/dist/badge.js), and start having fun with badges !

```html
<html>
  <body>
    <script src="badge.js"></script>
    <script>
      var myBadge = new badge.Boolean({
        text: 'cookies',
        status: true,
        statusText: 'baked !'
      });
      
      document.body.appendChild(myBadge.asDOMNode());
    </script>
  </body>
</html>
```
Et voilà, a shiny custom badge in just two lines of code and 3 config parameters.  
![Le wild badge appears in the browser](https://raw.githubusercontent.com/hmil/project-badge/master/images/badge_in_browser.png)

## In node
This module is available as an npm package `npm install project-package`  
You should check out [node-canvas](https://github.com/Automattic/node-canvas) which provides a compatible canvas API in node.
Actually, it's what's being used in [node-project-badge](https://github.com/hmil/node-project-badge) to provide a CLI badge generator.

# One badge for every thing

Progress:
```javascript
var myBadge = new badge.Progress({
  text: 'baking',
  progress: 32,
});
```
![Progress badge 32%](https://raw.githubusercontent.com/hmil/project-badge/master/images/baking32.png) ![Progress badge 55%](https://raw.githubusercontent.com/hmil/project-badge/master/images/baking55.png) ![Progress badge 87%](https://raw.githubusercontent.com/hmil/project-badge/master/images/baking87.png)  
*Common usage: code coverage*

```javascript
var myBadge = new badge.Info({
  text: 'baking time',
  info: '12\'30'
});
```
![Info badge](https://raw.githubusercontent.com/hmil/project-badge/master/images/baking_time.png)  
*Common usage: package verison, date of last build*

```javascript
var myBadge = new badge.Boolean({
  text: 'taste',
  status: true,
  successText: 'yummy',
  failureText: 'yuck !'
});
myBadge.renderTo(ctx, 0, 0);
myBadge.status = false;
myBadge.renderTo(ctx, 120, 0);
```
![Boolean badge](https://raw.githubusercontent.com/hmil/project-badge/master/images/taste.png)  
*Common usage: build: passing/failure*

# API Reference

## badge.config(conf)

Use this function to set global configuration settings. Available settings are:
```coffeescript
'color-success': '#0a0'
'color-failure': '#a00'
'color-warning': '#880'
'color-info': '#3BC2EB'
'color-background': '#444'
'color-text': '#fff'      

'font': '11px Verdana'      # the same font for all texts
'border-radius': 5          # like css border-radius
'padding': 5                # x padding for the text
'text-height': 14           # text position, y-axis

'width': 50                 # default width
'height': 20                # default height
```
## badge.Boolean

A badge that can take two states (namely 'failure' and 'success') depending
on the value of 'status'
{'fraction_non_alphanumeric': 0.14868970755791872, 'fraction_numerical': 0.013672616786935056, 'mean_word_length': 4.040191387559808, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 18, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3557631', 'n_tokens_mistral': 1819, 'n_tokens_neox': 1688, 'n_words': 457}