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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +139 -136
  3. data/lib/colsole/version.rb +1 -1
  4. data/lib/colsole.rb +2 -1
  5. metadata +9 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6020823f438cc49eb3eb4fdf1d18aba0d4b44a71
4
- data.tar.gz: 743c2add7febab44cd646fdcbd967bb25e5b32ae
3
+ metadata.gz: f2c590c10a219d6246954a7b1c6708ecf64e3456
4
+ data.tar.gz: 26ce9466d5e79b292b138e98dc06fc5ab3cf824d
5
5
  SHA512:
6
- metadata.gz: 4ee4e4296a5905f1c1452806f1c7ba2a34f1dfbf961e898ac9a57377b16567861a64f90d357a42be2f99d6f31f638324cfeb9a6bb6d0f9c1d75c1cffa87da267
7
- data.tar.gz: 8a91b479300a1eb7f079f87b33466b8e56f387c3068af097502800d180fbd8e319a6dd1a18af42b1992c860ad9b52baa6fe5d50fe80126c268c349acb7ee64fa
6
+ metadata.gz: 626e8866f26c58eef52d61ae76c0c6ef05365eb2ef6411805f75073596d341149233fbd3bad099983c55898988d30f843efa93b9d72a262df41626ab29d95d77
7
+ data.tar.gz: 3ff7a06d4a61d4a128c65f8127adf5827b54a2cd379dd2183df8b89178673d0ecad277b803393a937d234fc32ce242882b4500f3251398387bd73155b86a36c3
data/README.md CHANGED
@@ -1,136 +1,139 @@
1
- Colsole
2
- ==================================================
3
-
4
- [![Gem](https://img.shields.io/gem/v/colsole.svg?style=flat-square)](https://rubygems.org/gems/colsole)
5
- [![Travis](https://img.shields.io/travis/DannyBen/colsole.svg?style=flat-square)](https://travis-ci.org/DannyBen/colsole)
6
- [![Code Climate](https://img.shields.io/codeclimate/github/DannyBen/colsole.svg?style=flat-square)](https://codeclimate.com/github/DannyBen/colsole)
7
- [![Gem](https://img.shields.io/gem/dt/colsole.svg?style=flat-square)](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
- ### `resay "anything"`
87
-
88
- Use resay after a space terminated "said" string to rewrite the line
89
-
90
- ```ruby
91
- say "downloading... "
92
- # long process here...
93
- resay "downloaded."
94
- ```
95
-
96
-
97
- ### `say! "anything to stderr"`
98
-
99
- Use say! to output to stderr with color markers:
100
-
101
- ```ruby
102
- say! "!txtred!Error!txtrst!: This just did not work"
103
- ```
104
-
105
- Utility / Support Functions
106
- --------------------------------------------------
107
-
108
- ### `colorize "!txtred!Hello"`
109
-
110
- Parses and returns a color-flagged string.
111
-
112
- Respects pipe and auto terminates colored strings.
113
-
114
- Call without text to see a list/demo of all available colors.
115
-
116
- ### `terminal?`
117
-
118
- Returns true if we are running in an interactive terminal
119
-
120
- ### `command_exist? "some_executable"`
121
-
122
- Checks if the provided string is a command in the path.
123
-
124
- ### `detect_terminal_size fallback_value`
125
-
126
- Returns an array [width, height] of the terminal, or the supplied
127
- `fallback_value` if it is unable to detect.
128
-
129
-
130
- Color Codes
131
- --------------------------------------------------
132
-
133
- [![Color Codes](https://raw.githubusercontent.com/DannyBen/colsole/master/color-codes.png)](https://raw.githubusercontent.com/DannyBen/colsole/master/color-codes.png)
134
-
135
-
136
- [1]: https://github.com/DannyBen/colsole/blob/master/example.rb
1
+ Colsole
2
+ ==================================================
3
+
4
+ [![Gem](https://img.shields.io/gem/v/colsole.svg?style=flat-square)](https://rubygems.org/gems/colsole)
5
+ [![Travis](https://img.shields.io/travis/DannyBen/colsole.svg?style=flat-square)](https://travis-ci.org/DannyBen/colsole)
6
+ [![Code Climate](https://img.shields.io/codeclimate/github/DannyBen/colsole.svg?style=flat-square)](https://codeclimate.com/github/DannyBen/colsole)
7
+ [![Gem](https://img.shields.io/gem/dt/colsole.svg?style=flat-square)](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
+ [![Color Codes](https://raw.githubusercontent.com/DannyBen/colsole/master/color-codes.png)](https://raw.githubusercontent.com/DannyBen/colsole/master/color-codes.png)
137
+
138
+
139
+ [1]: https://github.com/DannyBen/colsole/blob/master/example.rb
@@ -1,3 +1,3 @@
1
1
  module Colsole
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
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.1
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: 2016-04-22 00:00:00.000000000 Z
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.6'
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.6'
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.8'
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.8'
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.11'
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.11'
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.4.6
112
+ rubygems_version: 2.5.1
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: Colorful Console Applications