colsole 0.8.1 → 0.8.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 +4 -4
- data/README.md +35 -23
- data/lib/colsole/compat.rb +2 -0
- data/lib/colsole/version.rb +1 -1
- data/lib/colsole.rb +2 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 277f45ee7c12e0c6090bd41752a275feef3357c38a1d3cbca522f9089ce68d49
|
4
|
+
data.tar.gz: f21a9866ce164222627f314c4ffe0c16046d705f5d544783b1d5f3598a54cf18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c74ab05a5fea57685109cbcf2bdc033e0b0ba7f191a5ea491e4d31a1bcee335718d7e74481a031b19e99203e14dd34646542985199a001d15c2dbfc0dd52a8da
|
7
|
+
data.tar.gz: af3bcd3c64f66cc5dd5a89c96f4e92946160082ea08e017e68c3eda311525c6de5688759bdfe858d084231dae835d4c091ed9ca6af225f640ef2803a61b0e4d9
|
data/README.md
CHANGED
@@ -9,10 +9,10 @@
|
|
9
9
|
Utility functions for colorful console applications.
|
10
10
|
|
11
11
|
> **Upgrade Note**
|
12
|
-
>
|
12
|
+
>
|
13
13
|
> This README is for the latest version of colsole (0.8.x), which is compatible
|
14
14
|
> with older versions. Version 1.x will NOT be compatible.
|
15
|
-
>
|
15
|
+
>
|
16
16
|
> See [Uprading](#upgrading) below.
|
17
17
|
|
18
18
|
## Install
|
@@ -23,6 +23,21 @@ Add to your Gemfile:
|
|
23
23
|
$ gem 'colsole', '>= 0.8.1', '< 2.0'
|
24
24
|
```
|
25
25
|
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
require 'colsole'
|
30
|
+
include Colsole
|
31
|
+
say 'b`Blue` Man Group'
|
32
|
+
```
|
33
|
+
|
34
|
+
All the methods described below can also be called directly on the `Colsole` module. This is useful when you want to use it at the top level of your project, without namespace contamination:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
require 'colsole'
|
38
|
+
Colsole.say 'b`Blue` Man Group'
|
39
|
+
```
|
40
|
+
|
26
41
|
## Examples
|
27
42
|
|
28
43
|
See the [Examples file](https://github.com/DannyBen/colsole/blob/master/example.rb).
|
@@ -60,7 +75,6 @@ say "downloading data... "
|
|
60
75
|
say "download complete.", replace: true
|
61
76
|
```
|
62
77
|
|
63
|
-
|
64
78
|
### `word_wrap " string" [, length]`
|
65
79
|
|
66
80
|
Wrap long lines while keeping words intact, and keeping indentation based on the
|
@@ -111,7 +125,6 @@ fallback if it is unable to detect.
|
|
111
125
|
Returns only the terminal width or height. This is a shortcut to
|
112
126
|
`terminal_size[0]` / terminal_size[1].
|
113
127
|
|
114
|
-
|
115
128
|
## Colors
|
116
129
|
|
117
130
|
Strings that are surrounded by backticks, and preceded by a color code and
|
@@ -123,24 +136,24 @@ say "this is b`blue` and ru`this is red underlined`"
|
|
123
136
|
|
124
137
|
The one letter color code is required, followed by up to 3 style code.
|
125
138
|
|
126
|
-
| Color Code | Color
|
127
|
-
|
128
|
-
| `n` | no color
|
129
|
-
| `k` | black
|
130
|
-
| `r` | red
|
131
|
-
| `g` | green
|
132
|
-
| `y` | yellow
|
133
|
-
| `b` | blue
|
134
|
-
| `m` | magenta
|
135
|
-
| `c` | cyan
|
136
|
-
| `w` | white
|
137
|
-
|
138
|
-
| Style Code | Style
|
139
|
-
|
140
|
-
| `b` | bold
|
141
|
-
| `u` | underlined
|
142
|
-
| `i` | inverted
|
143
|
-
| `z` | terminate
|
139
|
+
| Color Code | Color |
|
140
|
+
| ---------- | -------- |
|
141
|
+
| `n` | no color |
|
142
|
+
| `k` | black |
|
143
|
+
| `r` | red |
|
144
|
+
| `g` | green |
|
145
|
+
| `y` | yellow |
|
146
|
+
| `b` | blue |
|
147
|
+
| `m` | magenta |
|
148
|
+
| `c` | cyan |
|
149
|
+
| `w` | white |
|
150
|
+
|
151
|
+
| Style Code | Style |
|
152
|
+
| ---------- | ---------- |
|
153
|
+
| `b` | bold |
|
154
|
+
| `u` | underlined |
|
155
|
+
| `i` | inverted |
|
156
|
+
| `z` | terminate |
|
144
157
|
|
145
158
|
## Upgrading
|
146
159
|
|
@@ -150,7 +163,6 @@ markers. For easy transition, it is compatible with older versions.
|
|
150
163
|
Follow these steps to upgrade:
|
151
164
|
|
152
165
|
```ruby
|
153
|
-
|
154
166
|
# => Require a more flexible version
|
155
167
|
# change this
|
156
168
|
gem 'colsole'
|
data/lib/colsole/compat.rb
CHANGED
data/lib/colsole/version.rb
CHANGED
data/lib/colsole.rb
CHANGED
@@ -22,6 +22,8 @@ module Colsole
|
|
22
22
|
'z' => "\e[0m", # terminate
|
23
23
|
}
|
24
24
|
|
25
|
+
module_function
|
26
|
+
|
25
27
|
# Output a string with optional color markers to stdout.
|
26
28
|
# If text is ended with a white space, you can call again with replace: true
|
27
29
|
# to replace that line
|
@@ -119,8 +121,6 @@ module Colsole
|
|
119
121
|
process_color_markers(compat_string) { |_color, _styles, text| text }
|
120
122
|
end
|
121
123
|
|
122
|
-
private
|
123
|
-
|
124
124
|
def process_color_markers(string)
|
125
125
|
string.gsub(/([rgybmcn])([ubi]{0,3})`([^`]*)`/) do
|
126
126
|
color = ANSI_COLORS[$1]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: colsole
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danny Ben Shitrit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Utility functions for making colorful console applications
|
14
14
|
email: db@dannyben.com
|
@@ -40,7 +40,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
requirements: []
|
43
|
-
rubygems_version: 3.4.
|
43
|
+
rubygems_version: 3.4.5
|
44
44
|
signing_key:
|
45
45
|
specification_version: 4
|
46
46
|
summary: Colorful Console Applications
|