Skip to content

geronime/ruby-simplepp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ruby-simplepp - simple pretty print

ruby-simplepp is a module to simple string pretty print of hash/array structures.

Usage:

require 'ruby-simplepp'
pretty = SimplePP.pp(struct, indent_level=0, indent_str='  ')
  • indent_level specifies starting indentation level (internally used for recursion as well)
  • indentation string can be redefined with indent_str (defaults to two spaces)

Example:

irb> puts SimplePP.pp struct
{
  "resource" => "anywhere",
  "q"        => "Some query",
  "search"   => "fulltext",
  "limit"    => 20,
  "details"  => false,
  "foo"      => nil,
  "bar"      => "baz",
  "result"   => {
    "search_time" => 0.532,
    "item_count"  => 1,
    "items"       => [
      {
        "name" => "Item name",
        "url"  => "http://foo.bar.baz"
      }
    ]
  }
}

Changelog:

  • 0.0.2: symbols displayed as symbols, empty hashes/arrays are not newlined
  • 0.0.1: first revision of simple pretty print

License:

ruby-simplepp is copyright (c)2012 Jiri Nemecek, and released under the terms of the MIT license. See the LICENSE file for the gory details.

About

simple string pretty print of hash/array structures in ruby

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages