<commit_before># Airbrake::Sinatra

The helper method provided with the official Airbrake gem is specific to Rails
and requires a bit of hacking to get working in Sinatra. This gem exists to
serve as a Sinatra helper method for the Airbrake Javascript.

## Installation

Add this line to your application's Gemfile:

    gem 'airbrake-sinatra'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install airbrake-sinatra

## Usage

There are two sample applications in the source code on Github. You will find
them under the `examples/` directory. One of them shows how to use this gem with
a standard Sinatra `server.rb` file. The other shows how to use this gem with
your own class that extends `Sinatra::Base`. There is a subtle difference :)

Essentially all it boils down to is using the `airbrake_javascript_sinatra`
helper in your views. An example layout might look something like this:

``` haml
%head
  = airbrake_javascript_sinatra
%body
  %p
    The Airbrake javascript helper is outputting the following into the header:
    %pre= h airbrake_javascript_sinatra
```

## Developing

There are two Rake tasks that are there for development purposes:

    $ rake example:one<commit_msg>Updated README.<commit_after># Airbrake::Sinatra

The helper method provided with the official Airbrake gem is specific to Rails
and requires a bit of hacking to get working in Sinatra. This gem exists to
serve as a Sinatra helper method for the Airbrake Javascript.

## Installation

Add this line to your application's Gemfile:

    gem 'airbrake-sinatra', :require => 'sinatra/airbrake-javascript'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install airbrake-sinatra

## Usage

There are two sample applications in the source code on Github. You will find
them under the `examples/` directory. One of them shows how to use this gem with
a standard Sinatra `server.rb` file. The other shows how to use this gem with
your own class that extends `Sinatra::Base`. There is a subtle difference :)

Essentially all it boils down to is using the `airbrake_javascript_sinatra`
helper in your views. An example layout might look something like this:

``` haml
%head
  = airbrake_javascript_sinatra
%body
  %p
    The Airbrake javascript helper is outputting the following into the header:
    %pre= h airbrake_javascript_sinatra
```

Note that if you do not use `Bundler.require` with the `gem` line specified in
the above section you will need to require the gem manually like so:

``` ruby
require 'sinatra/airbrake-javascript'
```

## Developing

There are two Rake tasks that are there for development purposes:

    $ rake example:one
{'fraction_non_alphanumeric': 0.054185351270553066, 'fraction_numerical': 0.0, 'mean_word_length': 4.1980582524271846, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, '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': '7261514', 'n_tokens_mistral': 770, 'n_tokens_neox': 728, 'n_words': 376}