Sha256: a98bcb372d974f9b6d3f075d882c9279c2e36e7a45b4fb1b9988a3d33abcc867

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

# 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.

## Usage

Pizzazzifing an object is simple:

``` ruby
object = { name: 'Sam Soffes', website: 'http://samsoff.es' }
Pizzazz.ify(object)
#=> "{\n  <span class=\"string\">\"name\"</span>: <span class=\"string\">\"Sam Soffes\"</span>,\n  <span class=\"string\">\"website\"</span>: <span class=\"string\">\"http://samsoff.es\"</span>\n}"
```

You can optionally limit arrays as well:

``` ruby
Pizzazz.ify(all_of_the_things, limit: 1)
```

This will add an ellipses after the first element.

### HTML

Spans are added around various elements. Here's the classes:

* `string`
* `constant` (for `true` or `false`
* `null`
* `number`

Everything else is left alone. It is recommended to wrap the output like this:

``` html
<pre><%= Pizzazz.ify(object).html_safe %></pre>
```

Here's my stylesheet if you're interested:

``` css
pre {
  border-radius: 5px;
  background: #f7f7f7;
  padding: 0.5em;
  margin-bottom: 2em;
  border: 1px solid #ddd;
}

.string {
  color: #ee6132;
}

.null, .number, .constant {
  color: #8e75c3;
}

.comment {
  color: #999;
  font-style: italic;
}
```

## 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. Enjoy.

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pizzazz-0.1.0 Readme.markdown