<commit_before># Honeybadger for Ruby

[![Code Climate](https://codeclimate.com/github/honeybadger-io/honeybadger-ruby/badges/gpa.svg)](https://codeclimate.com/github/honeybadger-io/honeybadger-ruby)
[![Test Coverage](https://codeclimate.com/github/honeybadger-io/honeybadger-ruby/badges/coverage.svg)](https://codeclimate.com/github/honeybadger-io/honeybadger-ruby)
[![Build Status](https://secure.travis-ci.org/honeybadger-io/honeybadger-ruby.png?branch=master)](http://travis-ci.org/honeybadger-io/honeybadger-ruby)
[![Gem Version](https://badge.fury.io/rb/honeybadger.png)](http://badge.fury.io/rb/honeybadger)

This is the notifier gem for integrating apps with the :zap: [Honeybadger Exception Notifier for Ruby and Rails](http://honeybadger.io).

When an uncaught exception occurs, Honeybadger will POST the relevant data to the Honeybadger server specified in your environment.

## Supported Ruby versions

| Ruby Interpreter  | Supported Version  |
| ----              | ----               |
| MRI               | >= 1.9.3          |
| JRuby             | >= 1.7 (1.9 mode) |
| Rubinius          | >= 2.0            |

## Supported web frameworks

| Framework     | Version       | Native?    |
| ------------- | ------------- |------------|
| Rails         | >= 3.0        | yes        |
| Sinatra       | >= 1.2.1      | yes        |
| Rack          | >= 1.0        | middleware |

Rails and Sinatra are supported natively (install/configure the gem and you're done). For vanilla Rack apps, we provide a collection of middleware that must be installed manually.

To use Rails 2.x, you'll need to use an earlier version of the Honeybadger gem. [Go to version 1.x of the gem docs](https://github.com/honeybadger-io/honeybadger-ruby/blob/1.16-stable/docs/index.md). 

Integrating with other libraries/frameworks is simple! [See the documentation](http://rubydoc.info/gems/honeybadger/) to learn about our public API, and see [Contributing](#contributing) to suggest a patch.

## Supported job queues

| Framework     | Version       | Native?      |
| ------------- | ------------- | ------------ |
| Sidekiq       | any           | yes          |
| Resque        | any           | yes          |
| Delayed Job   | any           | yes          |
| Sucker Punch  | any           | yes          |

You can integrate honeybadger into any Ruby script via the `Honeybadger.notify` method. 

## Getting Started

Honeybadger works out of the box with all popular Ruby frameworks. Installation is just a matter of including the gem and setting your API key. In this section, we'll cover the basics. More advanced installations are covered later. 

### 1. Install the gem


The first step is to add the honeybadger gem to your Gemfile:

```ruby
gem 'honeybadger'
```

Tell bundler to install:

```bash
$ bundle install
```

### 2. Set your API key

Next, you'll set the API key for this project.

```bash
$ bundle exec honeybadger install [YOUR API KEY HERE]
```

This will generate a `config/honeybadger.yml` file. If you don't like config files, you can place your API key in the `$HONEYBADGER_API_KEY` environment variable.

#### Heroku installation

If your app is deployed to heroku, you can configure Honeybadger on your dynos like so:

```bash
$ bundle exec honeybadger heroku install [YOUR API KEY HERE]
```

This will automatically add a `HONEYBADGER_API_KEY` environment variable to your
remote Heroku config and configure deploy notifications.

This step isn't necessary if you're using our [Heroku add-on](https://elements.heroku.com/addons/honeybadger).

### 3. Set up your code

#### Rails

You're done! Any rake tasks and job queues that load the Rails environment are also covered. 

#### Sinatra

All you need to do is to include the honeybadger gem: 

```ruby
# Always require Sinatra first.
require 'sinatra'
# Then require honeybadger.
require 'honeybadger'
# Define your application code *after* Sinatra *and* honeybadger:
get '/' do
  raise "Sinatra has left the building"
end
```

#### Rack

With rack, you have to do things manually, but it's still just a few lines of code:

```ruby
require 'rack'
 
# Load the gem
require 'honeybadger'
 
# Write your app
app = Rack::Builder.app do<commit_msg>link to rails setup screencast from readme<commit_after># Honeybadger for Ruby

[![Code Climate](https://codeclimate.com/github/honeybadger-io/honeybadger-ruby/badges/gpa.svg)](https://codeclimate.com/github/honeybadger-io/honeybadger-ruby)
[![Test Coverage](https://codeclimate.com/github/honeybadger-io/honeybadger-ruby/badges/coverage.svg)](https://codeclimate.com/github/honeybadger-io/honeybadger-ruby)
[![Build Status](https://secure.travis-ci.org/honeybadger-io/honeybadger-ruby.png?branch=master)](http://travis-ci.org/honeybadger-io/honeybadger-ruby)
[![Gem Version](https://badge.fury.io/rb/honeybadger.png)](http://badge.fury.io/rb/honeybadger)

This is the notifier gem for integrating apps with the :zap: [Honeybadger Exception Notifier for Ruby and Rails](http://honeybadger.io).

When an uncaught exception occurs, Honeybadger will POST the relevant data to the Honeybadger server specified in your environment.

## Supported Ruby versions

| Ruby Interpreter  | Supported Version  |
| ----              | ----               |
| MRI               | >= 1.9.3          |
| JRuby             | >= 1.7 (1.9 mode) |
| Rubinius          | >= 2.0            |

## Supported web frameworks

| Framework     | Version       | Native?    |
| ------------- | ------------- |------------|
| Rails         | >= 3.0        | yes        |
| Sinatra       | >= 1.2.1      | yes        |
| Rack          | >= 1.0        | middleware |

Rails and Sinatra are supported natively (install/configure the gem and you're done). For vanilla Rack apps, we provide a collection of middleware that must be installed manually.

To use Rails 2.x, you'll need to use an earlier version of the Honeybadger gem. [Go to version 1.x of the gem docs](https://github.com/honeybadger-io/honeybadger-ruby/blob/1.16-stable/docs/index.md). 

Integrating with other libraries/frameworks is simple! [See the documentation](http://rubydoc.info/gems/honeybadger/) to learn about our public API, and see [Contributing](#contributing) to suggest a patch.

## Supported job queues

| Framework     | Version       | Native?      |
| ------------- | ------------- | ------------ |
| Sidekiq       | any           | yes          |
| Resque        | any           | yes          |
| Delayed Job   | any           | yes          |
| Sucker Punch  | any           | yes          |

You can integrate honeybadger into any Ruby script via the `Honeybadger.notify` method. 

## Getting Started

Honeybadger works out of the box with all popular Ruby frameworks. Installation is just a matter of including the gem and setting your API key. In this section, we'll cover the basics. More advanced installations are covered later. 

### 1. Install the gem


The first step is to add the honeybadger gem to your Gemfile:

```ruby
gem 'honeybadger'
```

Tell bundler to install:

```bash
$ bundle install
```

### 2. Set your API key

Next, you'll set the API key for this project.

```bash
$ bundle exec honeybadger install [YOUR API KEY HERE]
```

This will generate a `config/honeybadger.yml` file. If you don't like config files, you can place your API key in the `$HONEYBADGER_API_KEY` environment variable.

#### Heroku installation

If your app is deployed to heroku, you can configure Honeybadger on your dynos like so:

```bash
$ bundle exec honeybadger heroku install [YOUR API KEY HERE]
```

This will automatically add a `HONEYBADGER_API_KEY` environment variable to your
remote Heroku config and configure deploy notifications.

This step isn't necessary if you're using our [Heroku add-on](https://elements.heroku.com/addons/honeybadger).

### 3. Set up your code

#### Rails

You're done! Any rake tasks and job queues that load the Rails environment are also covered. 

For more info, check out our screencast on getting up and running with Honeybadger and Rails:

[![Using the Honeybadger gem with Rails](https://embed-ssl.wistia.com/deliveries/e1e2133b8f1bec224c57f6677f6bdb11691b3822.jpg?image_play_button=true&image_play_button_color=7b796ae0&image_crop_resized=150x84)](https://honeybadger.wistia.com/medias/l3cmyucx8f)

#### Sinatra

All you need to do is to include the honeybadger gem: 

```ruby
# Always require Sinatra first.
require 'sinatra'
# Then require honeybadger.
require 'honeybadger'
# Define your application code *after* Sinatra *and* honeybadger:
get '/' do
  raise "Sinatra has left the building"
end
```

#### Rack

With rack, you have to do things manually, but it's still just a few lines of code:

```ruby
require 'rack'
 
# Load the gem
require 'honeybadger'
 
# Write your app
app = Rack::Builder.app do
{'fraction_non_alphanumeric': 0.12005441559913842, 'fraction_numerical': 0.009749461512300193, 'mean_word_length': 3.019134396355353, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 18, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7671803', 'n_tokens_mistral': 2865, 'n_tokens_neox': 2647, 'n_words': 917}