colsole 0.4.1 → 0.4.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 +139 -136
- data/lib/colsole/version.rb +1 -1
- data/lib/colsole.rb +2 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2c590c10a219d6246954a7b1c6708ecf64e3456
|
4
|
+
data.tar.gz: 26ce9466d5e79b292b138e98dc06fc5ab3cf824d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 626e8866f26c58eef52d61ae76c0c6ef05365eb2ef6411805f75073596d341149233fbd3bad099983c55898988d30f843efa93b9d72a262df41626ab29d95d77
|
7
|
+
data.tar.gz: 3ff7a06d4a61d4a128c65f8127adf5827b54a2cd379dd2183df8b89178673d0ecad277b803393a937d234fc32ce242882b4500f3251398387bd73155b86a36c3
|
data/README.md
CHANGED
@@ -1,136 +1,139 @@
|
|
1
|
-
Colsole
|
2
|
-
==================================================
|
3
|
-
|
4
|
-
[](https://rubygems.org/gems/colsole)
|
5
|
-
[](https://travis-ci.org/DannyBen/colsole)
|
6
|
-
[](https://codeclimate.com/github/DannyBen/colsole)
|
7
|
-
[](https://rubygems.org/gems/colsole)
|
8
|
-
|
9
|
-
---
|
10
|
-
|
11
|
-
Utility functions for colorful console applications.
|
12
|
-
|
13
|
-
---
|
14
|
-
|
15
|
-
|
16
|
-
Install
|
17
|
-
--------------------------------------------------
|
18
|
-
|
19
|
-
```
|
20
|
-
$ gem install colsole
|
21
|
-
```
|
22
|
-
|
23
|
-
Features
|
24
|
-
--------------------------------------------------
|
25
|
-
|
26
|
-
- Print colored messages
|
27
|
-
- Color parts of a message
|
28
|
-
- Print neatly aligned status messages
|
29
|
-
- Word wrap with indentation consideration
|
30
|
-
|
31
|
-
See the [Examples file][1] for more.
|
32
|
-
|
33
|
-
Primary Functions
|
34
|
-
--------------------------------------------------
|
35
|
-
|
36
|
-
### `say "anything"`
|
37
|
-
|
38
|
-
An alternative to puts.
|
39
|
-
|
40
|
-
```ruby
|
41
|
-
say "Hello"
|
42
|
-
```
|
43
|
-
|
44
|
-
Leave a trailing space to keep the cursor at the same line
|
45
|
-
|
46
|
-
```ruby
|
47
|
-
say "appears in "
|
48
|
-
say "one line"
|
49
|
-
```
|
50
|
-
|
51
|
-
Embed color markers in the string:
|
52
|
-
|
53
|
-
```ruby
|
54
|
-
say "!txtred!I am RED !txtgrn!I am GREEN"
|
55
|
-
```
|
56
|
-
|
57
|
-
### `say_status :status, "message" [, :color]`
|
58
|
-
|
59
|
-
Print a message with a colored status
|
60
|
-
|
61
|
-
```ruby
|
62
|
-
say_status :create, "perpetual energy"
|
63
|
-
```
|
64
|
-
|
65
|
-
You can provide a color in the regulat 6 letter code:
|
66
|
-
|
67
|
-
```ruby
|
68
|
-
say_status :error, "does not compute", :txtred
|
69
|
-
```
|
70
|
-
|
71
|
-
### `word_wrap " string"`
|
72
|
-
|
73
|
-
Wrap long lines while keeping words intact, and keeping
|
74
|
-
indentation based on the leading spaces in your string:
|
75
|
-
|
76
|
-
```ruby
|
77
|
-
say word_wrap(" one two three four five", 15)
|
78
|
-
|
79
|
-
# output:
|
80
|
-
# one two
|
81
|
-
# three four
|
82
|
-
# five
|
83
|
-
```
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
say!
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
`fallback_value`
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
[
|
1
|
+
Colsole
|
2
|
+
==================================================
|
3
|
+
|
4
|
+
[](https://rubygems.org/gems/colsole)
|
5
|
+
[](https://travis-ci.org/DannyBen/colsole)
|
6
|
+
[](https://codeclimate.com/github/DannyBen/colsole)
|
7
|
+
[](https://rubygems.org/gems/colsole)
|
8
|
+
|
9
|
+
---
|
10
|
+
|
11
|
+
Utility functions for colorful console applications.
|
12
|
+
|
13
|
+
---
|
14
|
+
|
15
|
+
|
16
|
+
Install
|
17
|
+
--------------------------------------------------
|
18
|
+
|
19
|
+
```
|
20
|
+
$ gem install colsole
|
21
|
+
```
|
22
|
+
|
23
|
+
Features
|
24
|
+
--------------------------------------------------
|
25
|
+
|
26
|
+
- Print colored messages
|
27
|
+
- Color parts of a message
|
28
|
+
- Print neatly aligned status messages
|
29
|
+
- Word wrap with indentation consideration
|
30
|
+
|
31
|
+
See the [Examples file][1] for more.
|
32
|
+
|
33
|
+
Primary Functions
|
34
|
+
--------------------------------------------------
|
35
|
+
|
36
|
+
### `say "anything"`
|
37
|
+
|
38
|
+
An alternative to puts.
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
say "Hello"
|
42
|
+
```
|
43
|
+
|
44
|
+
Leave a trailing space to keep the cursor at the same line
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
say "appears in "
|
48
|
+
say "one line"
|
49
|
+
```
|
50
|
+
|
51
|
+
Embed color markers in the string:
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
say "!txtred!I am RED !txtgrn!I am GREEN"
|
55
|
+
```
|
56
|
+
|
57
|
+
### `say_status :status, "message" [, :color]`
|
58
|
+
|
59
|
+
Print a message with a colored status
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
say_status :create, "perpetual energy"
|
63
|
+
```
|
64
|
+
|
65
|
+
You can provide a color in the regulat 6 letter code:
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
say_status :error, "does not compute", :txtred
|
69
|
+
```
|
70
|
+
|
71
|
+
### `word_wrap " string" [, length]`
|
72
|
+
|
73
|
+
Wrap long lines while keeping words intact, and keeping
|
74
|
+
indentation based on the leading spaces in your string:
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
say word_wrap(" one two three four five", 15)
|
78
|
+
|
79
|
+
# output:
|
80
|
+
# one two
|
81
|
+
# three four
|
82
|
+
# five
|
83
|
+
```
|
84
|
+
|
85
|
+
If `length` is not provided, `word_wrap` will attempt to determine it
|
86
|
+
automatically based on the width of the terminal.
|
87
|
+
|
88
|
+
|
89
|
+
### `resay "anything"`
|
90
|
+
|
91
|
+
Use resay after a space terminated "said" string to rewrite the line
|
92
|
+
|
93
|
+
```ruby
|
94
|
+
say "downloading... "
|
95
|
+
# long process here...
|
96
|
+
resay "downloaded."
|
97
|
+
```
|
98
|
+
|
99
|
+
|
100
|
+
### `say! "anything to stderr"`
|
101
|
+
|
102
|
+
Use say! to output to stderr with color markers:
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
say! "!txtred!Error!txtrst!: This just did not work"
|
106
|
+
```
|
107
|
+
|
108
|
+
Utility / Support Functions
|
109
|
+
--------------------------------------------------
|
110
|
+
|
111
|
+
### `colorize "!txtred!Hello"`
|
112
|
+
|
113
|
+
Parses and returns a color-flagged string.
|
114
|
+
|
115
|
+
Respects pipe and auto terminates colored strings.
|
116
|
+
|
117
|
+
Call without text to see a list/demo of all available colors.
|
118
|
+
|
119
|
+
### `terminal?`
|
120
|
+
|
121
|
+
Returns true if we are running in an interactive terminal
|
122
|
+
|
123
|
+
### `command_exist? "some_executable"`
|
124
|
+
|
125
|
+
Checks if the provided string is a command in the path.
|
126
|
+
|
127
|
+
### `detect_terminal_size fallback_value`
|
128
|
+
|
129
|
+
Returns an array `[width, height]` of the terminal, or the supplied
|
130
|
+
`fallback_value` if it is unable to detect.
|
131
|
+
|
132
|
+
|
133
|
+
Color Codes
|
134
|
+
--------------------------------------------------
|
135
|
+
|
136
|
+
[](https://raw.githubusercontent.com/DannyBen/colsole/master/color-codes.png)
|
137
|
+
|
138
|
+
|
139
|
+
[1]: https://github.com/DannyBen/colsole/blob/master/example.rb
|
data/lib/colsole/version.rb
CHANGED
data/lib/colsole.rb
CHANGED
@@ -77,7 +77,8 @@ module Colsole
|
|
77
77
|
elsif (RUBY_PLATFORM =~ /java/ || (!STDIN.tty? && ENV['TERM'])) && command_exist?('tput')
|
78
78
|
[`tput cols`.to_i, `tput lines`.to_i]
|
79
79
|
elsif STDIN.tty? && command_exist?('stty')
|
80
|
-
`stty size`.scan(/\d+/).map { |s| s.to_i }.reverse
|
80
|
+
result = `stty size`.scan(/\d+/).map { |s| s.to_i }.reverse
|
81
|
+
result == [0,0] ? default : result
|
81
82
|
else
|
82
83
|
default
|
83
84
|
end
|
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.4.
|
4
|
+
version: 0.4.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:
|
11
|
+
date: 2017-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: runfile
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.9'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.9'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: runfile-tasks
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '5.
|
47
|
+
version: '5.10'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '5.
|
54
|
+
version: '5.10'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: minitest-reporters
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0.
|
75
|
+
version: '0.14'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0.
|
82
|
+
version: '0.14'
|
83
83
|
description: Utility functions for making colorful console applications
|
84
84
|
email: db@dannyben.com
|
85
85
|
executables: []
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
111
|
rubyforge_project:
|
112
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.5.1
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: Colorful Console Applications
|