nub 0.0.28 → 0.0.29

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: 016841fd882525bfb3325351d440b2e55a0657a596fba9678a322521292779e7
4
- data.tar.gz: 78bcbe33e95f0abb4adf322845e31adf796f8a75ae30d2c4b31ca74f0d58c826
3
+ metadata.gz: a2d2c2ee5ea0dfbc1a6ab81edabe2df53d1ca2381a64f70645b314fab80ae46c
4
+ data.tar.gz: 4e757be870d2e93d4a997750390b365240a06872e89716d6571a667b48f2eecf
5
5
  SHA512:
6
- metadata.gz: 30a79b7d0b62241bdc8895abefb65c25f64cc2d7785b1184d1167e6d79c509747d2737cb143c77aa5954831f4b05de0be8e94c51e5903f05f65e026cbaeb00d1
7
- data.tar.gz: e6410024d881ff21d1d3cce45464e9f33819484da7189228988e0b8da8792cf41fb9ebd49b8a82ac29043c16ff33b318c8c499a33fec2187d5ee3a318d297d06
6
+ metadata.gz: ca89d8100c847e6cfee9e72f32bc2242729ad7f5e4f5003f20cc7695e9b5de0582ee73b1cf614c750d3b6e045c31947051114a37a8fd8f213593ba0bc44169f5
7
+ data.tar.gz: b173a64794b3304deea13bf2ea297ecac74e410f81d71a9ff03f7de978048a4633016d4c048b86af0948e98b3a39f30f6eb86b70954ef50f0d4df7275430cf0a
data/lib/nub/commander.rb CHANGED
@@ -157,8 +157,10 @@ class Commander
157
157
  # @returns [String] the app's help string
158
158
  def help
159
159
  help = "#{banner}\n"
160
- newline = (!@examples.nil? && !@examples.empty? && @examples[-1] != "\n") ? "\n" : ""
161
- help += "Examples:\n#{@examples}\n#{newline}" if !@examples.nil? && !@examples.empty?
160
+ if !@examples.nil? && !@examples.empty?
161
+ newline = Sys.strip_colorize(@examples)[-1] != "\n" ? "\n" : ""
162
+ help += "Examples:\n#{@examples}\n#{newline}"
163
+ end
162
164
  help += "Usage: ./#{@app} [commands] [options]\n"
163
165
  help += " #{'-h|--help'.ljust(@just)}Print command/options help: Flag\n"
164
166
  help += "COMMANDS:\n"
data/lib/nub/log.rb CHANGED
@@ -121,7 +121,7 @@ module Log
121
121
  str = format(str) if stamp
122
122
 
123
123
  if !str.empty?
124
- @file << strip_colorize(str) if @path
124
+ @file << Sys.strip_colorize(str) if @path
125
125
  @@_queue << str if @@_queue
126
126
  $stdout.print(str) if @@_stdout
127
127
  end
@@ -145,7 +145,7 @@ module Log
145
145
  str = format(str) if stamp
146
146
 
147
147
  # Handle output
148
- @file.puts(strip_colorize(str)) if @path
148
+ @file.puts(Sys.strip_colorize(str)) if @path
149
149
  @@_queue << "#{str}\n" if @@_queue
150
150
  $stdout.puts(str) if @@_stdout
151
151
 
@@ -189,15 +189,6 @@ module Log
189
189
  return @@_queue ? @@_queue.empty? : true
190
190
  end
191
191
 
192
- # Strip the ansi color codes from the given string
193
- # @param str [String] string with ansi color codes
194
- # @returns [String] string without any ansi codes
195
- def strip_colorize(str)
196
- @@_monitor.synchronize{
197
- return str.gsub(/\e\[0;[39]\d;49m/, '').gsub(/\e\[0m/, '')
198
- }
199
- end
200
-
201
192
  # Tokenize the given colorized string
202
193
  # @param str [String] string with ansi color codes
203
194
  # @returns [Array] array of Token
data/lib/nub/sys.rb CHANGED
@@ -49,6 +49,14 @@ module Sys
49
49
  end
50
50
 
51
51
  end
52
+
53
+ # Strip the ansi color codes from the given string
54
+ # @param str [String] string with ansi color codes
55
+ # @returns [String] string without any ansi codes
56
+ def self.strip_colorize(str)
57
+ return str.gsub(/\e\[0;[39]\d;49m/, '').gsub(/\e\[0m/, '')
58
+ end
59
+
52
60
  end
53
61
 
54
62
  # vim: ft=ruby:ts=2:sw=2:sts=2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.28
4
+ version: 0.0.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Crummett