punchy_pp 0.0.0 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 808209467a2fcb9c60e695e881084e699769337e805954690c40c776146a86e5
4
- data.tar.gz: d06ca534f20422316534dfcecc2e7b1f6ce51e60d3469a6b52b81ea02dcf427d
3
+ metadata.gz: f4e04e027acca25c4ac861c86a5b9b699279fdca62e1a825c75940dfd6d3a31e
4
+ data.tar.gz: c1a4172697e8803757e0260fe608ff801c8f77700f35a060346fca940a235898
5
5
  SHA512:
6
- metadata.gz: ffbe103d697878d16637a587297aa81ea3c6a80a0989589b2b8f0ac80d007be75b441e8e5ca33892e9ff1f70290057061167577befb01ef8700a378fc53439a8
7
- data.tar.gz: f552143fae9f666bb1f70f011f09ccea4d6d0e5733cbdf4216ed08e50d4a54343e01cd363ae0e4dc3a7a76ca3a9d6975bf6f905653c0110c98a6265bec63fc0f
6
+ metadata.gz: d086c53ccb99ca5ba471b3c0d3ff2a687bf089ace337756fcc97b7b4624401d61a01a588f7b254098f55f0acffc707ea6e223e973d43bfd92237e5d80efadb6b
7
+ data.tar.gz: e433eed593a2fb20e0446d0cdb390c1631458514da7280cc7283d4f061c74f01b6ee4ee13beaf985257227f44bd2711c9a52432f01bc45f2c2ac5b350e3dfb18
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  _A "whistle key finder" for you *puts*_
4
4
 
5
5
 
6
- ## WAT?
6
+ ## WhAt?
7
7
 
8
8
  * Are you a [puts debuguerer](https://tenderlovemaking.com/2016/02/05/i-am-a-puts-debuggerer/)?
9
9
  * You tired of playing 'Where's Waldo' with your `puts`?
@@ -13,22 +13,22 @@ _A "whistle key finder" for you *puts*_
13
13
  If any of these is a **YES**, then, my dear friend, here I've got some well-deserved **punchy** for your puts'es
14
14
 
15
15
  ## Usage
16
+ If you are using Rails, `bundle add punchy_pp` and you are good to go.
16
17
 
17
- `bundle add punchy_pp` or `gem install punchy_pp` and then include punchy_pp's printer method `#ppp` in the top-level object, like so:
18
-
19
- > Note: `#ppp` stands for `Punchy Pretty Print`, or `Power pp` or _something_ pee pee :thinking:
18
+ If not, then you also need to include punchy_pp's printer method `#ppp` in the top-level object, like so:
20
19
 
21
20
  ```ruby
22
21
  require "punchy_pp"
23
- include PunchyPP::Methods
22
+ include PunchyPP::Methods # or self.extend PunchyPP::Methods
24
23
 
25
- ppp "conspicuous"
24
+ ppp "Punchy"
26
25
  ```
27
26
 
28
27
  And you'll get something like:
29
28
 
30
29
  ![image of command line interface with very conspicuous strings](image.png)
31
30
 
31
+
32
32
  ## Development, Contributing, License, CoC, etc, etc, etc
33
33
 
34
- MIT, Contributor Covenant Code of Conduct, etc, all the standard stuff Bundler happily made for me :grinning: Just reach out with an issue or PR
34
+ MIT, Contributor Covenant Code of Conduct, etc, all the standard stuff Bundler happily made for us all :grinning: Just reach out with an issue or PR
@@ -0,0 +1,3 @@
1
+ module PunchyPP
2
+ VERSION = "0.0.2"
3
+ end
data/lib/punchy_pp.rb CHANGED
@@ -1,10 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "pp"
4
+ require_relative "railtie" if defined?(Rails::Railtie)
4
5
 
5
6
  module PunchyPP
6
- VERSION = "0.0.0"
7
-
8
7
  LINE_CONTINUATIION = "\e[94m···\e[0m "
9
8
  PATTERNS = {
10
9
  white: "\e[30m\e[107m%s\e[0m",
@@ -17,19 +16,21 @@ module PunchyPP
17
16
  red: "\e[97m\e[101m%s\e[0m"
18
17
  }
19
18
 
20
- PATTERNS.each do |color, pattern|
19
+ COLOR_QUEUE = Queue.new
20
+ PATTERNS.keys.each do |color|
21
+ COLOR_QUEUE.push(color)
21
22
  define_method color do |text|
22
- pattern % text
23
+ PATTERNS[color] % text
23
24
  end
24
25
  end
25
26
 
26
- COLOR_CYCLE = PATTERNS.keys.cycle
27
-
28
27
  def cycle_color
29
- @current_color = config[:color] || COLOR_CYCLE.next
28
+ color = COLOR_QUEUE.pop
29
+ COLOR_QUEUE.push(color)
30
+ @current_color = config[:color] || color
30
31
  end
31
32
 
32
- def color
33
+ def current_color
33
34
  @current_color || cycle_color
34
35
  end
35
36
 
@@ -42,7 +43,7 @@ module PunchyPP
42
43
  end
43
44
 
44
45
  def paint(text)
45
- send PunchyPP.color, text
46
+ send current_color, text
46
47
  end
47
48
 
48
49
  def border(text = nil)
@@ -96,10 +97,11 @@ module PunchyPP
96
97
  out border " "
97
98
  end
98
99
 
99
- extend self
100
100
  module Methods
101
101
  def ppp(*objects)
102
102
  PunchyPP.puts(*objects)
103
103
  end
104
104
  end
105
+
106
+ extend self
105
107
  end
data/lib/railtie.rb ADDED
@@ -0,0 +1,8 @@
1
+ module PunchyPP
2
+ class Railtie < ::Rails::Railtie
3
+ initializer "punchy_pp.include_methods" do
4
+ main = Object.const_get(:TOPLEVEL_BINDING).eval("self")
5
+ main.extend(PunchyPP::Methods)
6
+ end
7
+ end
8
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: punchy_pp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernando Martínez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-08-15 00:00:00.000000000 Z
11
+ date: 2024-09-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Are you a puts debuguerer too? Tired of playing 'Where's Waldo' with
14
14
  your `puts`? Sick of losing and forgeting where the heck you've _put_ them in your
@@ -29,6 +29,8 @@ files:
29
29
  - Rakefile
30
30
  - image.png
31
31
  - lib/punchy_pp.rb
32
+ - lib/punchy_pp/version.rb
33
+ - lib/railtie.rb
32
34
  - sig/punchy_pp.rbs
33
35
  homepage: https://github.com/sinaptia/punchy_pp
34
36
  licenses:
@@ -50,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
52
  - !ruby/object:Gem::Version
51
53
  version: '0'
52
54
  requirements: []
53
- rubygems_version: 3.5.3
55
+ rubygems_version: 3.5.18
54
56
  signing_key:
55
57
  specification_version: 4
56
58
  summary: The puts debugguerer's indispensable companion