extra_print 1.1.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/extra_print.rb +104 -0
  3. metadata +65 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2bd224ffefb3f402b46f04d64b3eae5a6b764ff4
4
+ data.tar.gz: 01a13fe4037679e8fff58afb688946bb64b1f452
5
+ SHA512:
6
+ metadata.gz: 62b75b7f4626021a1afbaf19cef5a66b24d4f754b7c8bae9ed1166592d2207a5c3a6f57e3c73e7164e0c3b142e943360af5f08f53abb2950c089d712377b03c3
7
+ data.tar.gz: f723d6514ef0557db0e595795eb607ed4481cb7a65784d03840c29e28cf6f874a5570f4ef769e5b6879a00eded659662e262919ab4f26a7359220add2d2524c2
@@ -0,0 +1,104 @@
1
+ $COLORS = {'red' => '031','green' => '032','yellow' => '033','blue' => '034','magenta' => '035','cyan' => '036'}
2
+
3
+ #### DEBUGGING gems ####
4
+ # require 'awesome_print'
5
+ # require 'pry-byebug'
6
+ ########################
7
+
8
+ # Using ANSI color coding to spruce things up
9
+ # SYNTAX: \033[COLOR_CODEmINNER_TEXT\033[0m
10
+ # There are cleaner ways of doing the color manipulation
11
+ # But this approach avoids extra dependencies, which is better :-)
12
+
13
+ def eap(variable = nil, msg = nil)
14
+ @caller_path = caller
15
+ return display_emoji_break unless variable
16
+ extra_print(variable, msg, true)
17
+ variable
18
+ end
19
+
20
+ def ep(variable = nil, msg = nil)
21
+ @caller_path = caller
22
+ return display_emoji_break unless variable
23
+ extra_print(variable, msg)
24
+ variable
25
+ end
26
+
27
+ private
28
+
29
+ def extra_print(variable = nil, msg = nil, add_awesome_print = false)
30
+ # Set variables
31
+ @color = $COLORS.values.sample
32
+ @variable = variable
33
+ @msg = msg ? msg : " FINISH "
34
+ # If the color being passed in is RED set secondary color to BLUE
35
+ @secondary_color = @color == '031' ? '034' : '031'
36
+
37
+ # View Methods
38
+ display_detail_header
39
+ display_variable(add_awesome_print)
40
+ display_footer
41
+ end
42
+
43
+ def path_clip
44
+ @caller_path[0].split('/').last(2).join('/').split(':in')[0]
45
+ end
46
+
47
+ def display_variable(add_awesome_print)
48
+ proc = Proc.new { @variable }
49
+ puts
50
+ if add_awesome_print
51
+ require 'awesome_print'
52
+ ap proc.call if add_awesome_print
53
+ else
54
+ p proc.call unless add_awesome_print
55
+ end
56
+ puts
57
+ end
58
+
59
+ # 40 rando emojis for fun && eye catching line breaks
60
+ def display_emoji_break
61
+ chars = %w"😎 😈 👹 👺 👻 👿 💀 👽 😂 🤣 🎃 🐶 🦊 ⭐ 🌟 🏈 🏀 ⚽ ⛔ ❓ 💽 🎁 🌠 🥓 🍤 🍗 🍖 🍕 🍰 🍦 🍭"
62
+ emoji = chars.sample
63
+ print "#{emoji} " * 15
64
+ print " #{path_clip} "
65
+ puts "#{emoji} " * 15
66
+ end
67
+
68
+ # TODO: off by one error on dynamic footer length
69
+ def display_footer
70
+ str = "\033[#{@color}m⬆ " * ((@length / 4) - (@msg.length / 2) - 1)
71
+ str += "\033[#{@secondary_color}m #{@msg} "
72
+ str += "\033[#{@color}m⬆ \033[0m" * ((@length / 4))
73
+ puts str
74
+ end
75
+
76
+ def display_detail_header
77
+
78
+ # Initial arrows with a new line padding the top
79
+ str = "\n"
80
+ str += "\033[#{@color}m⬇ \033[m" * 5
81
+
82
+ # Variable Class Display
83
+ str += "\033[#{@color}m CLASS:\033[m"
84
+ str += "\033[#{@secondary_color}m #{@variable.class} \033[m"
85
+
86
+ # IF variable has a length display it
87
+ if @variable.respond_to?(:length)
88
+ str += "\033[#{@color}mLENGTH:\033[m"
89
+ str += "\033[#{@secondary_color}m #{@variable.length} \033[m"
90
+ end
91
+
92
+ # Show where the code was called from last
93
+ str += "\033[#{@color}mCALLER:\033[m"
94
+ str += "\033[#{@secondary_color}m #{path_clip} \033[m"
95
+
96
+ # Closing arrows
97
+ str += "\033[#{@color}m⬇ \033[m" * 5
98
+
99
+ # Output completed string
100
+ puts str
101
+
102
+ # Set @length - non encoded string for use in footer
103
+ @length = str.gsub(/\e\[\d{3}m/, '').gsub(/\e\[m/, '').length
104
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: extra_print
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Hunter Chapman
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-09-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: awesome_print
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.8.0
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.8'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.8.0
33
+ description: Simple gem to display variables and visual breaks.
34
+ email: bootcoder@gmail.com
35
+ executables: []
36
+ extensions: []
37
+ extra_rdoc_files: []
38
+ files:
39
+ - lib/extra_print.rb
40
+ homepage: http://rubygems.org/gems/extra_print
41
+ licenses:
42
+ - MIT
43
+ metadata: {}
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 2.6.13
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: Easily spot variables printed in a busy console.
64
+ test_files: []
65
+ has_rdoc: