rainbow_hash 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 75e5485df1c03e6115814ddc9c55edc68b6e4765
4
+ data.tar.gz: 88e8c9ac827a445779a1b1bcfa2c10c53acfafcb
5
+ SHA512:
6
+ metadata.gz: 7e4912be19f735cef28735ad3edc333f32bcf5b9d8bd5b4d5b5abb4274e8c0b3b5a85802037f17d4e3a62b9b5975047d911313d05be3c337e95174095308bc72
7
+ data.tar.gz: 695767fca48c8f3754e5aa57cab8f35f37fcabf0394add313c5e24844dbd069a8aca9f6a0e0e8445eaac135014d0fe80d1a1abf51f9dfb0194c2c765803029df
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rainbow_hash.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Jay Wengrow
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # RainbowHash
2
+
3
+ This simple gem gives you the ability to print out a structure of arrays and hashes in a pretty way straight from your terminal.
4
+
5
+ ## Installation
6
+
7
+ Install it by running the following command from your terminal:
8
+
9
+ $ gem install rainbow_hash
10
+
11
+ If you use Rbenv to manage your Ruby versions, you may have to run:
12
+
13
+ $ rbenv rehash
14
+
15
+ ## Usage
16
+
17
+ From your terminal, run the `rainbow` command followed by your data structure surrounded by quotation marks.
18
+
19
+ For example, if you wanted to view the following hash from your terminal:
20
+
21
+ [TEST, {a: 1, [2, 3, 4]}]
22
+
23
+ you would run:
24
+
25
+ rainbow "[TEST, {a: 1, [2, 3, 4, {cow: 'moo'}]}]"
26
+
27
+ And watch the results!
28
+
29
+ ## Contributing
30
+
31
+ 1. Fork it ( https://github.com/[my-github-username]/rainbow_hash/fork )
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/rainbow ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/rainbow_hash"
4
+
5
+ RainbowHash::Display.print(ARGV[0])
@@ -0,0 +1,56 @@
1
+ module RainbowHash
2
+
3
+ class Display
4
+
5
+ def self.print(string)
6
+ self.new(string).output
7
+ end
8
+
9
+ def initialize(string)
10
+ @string = string
11
+ @color_stack = 30
12
+ @indentation_level = 0
13
+ end
14
+
15
+ def output
16
+ new_string = ""
17
+ @string.each_char do |char|
18
+ if beginning_delimeter?(char)
19
+ increment_level
20
+ new_string += "\n" + (" " * @indentation_level)
21
+ end
22
+ new_string += colorize(char)
23
+ if ending_delimeter?(char)
24
+ decrement_level
25
+ new_string += "\n" + (" " * @indentation_level)
26
+ end
27
+ end
28
+ puts new_string
29
+ end
30
+
31
+ private
32
+
33
+ def beginning_delimeter?(char)
34
+ char == "[" || char == "{"
35
+ end
36
+
37
+ def ending_delimeter?(char)
38
+ char == "]" || char == "}"
39
+ end
40
+
41
+ def colorize(char)
42
+ "\e[#{@color_stack}m#{char}\e[0m"
43
+ end
44
+
45
+ def increment_level
46
+ @color_stack += 1
47
+ @indentation_level += 2
48
+ end
49
+
50
+ def decrement_level
51
+ @color_stack -= 1
52
+ @indentation_level -= 2
53
+ end
54
+ end
55
+
56
+ end
@@ -0,0 +1,3 @@
1
+ module RainbowHash
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,6 @@
1
+ require "rainbow_hash/version"
2
+ require "rainbow_hash/display"
3
+
4
+ module RainbowHash
5
+
6
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rainbow_hash/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rainbow_hash"
8
+ spec.version = RainbowHash::VERSION
9
+ spec.authors = ["Jay Wengrow"]
10
+ spec.email = ["jaywngrw@gmail.com"]
11
+ spec.summary = %q{Run your complex hashes and arrays through this gem to see a pretty output of it in your terminal.}
12
+ spec.description = %q{Run your complex hashes and arrays through this gem to see a pretty output of it in your terminal.}
13
+ spec.homepage = "https://github.com/jaywengrow/rainbow_hash"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rainbow_hash
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jay Wengrow
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-05-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Run your complex hashes and arrays through this gem to see a pretty output
42
+ of it in your terminal.
43
+ email:
44
+ - jaywngrw@gmail.com
45
+ executables:
46
+ - rainbow
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - ".gitignore"
51
+ - Gemfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - bin/rainbow
56
+ - lib/rainbow_hash.rb
57
+ - lib/rainbow_hash/display.rb
58
+ - lib/rainbow_hash/version.rb
59
+ - rainbow_hash.gemspec
60
+ homepage: https://github.com/jaywengrow/rainbow_hash
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.2.2
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Run your complex hashes and arrays through this gem to see a pretty output
84
+ of it in your terminal.
85
+ test_files: []