Skip to content

Commit

Permalink
Better: Replace colorize gem with inline code
Browse files Browse the repository at this point in the history
  • Loading branch information
ylecuyer committed Jul 5, 2024
1 parent 4aa4ea1 commit 2a4c095
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 0 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ PATH
remote: .
specs:
puma-status (1.6)
colorize (~> 1.1)
net_http_unix (~> 0.2)
parallel (~> 1)

GEM
remote: https://rubygems.org/
specs:
climate_control (0.2.0)
colorize (1.1.0)
diff-lcs (1.5.0)
net_http_unix (0.2.2)
parallel (1.24.0)
Expand Down
13 changes: 10 additions & 3 deletions lib/helpers.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
require 'colorize'

def debug(str)
puts str if ENV.key?('DEBUG')
end
Expand All @@ -14,7 +12,16 @@ def red(str)

def colorize(str, color_name)
return str if ENV.key?('NO_COLOR')
str.to_s.colorize(color_name)
case color_name
when :red
"\e[0;31;49m#{str}\e[0m"
when :yellow
"\e[0;33;49m#{str}\e[0m"
when :green
"\e[0;32;49m#{str}\e[0m"
else
str
end
end

def color(critical, warn, value, str = nil)
Expand Down
1 change: 0 additions & 1 deletion puma-status.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]
s.executables = ['puma-status']

s.add_runtime_dependency "colorize", '~> 1.1'
s.add_runtime_dependency "net_http_unix", '~> 0.2'
s.add_runtime_dependency "parallel", '~> 1'

Expand Down

0 comments on commit 2a4c095

Please sign in to comment.