colorputs 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/colorputs.rb +32 -0
  3. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b6fb4e8d351679f23b4ad4d6aa8fa9067aa69c20
4
+ data.tar.gz: 42cb9ff58d72f81ed614d1e5f2eb5b17557254bb
5
+ SHA512:
6
+ metadata.gz: 435259c4ae0121a1304d8b729a3d349ed1c33defb7f673fc98bf32fe68dc868d0eb114862089cb686bac503798c25376871868a5a527d682610a9c614d601afb
7
+ data.tar.gz: 1617dc47d8529fbc8cb0d67c444549d84f07f141ae8abc2864405fc5f0263b7087c6e6d522638c0536cd8406540c111ad6d33e73212be8377e5bfa5529537deb
data/lib/colorputs.rb ADDED
@@ -0,0 +1,32 @@
1
+ module Kernel
2
+ __colors__ = {
3
+ red: '[91m',
4
+ green: '[92m',
5
+ yellow: '[93m',
6
+ blue: '[94m',
7
+ magenta: '[95m',
8
+ cyan: '[96m',
9
+ white: '[37m',
10
+ black: '[30m'
11
+ }
12
+
13
+ old_puts = method :puts
14
+
15
+ aux_rb_body = proc do |str|
16
+ str.chars.inject("") {|acc,c| acc << "\e[5m\e" + __colors__.values[rand(__colors__.size - 1)] + c}.<< "\e[0m"
17
+ end
18
+
19
+ p_color_body = proc do |print_m_sym, obj, color = nil|
20
+ color_s = if color == :rainbow
21
+ aux_rb_body.(obj.send(print_m_sym))
22
+ elsif color && __colors__[color.to_sym]
23
+ "\e#{__colors__[color.to_sym]}#{obj.send(print_m_sym)}\e[0m"
24
+ else
25
+ obj
26
+ end
27
+ old_puts.(color_s)
28
+ end.curry()
29
+
30
+ define_method :puts, p_color_body.(:to_s)
31
+ define_method :p, p_color_body.(:inspect)
32
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: colorputs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Agustín Beamurguía, Lautaro De León
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-10-07 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Enables to use puts and p standard methods with a easy color interface
14
+ email:
15
+ - agus.beam@gmail.com, laudleon@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/colorputs.rb
21
+ homepage: http://github.com/lndl
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib/
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.0.7
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Color in puts method!!
45
+ test_files: []