# Pizzazz [![Build Status](https://travis-ci.org/soffes/pizzazz.png?branch=master)](https://travis-ci.org/soffes/pizzazz) [![Coverage Status](https://coveralls.io/repos/soffes/pizzazz/badge.png?branch=master)](https://coveralls.io/r/soffes/pizzazz) [![Code Climate](https://codeclimate.com/github/soffes/pizzazz.png)](https://codeclimate.com/github/soffes/pizzazz) [![Dependency Status](https://gemnasium.com/soffes/pizzazz.png)](https://gemnasium.com/soffes/pizzazz) [![Gem Version](https://badge.fury.io/rb/pizzazz.png)](http://badge.fury.io/rb/pizzazz) Pizzazz is a simple pure Ruby implementation of code coloring, but just for JSON. Basically, if you have a ruby object and want to show it converted to JSON and add HTML around it so you can color it. [Cheddar](http://cheddarapp.com) uses this to show example output of it's API calls. [Check it out](https://cheddarapp.com/developer/lists). ## Installation Add this line to your application's Gemfile: ``` ruby gem 'pizzazz' ``` And then execute: $ bundle Or install it yourself as: $ gem install pizzazz Simple as that. ## Usage Pizzazzifing an object is simple: ``` ruby object = { name: 'Sam Soffes', website: 'http://samsoff.es' } Pizzazz.ify(object) #=> "{\n \"name\": \"Sam Soffes\",\n \"website\": \"http://samsoff.es\"\n}" ``` You can optionally limit arrays or values as well: ``` ruby Pizzazz.ify(all_of_the_things, array_limit: 1, value_limit: 100) ``` This will add an ellipses after the first element and truncate values longer than 100 characters. You can replace the ellipses by setting the `array_omission` and then `value_omission` options: ``` ruby Pizzazz.ify(all_of_the_things, array_limit: 'etc', value_omission: '... (continued)') ``` ### HTML Spans are added around various elements. Here's the classes: * `string` * `constant` (`true` or `false`) * `null` * `number` Everything else is left alone. If you want it wrapped in `
` (and call `html_safe` if possible), do the following:

``` ruby
Pizzazz.ify_html(object)
```

### Stylesheet

If you're using the asset pipeline, you can simply require `pizzazz` to get my stylesheet. Be sure your `
` has the `pizzazz` class. If you use `ify_html` it will automatically do this.


## Supported Ruby Versions

Pizzazz is tested under 1.9.2, 1.9.3, 2.0.0, JRuby 1.7.2 (1.9 mode), and Rubinius 2.0.0 (1.9 mode).


## Contributing

See the [contributing guide](Contributing.markdown).