<commit_before># Bail

[![Build Status](https://travis-ci.org/bjh/bail.svg?branch=master)](https://travis-ci.org/bjh/bail)
[![Coverage Status](https://coveralls.io/repos/bjh/bail/badge.png)](https://coveralls.io/r/bjh/bail)

#### What
A miniscule DSL to write guard clauses. Also to ask some basic questions of my types when I get curious.

#### Why
I was finding my methods were collecting a top layer of IF/ELSE statements that got harder to read and maintain.

#### How
Sweet sexy voodoo magic.

***

A basic *un-sugared* guard looks something like this:
```ruby
  Bail.when(:any, :of, :these, :things) {|item| item.nil?}
```

So you pass in an enumerator (defaults are the Enumerable module methods), any number of arguments, and a `block` for the condition test.

Super *easy* and super *cheezy*.

There are more specialized versions that do not require a block:  
These are really just lightly *sugared* wrappers around Enumerable methods...

```ruby
  Bail.when_any(condition, *objects)
  Bail.when_all(condition, *objects)
  Bail.when_one(condition, *objects)
  Bail.when_none(condition, *objects)
```<commit_msg>fixed the coveralls badge<commit_after># Bail

[![Build Status](https://travis-ci.org/bjh/bail.svg?branch=master)](https://travis-ci.org/bjh/bail)
[![Coverage Status](https://coveralls.io/repos/bjh/bail/badge.png?branch=master)](https://coveralls.io/r/bjh/bail?branch=master)
#### What
A miniscule DSL to write guard clauses. Also to ask some basic questions of my types when I get curious.

#### Why
I was finding my methods were collecting a top layer of IF/ELSE statements that got harder to read and maintain.

#### How
Sweet sexy voodoo magic.

***

A basic *un-sugared* guard looks something like this:
```ruby
  Bail.when(:any, :of, :these, :things) {|item| item.nil?}
```

So you pass in an enumerator (defaults are the Enumerable module methods), any number of arguments, and a `block` for the condition test.

Super *easy* and super *cheezy*.

There are more specialized versions that do not require a block:  
These are really just lightly *sugared* wrappers around Enumerable methods...

```ruby
  Bail.when_any(condition, *objects)
  Bail.when_all(condition, *objects)
  Bail.when_one(condition, *objects)
  Bail.when_none(condition, *objects)
```
{'fraction_non_alphanumeric': 0.12889083735203857, 'fraction_numerical': 0.0, 'mean_word_length': 4.748110831234257, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3328376', 'n_tokens_mistral': 775, 'n_tokens_neox': 733, 'n_words': 255}