colsole 0.8.2 → 1.0.1

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: 277f45ee7c12e0c6090bd41752a275feef3357c38a1d3cbca522f9089ce68d49
4
- data.tar.gz: f21a9866ce164222627f314c4ffe0c16046d705f5d544783b1d5f3598a54cf18
3
+ metadata.gz: c0eb4d2ccfbad964021e0ca4fbc960c9dad7b94656ad9219df64b466923f20f8
4
+ data.tar.gz: 3f7f6cfeaf1ae7a1a3d32e0d079acbd538406947587e33f7af28e8e9bb0fda27
5
5
  SHA512:
6
- metadata.gz: c74ab05a5fea57685109cbcf2bdc033e0b0ba7f191a5ea491e4d31a1bcee335718d7e74481a031b19e99203e14dd34646542985199a001d15c2dbfc0dd52a8da
7
- data.tar.gz: af3bcd3c64f66cc5dd5a89c96f4e92946160082ea08e017e68c3eda311525c6de5688759bdfe858d084231dae835d4c091ed9ca6af225f640ef2803a61b0e4d9
6
+ metadata.gz: d8da75c93b2ec90c5371026a0ab5b592150806e460197b7a61fb2e65f89027238343d55a3bbe1a4be5daff3564f895829cf8377dbbd7edb036bba6f82b3dc267
7
+ data.tar.gz: 8e209b414153ccb313bf10f375dcc95fde7db4d53e8adc57af1f79b1c03a12b415e82e626cb8d37f570b0c731ee372f6a536d14fe0195af3afde248c97ce1222
data/README.md CHANGED
@@ -1,19 +1,15 @@
1
1
  # Colsole
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/colsole.svg)](https://badge.fury.io/rb/colsole)
4
- [![Build Status](https://github.com/DannyBen/colsole/workflows/Test/badge.svg)](https://github.com/DannyBen/colsole/actions?query=workflow%3ATest)
5
- [![Maintainability](https://api.codeclimate.com/v1/badges/0556015f7cd2080531a1/maintainability)](https://codeclimate.com/github/DannyBen/colsole/maintainability)
6
-
7
- ---
3
+ ![repocard](https://repocard.dannyben.com/svg/colsole.svg)
8
4
 
9
5
  Utility functions for colorful console applications.
10
6
 
11
7
  > **Upgrade Note**
12
8
  >
13
- > This README is for the latest version of colsole (0.8.x), which is compatible
14
- > with older versions. Version 1.x will NOT be compatible.
9
+ > - Version 1.0.x is not compatible with older versions
10
+ > - Version 0.8.x is compatible with both the old syntax and new syntax
15
11
  >
16
- > See [Uprading](#upgrading) below.
12
+ > See [Upgrading](#upgrading) below.
17
13
 
18
14
  ## Install
19
15
 
@@ -1,3 +1,3 @@
1
1
  module Colsole
2
- VERSION = '0.8.2'
2
+ VERSION = '1.0.1'
3
3
  end
data/lib/colsole.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require 'io/console'
2
- require 'colsole/compat'
3
2
 
4
3
  # Utility functions for colorful console applications.
5
4
  module Colsole
@@ -105,24 +104,20 @@ module_function
105
104
 
106
105
  # Convert color markers to ansi colors.
107
106
  def colorize(string)
108
- # compatibility later
109
- compat_string = old_colorize string
110
-
111
- process_color_markers compat_string do |color, styles, text|
107
+ process_color_markers string do |color, styles, text|
112
108
  "#{styles}#{color}#{text}#{ANSI_STYLES['z']}"
113
109
  end
114
110
  end
115
111
 
116
112
  # Remove color markers.
117
113
  def strip_colors(string)
118
- # compatibility layer
119
- compat_string = old_strip_colors string
120
-
121
- process_color_markers(compat_string) { |_color, _styles, text| text }
114
+ process_color_markers(string) { |_color, _styles, text| text }
122
115
  end
123
116
 
124
117
  def process_color_markers(string)
125
- string.gsub(/([rgybmcn])([ubi]{0,3})`([^`]*)`/) do
118
+ color_codes = Regexp.union(ANSI_COLORS.keys)
119
+
120
+ string.gsub(/(#{color_codes})([ubi]{0,3})`([^`]*)`/) do
126
121
  color = ANSI_COLORS[$1]
127
122
  styles = $2.chars.map { |a| ANSI_STYLES[a] }.join
128
123
  text = $3
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: colsole
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danny Ben Shitrit
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-01-25 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: Utility functions for making colorful console applications
14
13
  email: db@dannyben.com
@@ -18,14 +17,15 @@ extra_rdoc_files: []
18
17
  files:
19
18
  - README.md
20
19
  - lib/colsole.rb
21
- - lib/colsole/compat.rb
22
20
  - lib/colsole/version.rb
23
21
  homepage: https://github.com/DannyBen/colsole
24
22
  licenses:
25
23
  - MIT
26
24
  metadata:
25
+ bug_tracker_uri: https://github.com/DannyBen/colsole/issues
26
+ changelog_uri: https://github.com/DannyBen/colsole/blob/master/CHANGELOG.md
27
+ source_code_uri: https://github.com/DannyBen/colsole
27
28
  rubygems_mfa_required: 'true'
28
- post_install_message:
29
29
  rdoc_options: []
30
30
  require_paths:
31
31
  - lib
@@ -33,15 +33,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
33
33
  requirements:
34
34
  - - ">="
35
35
  - !ruby/object:Gem::Version
36
- version: 2.6.0
36
+ version: '3.1'
37
37
  required_rubygems_version: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  requirements: []
43
- rubygems_version: 3.4.5
44
- signing_key:
43
+ rubygems_version: 4.0.3
45
44
  specification_version: 4
46
45
  summary: Colorful Console Applications
47
46
  test_files: []
@@ -1,61 +0,0 @@
1
- # This file contains methods that are called by the main Colsole module
2
- # for compatibility with older versions of colsole.
3
- # Do not use these methods directly.
4
- module Colsole
5
- module_function
6
-
7
- def detect_terminal_size(*args)
8
- terminal_size(*args)
9
- end
10
-
11
- def old_colorize(text)
12
- reset = colors['txtrst']
13
- reset_called_last = true
14
-
15
- out = text.gsub(/!([a-z]{6})!/) do
16
- reset_called_last = $1 == 'txtrst'
17
- colors[$1]
18
- end
19
-
20
- reset_called_last or out = "#{out}#{reset}"
21
- out
22
- end
23
-
24
- def old_strip_colors(text)
25
- text.gsub(/!([a-z]{6})!/, '')
26
- end
27
-
28
- def resay(text)
29
- say text, replace: true
30
- end
31
-
32
- def say_status(status, message = nil, color = nil)
33
- color ||= (message ? :txtgrn : :txtblu)
34
- say "!#{color}!#{status.to_s.rjust 12} !txtrst! #{message}".strip
35
- end
36
-
37
- def colors
38
- @colors ||= begin
39
- esc = 27.chr
40
- pattern = "#{esc}[%{decor};%{fg}m"
41
-
42
- decors = { txt: 0, bld: 1, und: 4, rev: 7 }
43
- color_codes = { blk: 0, red: 1, grn: 2, ylw: 3, blu: 4, pur: 5, cyn: 6, wht: 7 }
44
- colors = {}
45
-
46
- decors.each do |dk, dv|
47
- color_codes.each do |ck, cv|
48
- key = "#{dk}#{ck}"
49
- val = pattern % { decor: dv, fg: "3#{cv}" }
50
- colors[key] = val
51
- end
52
- end
53
-
54
- colors['txtbld'] = "#{esc}[1m"
55
- colors['txtund'] = "#{esc}[4m"
56
- colors['txtrev'] = "#{esc}[7m"
57
- colors['txtrst'] = "#{esc}[0m"
58
- colors
59
- end
60
- end
61
- end