Skip to content

Commit

Permalink
thread-safe... thread-safe... thread-safe...
Browse files Browse the repository at this point in the history
  • Loading branch information
F-3r committed Sep 20, 2024
1 parent f600937 commit 092a1b9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ _A "whistle key finder" for you *puts*_
If any of these is a **YES**, then, my dear friend, here I've got some well-deserved **punchy** for your puts'es

## Usage
If you are using Rails, `bundle add punchy_pp` or `gem install punchy_pp` and you are good to go.
If you are using Rails, `bundle add punchy_pp` and you are good to go.

If not, then you also need to include punchy_pp's printer method `#ppp` in the top-level object, like so:

```ruby
require "punchy_pp"
include PunchyPP::Methods
include PunchyPP::Methods # or self.extend PunchyPP::Methods

ppp "Punchy"
```
Expand All @@ -28,6 +28,7 @@ And you'll get something like:

![image of command line interface with very conspicuous strings](image.png)


## Development, Contributing, License, CoC, etc, etc, etc

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
12 changes: 7 additions & 5 deletions lib/punchy_pp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,18 @@ module PunchyPP
red: "\e[97m\e[101m%s\e[0m"
}

PATTERNS.each do |color, pattern|
COLOR_QUEUE = Queue.new
PATTERNS.keys.each do |color|
COLOR_QUEUE.push(color)
define_method color do |text|
pattern % text
PATTERNS[color] % text
end
end

COLOR_CYCLE = PATTERNS.keys.cycle

def cycle_color
@current_color = config[:color] || COLOR_CYCLE.next
color = COLOR_QUEUE.pop
COLOR_QUEUE.push(color)
@current_color = config[:color] || color
end

def current_color
Expand Down

0 comments on commit 092a1b9

Please sign in to comment.