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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/extra_print.rb +39 -7
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d51296c03230ed1f4449712d5095f562bd23751d
4
- data.tar.gz: 2cda1c2a03a78d638254126cf2d54ce00dd9886a
3
+ metadata.gz: 2cc49409e4be0233306cef829101163c967cbc2a
4
+ data.tar.gz: 650c8cf22e18542d27d1ec297e7098383755b574
5
5
  SHA512:
6
- metadata.gz: 6a29ea4d27f8d18e9f0bf1506e21d31a0081fbd932143078c751a9d3085579d399db7a9fc87f9abda25000164bc349de065d29d187c34a44c4a568f7ce913f64
7
- data.tar.gz: 7dc892716e9217ea5346e21f2d6c8dd1f0e978178011c4f301a243015e93954fa81a51b708e1c369cd9312db21515a3ad22d88bd452e269de4764242eaae93bc
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 ep or eap (extra_awesome_print) and pass a variable you want to inspect.
16
- # Alternatively, call ep or eap with no arguments to display an emoji line break when evaluated.
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
- # If the color being passed in is RED set secondary color to BLUE
40
- @secondary_color = @color == '031' ? '034' : '031'
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
- $0.split('.').last == 'rb' ? val : nil
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 proc.call
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: 1.1.7
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-03-28 00:00:00.000000000 Z
11
+ date: 2018-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: awesome_print