extra_print 1.1.7 → 2.0.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.
- checksums.yaml +4 -4
- data/lib/extra_print.rb +39 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cc49409e4be0233306cef829101163c967cbc2a
|
4
|
+
data.tar.gz: 650c8cf22e18542d27d1ec297e7098383755b574
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff36e93cea7e7badf3947b33c3f98418b0622aa8b42412f5fe27ead2d853ec972067e83a87859405b976fa6c3357c481360db601c840cfd3fd128be488f52441
|
7
|
+
data.tar.gz: 9acccfad7f9dc44f65befe9d178d43b7a390ddc163668ede8a5361910867a65fec150bbc9c249aa8d1ddf43cf0d2918a3d80ac9696d464b9e535ac81600b8f58
|
data/lib/extra_print.rb
CHANGED
@@ -12,8 +12,26 @@ $EMOJIS = %w"😎 😈 👹 👺 👻 👿 💀 👽 😂 🤣 🎃 🐶 🦊
|
|
12
12
|
# There are cleaner ways of doing the color manipulation
|
13
13
|
# But this approach avoids extra dependencies, which is better :-)
|
14
14
|
|
15
|
-
# Simply call
|
16
|
-
# Alternatively, call
|
15
|
+
# Simply call pe or pea (extra_awesome_print) and pass a variable you want to inspect.
|
16
|
+
# Alternatively, call pe or pea with no arguments to display an emoji line break and calling line info.
|
17
|
+
|
18
|
+
def pe(*args)
|
19
|
+
@caller_path = caller
|
20
|
+
return display_emoji_break if args.empty?
|
21
|
+
extra_print(args[0], args[1])
|
22
|
+
return_value(args[0])
|
23
|
+
end
|
24
|
+
|
25
|
+
def pea(*args)
|
26
|
+
@caller_path = caller
|
27
|
+
return display_emoji_break if args.empty?
|
28
|
+
extra_print(args[0], args[1], true)
|
29
|
+
return_value(args[0])
|
30
|
+
end
|
31
|
+
|
32
|
+
#######################################################################
|
33
|
+
# NOTE: LEGACY CODE #ep #eap ensure compatibility for future versions #
|
34
|
+
#######################################################################
|
17
35
|
|
18
36
|
def ep(*args)
|
19
37
|
@caller_path = caller
|
@@ -33,11 +51,20 @@ private
|
|
33
51
|
|
34
52
|
def extra_print(variable = nil, msg = nil, add_awesome_print = false)
|
35
53
|
# Set variables
|
36
|
-
@color = $COLORS.values.sample
|
37
54
|
@variable = variable
|
38
55
|
@msg = msg ? msg : " FINISH "
|
39
|
-
|
40
|
-
|
56
|
+
|
57
|
+
# No red/green if calling from a spec
|
58
|
+
if $0.split('.').last[/spec|test/]
|
59
|
+
$COLORS.delete('red')
|
60
|
+
$COLORS.delete('green')
|
61
|
+
@color = $COLORS.values.sample
|
62
|
+
@secondary_color = '034'
|
63
|
+
else
|
64
|
+
@color = $COLORS.values.sample
|
65
|
+
# If the color being passed in is RED set secondary color to BLUE
|
66
|
+
@secondary_color = @color == '031' ? '034' : '031'
|
67
|
+
end
|
41
68
|
|
42
69
|
# View Methods
|
43
70
|
display_detail_header
|
@@ -49,7 +76,12 @@ end
|
|
49
76
|
# IF so returns value, enabling ep's from the end of a method without disrupting functionality.
|
50
77
|
# ELSE returns nil, presuming it is running in a REPL and we don't want to see our output doubled because the REPL prints the return value as well.
|
51
78
|
def return_value(val)
|
52
|
-
|
79
|
+
return val if defined?(Rails::Server)
|
80
|
+
return nil if defined?(Rails::Console)
|
81
|
+
return nil if $0.split('.').last.include? 'pry'
|
82
|
+
return nil if $0.split('.').last.include? 'irb'
|
83
|
+
return val if $0.split('.').last == 'rb'
|
84
|
+
val
|
53
85
|
end
|
54
86
|
|
55
87
|
def path_clip
|
@@ -64,7 +96,7 @@ def display_variable(add_awesome_print)
|
|
64
96
|
indent: -2, # left aligned
|
65
97
|
sort_keys: true, # sort hash keys
|
66
98
|
}
|
67
|
-
ap
|
99
|
+
ap @variable
|
68
100
|
else
|
69
101
|
p proc.call
|
70
102
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: extra_print
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hunter T. Chapman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|