Socket
Book a DemoInstallSign in
Socket

pretty_hash

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pretty_hash

0.0.2
bundlerRubygems
Version published
Maintainers
1
Created
Source

PrettyHash

PrettyPrint the Hash

Format to the ascii table format for Hash. It's very small library.

Installation

Add this line to your application's Gemfile:

gem 'pretty_hash'

And then execute:

$ bundle

Or install it yourself as:

$ gem install pretty_hash

Quick Start

require 'pretty_hash'
puts {"a" => "abcde", "bbb" =>  "a"}.to_pp_table
---|-----
  a|abcde
bbb|a
---|-----

Features

Symbol key

{:ccc => "aa", "dddd" => "a"}.to_pp_table

----|--
:ccc|aa
dddd|a
----|--

Proc is applied to the value

v1 = Struct.new(:name).new("foo")
v1.name
=> "foo"
v2 = Struct.new(:name).new("bar")
v2.name
=> "bar"

{:k1 => v1, :k2 => v2}.to_pp_table

---|---------------------
:k1|#<struct name="hoge">
:k2|#<struct name="foo">
---|---------------------

Too bad....

{:k1 => v1, :k2 => v2}.to_pp_table(Proc.new{|c|c.name})

---|----
:k1|hoge
:k2|foo
---|----

Good!

Multibyte

{:ccc => "日本語講座", "dddd" => "a"}.to_pp_table

----|----------
:ccc|日本語講座
dddd|a
----|----------

Just fit width.

Not implement

  • Nested value (e.g.) { a: => {:v1 => 1 }}
    Use to Proc.

Contributing

  • Fork it ( https://github.com/[my-github-username]/pretty_hash/fork )
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create a new Pull Request

FAQs

Package last updated on 24 Jul 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.