ansi 1.5.0 → 1.6.0
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 +5 -5
- data/HISTORY.md +17 -0
- data/README.md +16 -20
- data/demo/04_progressbar.md +2 -2
- data/demo/11_terminal.md +2 -2
- data/lib/ansi/version.rb +1 -13
- metadata +40 -106
- data/.index +0 -77
- data/.yardopts +0 -8
- data/DEMO.md +0 -451
- data/lib/ansi.yml +0 -77
- data/test/case_ansicode.rb +0 -43
- data/test/case_bbcode.rb +0 -35
- data/test/case_mixin.rb +0 -35
- data/test/case_progressbar.rb +0 -21
- data/test/test_helper.rb +0 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: f64bee2019769713b2ac4762b94be9f6c2346eb4ae4baa0b0645e7a2f2371286
|
|
4
|
+
data.tar.gz: 8fdba321ec78907d1109046af0656ee9c3a0c2342f5aaff7c3611ba3ea4d2976
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cb67809ddcbb4ddc3e527081a4c65ab4445c116d7eb17c0da6a31837d4cfc943c123724dd63e18ecf7812a43f5bfae6292899da2b8b2a1a6f77c70e1d336d0f8
|
|
7
|
+
data.tar.gz: da85dad4be00c385f5c019b61ea1ae358ef0208bb5c7c9d17713e64e710f72098fe7798b1e04e76c9e2030c440a7558202510a382ec3aa72a2d9f4c9d9911cb5
|
data/HISTORY.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# RELEASE HISTORY
|
|
2
2
|
|
|
3
|
+
## 1.6.0 | 2026-03-30
|
|
4
|
+
|
|
5
|
+
Maintenance release. Modernized project tooling and cleaned up documentation.
|
|
6
|
+
|
|
7
|
+
Changes:
|
|
8
|
+
|
|
9
|
+
* Replace custom Indexer system with standard gemspec.
|
|
10
|
+
* Replace Travis CI with GitHub Actions.
|
|
11
|
+
* Replace Assembly/detroit/ergo with Rakefile.
|
|
12
|
+
* Simplify version.rb to use a plain constant.
|
|
13
|
+
* Fix Fixnum reference for Ruby 3+ compatibility.
|
|
14
|
+
* Fix typos and update URLs to HTTPS.
|
|
15
|
+
* Move site from gh-pages to docs/.
|
|
16
|
+
* Remove obsolete files.
|
|
17
|
+
* Clean up .gitignore.
|
|
18
|
+
|
|
19
|
+
|
|
3
20
|
## 1.5.0 | 2015-01-16
|
|
4
21
|
|
|
5
22
|
ANSI 1.5 introduces one change that is not backward compatiable. The
|
data/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# ANSI
|
|
2
2
|
|
|
3
|
-
[HOME](
|
|
4
|
-
[API](
|
|
5
|
-
[
|
|
6
|
-
[
|
|
7
|
-
[SOURCE](http://github.com/rubyworks/ansi)
|
|
3
|
+
[HOME](https://rubyworks.github.io/ansi) ·
|
|
4
|
+
[API](https://rubydoc.info/gems/ansi) ·
|
|
5
|
+
[ISSUES](https://github.com/rubyworks/ansi/issues) ·
|
|
6
|
+
[SOURCE](https://github.com/rubyworks/ansi)
|
|
8
7
|
|
|
9
|
-
[](https://rubygems.org/gems/ansi)
|
|
9
|
+
[](https://github.com/rubyworks/ansi/actions/workflows/test.yml)
|
|
10
10
|
|
|
11
11
|
<br/>
|
|
12
12
|
|
|
@@ -34,8 +34,8 @@ device.
|
|
|
34
34
|
|
|
35
35
|
There are a number of modules and classes provided by the ANSI
|
|
36
36
|
package. To get a good understanding of them it is best to pursue
|
|
37
|
-
the [QED documents](
|
|
38
|
-
or the [API documentation](
|
|
37
|
+
the [QED documents](https://github.com/rubyworks/ansi/tree/master/demo/)
|
|
38
|
+
or the [API documentation](https://rubydoc.info/gems/ansi).
|
|
39
39
|
|
|
40
40
|
At the heart of all the provided libraries lies the ANSI::Code module
|
|
41
41
|
which defines ANSI codes as constants and methods. For example:
|
|
@@ -56,23 +56,19 @@ the system.
|
|
|
56
56
|
|
|
57
57
|
## Installation
|
|
58
58
|
|
|
59
|
-
###
|
|
60
|
-
|
|
61
|
-
To install with RubyGems simply open a console and type:
|
|
59
|
+
### Bundler
|
|
62
60
|
|
|
63
|
-
|
|
61
|
+
Add the usual `gem` line to your project's `Gemfile`.
|
|
64
62
|
|
|
65
|
-
|
|
63
|
+
gem 'ansi'
|
|
66
64
|
|
|
67
|
-
|
|
68
|
-
then [download](http://github.com/rubyworks/ansi/download) the tarball package and type:
|
|
65
|
+
And run then `bundle` command.
|
|
69
66
|
|
|
70
|
-
|
|
71
|
-
$ cd ansi-1.0.0
|
|
72
|
-
$ sudo setup.rb all
|
|
67
|
+
### RubyGems
|
|
73
68
|
|
|
74
|
-
|
|
69
|
+
To install with RubyGems simply open a console and type:
|
|
75
70
|
|
|
71
|
+
$ sudo gem install ansi
|
|
76
72
|
|
|
77
73
|
## Release Notes
|
|
78
74
|
|
|
@@ -83,7 +79,7 @@ Please see HISTORY.md file.
|
|
|
83
79
|
|
|
84
80
|
Copyright (c) 2009 Rubyworks
|
|
85
81
|
|
|
86
|
-
This program is redistributable under the terms of the *
|
|
82
|
+
This program is redistributable under the terms of the *BSD-2-Clause* license.
|
|
87
83
|
|
|
88
84
|
Some pieces of the code are copyrighted by others.
|
|
89
85
|
|
data/demo/04_progressbar.md
CHANGED
|
@@ -52,8 +52,8 @@ Calling this methods is the same as calling:
|
|
|
52
52
|
pbar.format("%-14s %3d%% %s %s",:title, :percentage, :bar, :stat_for_file_transfer)
|
|
53
53
|
run(pbar)
|
|
54
54
|
|
|
55
|
-
The `#style` setter allows each part of the line be modified with ANSI codes.
|
|
56
|
-
`#bar_mark` writer can be used to change the character used to make the bar.
|
|
55
|
+
The `#style` setter allows each part of the line be modified with ANSI codes.
|
|
56
|
+
And the `#bar_mark` writer can be used to change the character used to make the bar.
|
|
57
57
|
|
|
58
58
|
pbar.standard_mode
|
|
59
59
|
pbar.style(:title => [:red], :bar=>[:blue])
|
data/demo/11_terminal.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# ANSI::Terminal
|
|
2
2
|
|
|
3
|
-
We should be
|
|
3
|
+
We should be able to get the terminal width via the `terminal_width` method.
|
|
4
4
|
|
|
5
5
|
width = ANSI::Terminal.terminal_width
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Integer.assert === width
|
|
8
8
|
|
data/lib/ansi/version.rb
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
1
|
module ANSI
|
|
2
|
-
|
|
3
|
-
def self.metadata
|
|
4
|
-
@spec ||= (
|
|
5
|
-
require 'yaml'
|
|
6
|
-
YAML.load(File.new(File.dirname(__FILE__) + '/../ansi.yml'))
|
|
7
|
-
)
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
# Check metadata for missing constants.
|
|
11
|
-
def self.const_missing(name)
|
|
12
|
-
metadata[name.to_s.downcase] || super(name)
|
|
13
|
-
end
|
|
2
|
+
VERSION = '1.6.0'
|
|
14
3
|
end
|
|
15
|
-
|
metadata
CHANGED
|
@@ -1,116 +1,84 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ansi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Thomas Sawyer
|
|
8
8
|
- Florian Frank
|
|
9
|
-
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
|
-
name:
|
|
14
|
+
name: rake
|
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
|
17
16
|
requirements:
|
|
18
|
-
- -
|
|
17
|
+
- - ">="
|
|
19
18
|
- !ruby/object:Gem::Version
|
|
20
|
-
version: '
|
|
19
|
+
version: '13'
|
|
21
20
|
type: :development
|
|
22
21
|
prerelease: false
|
|
23
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
24
23
|
requirements:
|
|
25
|
-
- -
|
|
24
|
+
- - ">="
|
|
26
25
|
- !ruby/object:Gem::Version
|
|
27
|
-
version: '
|
|
28
|
-
- !ruby/object:Gem::Dependency
|
|
29
|
-
name: indexer
|
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
|
31
|
-
requirements:
|
|
32
|
-
- - '>='
|
|
33
|
-
- !ruby/object:Gem::Version
|
|
34
|
-
version: '0'
|
|
35
|
-
type: :development
|
|
36
|
-
prerelease: false
|
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
38
|
-
requirements:
|
|
39
|
-
- - '>='
|
|
40
|
-
- !ruby/object:Gem::Version
|
|
41
|
-
version: '0'
|
|
42
|
-
- !ruby/object:Gem::Dependency
|
|
43
|
-
name: ergo
|
|
44
|
-
requirement: !ruby/object:Gem::Requirement
|
|
45
|
-
requirements:
|
|
46
|
-
- - '>='
|
|
47
|
-
- !ruby/object:Gem::Version
|
|
48
|
-
version: '0'
|
|
49
|
-
type: :development
|
|
50
|
-
prerelease: false
|
|
51
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
52
|
-
requirements:
|
|
53
|
-
- - '>='
|
|
54
|
-
- !ruby/object:Gem::Version
|
|
55
|
-
version: '0'
|
|
26
|
+
version: '13'
|
|
56
27
|
- !ruby/object:Gem::Dependency
|
|
57
28
|
name: qed
|
|
58
29
|
requirement: !ruby/object:Gem::Requirement
|
|
59
30
|
requirements:
|
|
60
|
-
- -
|
|
31
|
+
- - ">="
|
|
61
32
|
- !ruby/object:Gem::Version
|
|
62
|
-
version: '
|
|
33
|
+
version: '2.9'
|
|
63
34
|
type: :development
|
|
64
35
|
prerelease: false
|
|
65
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
66
37
|
requirements:
|
|
67
|
-
- -
|
|
38
|
+
- - ">="
|
|
68
39
|
- !ruby/object:Gem::Version
|
|
69
|
-
version: '
|
|
40
|
+
version: '2.9'
|
|
70
41
|
- !ruby/object:Gem::Dependency
|
|
71
42
|
name: ae
|
|
72
43
|
requirement: !ruby/object:Gem::Requirement
|
|
73
44
|
requirements:
|
|
74
|
-
- -
|
|
75
|
-
- !ruby/object:Gem::Version
|
|
76
|
-
version: '0'
|
|
77
|
-
type: :development
|
|
78
|
-
prerelease: false
|
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
80
|
-
requirements:
|
|
81
|
-
- - '>='
|
|
82
|
-
- !ruby/object:Gem::Version
|
|
83
|
-
version: '0'
|
|
84
|
-
- !ruby/object:Gem::Dependency
|
|
85
|
-
name: lemon
|
|
86
|
-
requirement: !ruby/object:Gem::Requirement
|
|
87
|
-
requirements:
|
|
88
|
-
- - '>='
|
|
45
|
+
- - ">="
|
|
89
46
|
- !ruby/object:Gem::Version
|
|
90
|
-
version: '
|
|
47
|
+
version: '1.8'
|
|
91
48
|
type: :development
|
|
92
49
|
prerelease: false
|
|
93
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
94
51
|
requirements:
|
|
95
|
-
- -
|
|
52
|
+
- - ">="
|
|
96
53
|
- !ruby/object:Gem::Version
|
|
97
|
-
version: '
|
|
54
|
+
version: '1.8'
|
|
98
55
|
description: The ANSI project is a superlative collection of ANSI escape code related
|
|
99
|
-
libraries
|
|
56
|
+
libraries enabling ANSI colorization and stylization of console output. Byte for
|
|
100
57
|
byte ANSI is the best ANSI code library available for the Ruby programming language.
|
|
101
58
|
email:
|
|
102
59
|
- transfire@gmail.com
|
|
103
60
|
executables: []
|
|
104
61
|
extensions: []
|
|
105
|
-
extra_rdoc_files:
|
|
62
|
+
extra_rdoc_files: []
|
|
63
|
+
files:
|
|
64
|
+
- HISTORY.md
|
|
106
65
|
- LICENSE.txt
|
|
107
66
|
- NOTICE.md
|
|
108
67
|
- README.md
|
|
109
|
-
-
|
|
110
|
-
-
|
|
111
|
-
|
|
112
|
-
- .
|
|
113
|
-
- .
|
|
68
|
+
- demo/01_ansicode.md
|
|
69
|
+
- demo/02_core.md
|
|
70
|
+
- demo/03_logger.md
|
|
71
|
+
- demo/04_progressbar.md
|
|
72
|
+
- demo/05_mixin.md
|
|
73
|
+
- demo/06_string.md
|
|
74
|
+
- demo/07_columns.md
|
|
75
|
+
- demo/08_table.md
|
|
76
|
+
- demo/09_diff.md
|
|
77
|
+
- demo/10_bbcode.md
|
|
78
|
+
- demo/11_terminal.md
|
|
79
|
+
- demo/applique/ae.rb
|
|
80
|
+
- demo/applique/output.rb
|
|
81
|
+
- lib/ansi.rb
|
|
114
82
|
- lib/ansi/bbcode.rb
|
|
115
83
|
- lib/ansi/chain.rb
|
|
116
84
|
- lib/ansi/chart.rb
|
|
@@ -125,65 +93,31 @@ files:
|
|
|
125
93
|
- lib/ansi/progressbar.rb
|
|
126
94
|
- lib/ansi/string.rb
|
|
127
95
|
- lib/ansi/table.rb
|
|
96
|
+
- lib/ansi/terminal.rb
|
|
128
97
|
- lib/ansi/terminal/curses.rb
|
|
129
98
|
- lib/ansi/terminal/stty.rb
|
|
130
99
|
- lib/ansi/terminal/termios.rb
|
|
131
100
|
- lib/ansi/terminal/win32.rb
|
|
132
|
-
- lib/ansi/terminal.rb
|
|
133
101
|
- lib/ansi/version.rb
|
|
134
|
-
|
|
135
|
-
- lib/ansi.yml
|
|
136
|
-
- demo/01_ansicode.md
|
|
137
|
-
- demo/02_core.md
|
|
138
|
-
- demo/03_logger.md
|
|
139
|
-
- demo/04_progressbar.md
|
|
140
|
-
- demo/05_mixin.md
|
|
141
|
-
- demo/06_string.md
|
|
142
|
-
- demo/07_columns.md
|
|
143
|
-
- demo/08_table.md
|
|
144
|
-
- demo/09_diff.md
|
|
145
|
-
- demo/10_bbcode.md
|
|
146
|
-
- demo/11_terminal.md
|
|
147
|
-
- demo/applique/ae.rb
|
|
148
|
-
- demo/applique/output.rb
|
|
149
|
-
- test/case_ansicode.rb
|
|
150
|
-
- test/case_bbcode.rb
|
|
151
|
-
- test/case_mixin.rb
|
|
152
|
-
- test/case_progressbar.rb
|
|
153
|
-
- test/test_helper.rb
|
|
154
|
-
- NOTICE.md
|
|
155
|
-
- README.md
|
|
156
|
-
- HISTORY.md
|
|
157
|
-
- DEMO.md
|
|
158
|
-
- LICENSE.txt
|
|
159
|
-
homepage: http://rubyworks.github.com/ansi
|
|
102
|
+
homepage: https://github.com/rubyworks/ansi
|
|
160
103
|
licenses:
|
|
161
104
|
- BSD-2-Clause
|
|
162
105
|
metadata: {}
|
|
163
|
-
post_install_message:
|
|
164
106
|
rdoc_options: []
|
|
165
107
|
require_paths:
|
|
166
108
|
- lib
|
|
167
109
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
168
110
|
requirements:
|
|
169
|
-
- -
|
|
111
|
+
- - ">="
|
|
170
112
|
- !ruby/object:Gem::Version
|
|
171
|
-
version: '
|
|
113
|
+
version: '3.1'
|
|
172
114
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
115
|
requirements:
|
|
174
|
-
- -
|
|
116
|
+
- - ">="
|
|
175
117
|
- !ruby/object:Gem::Version
|
|
176
118
|
version: '0'
|
|
177
119
|
requirements: []
|
|
178
|
-
|
|
179
|
-
rubygems_version: 2.0.3
|
|
180
|
-
signing_key:
|
|
120
|
+
rubygems_version: 3.6.9
|
|
181
121
|
specification_version: 4
|
|
182
122
|
summary: ANSI at your fingertips!
|
|
183
|
-
test_files:
|
|
184
|
-
- test/case_bbcode.rb
|
|
185
|
-
- test/case_progressbar.rb
|
|
186
|
-
- test/case_ansicode.rb
|
|
187
|
-
- test/case_mixin.rb
|
|
188
|
-
- test/test_helper.rb
|
|
189
|
-
has_rdoc:
|
|
123
|
+
test_files: []
|
data/.index
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
revision: 2013
|
|
3
|
-
type: ruby
|
|
4
|
-
sources:
|
|
5
|
-
- INDEX.yml
|
|
6
|
-
authors:
|
|
7
|
-
- name: Thomas Sawyer
|
|
8
|
-
email: transfire@gmail.com
|
|
9
|
-
- name: Florian Frank
|
|
10
|
-
organizations: []
|
|
11
|
-
requirements:
|
|
12
|
-
- groups:
|
|
13
|
-
- build
|
|
14
|
-
development: true
|
|
15
|
-
name: mast
|
|
16
|
-
- groups:
|
|
17
|
-
- build
|
|
18
|
-
development: true
|
|
19
|
-
name: indexer
|
|
20
|
-
- groups:
|
|
21
|
-
- build
|
|
22
|
-
development: true
|
|
23
|
-
name: ergo
|
|
24
|
-
- groups:
|
|
25
|
-
- test
|
|
26
|
-
development: true
|
|
27
|
-
name: qed
|
|
28
|
-
- groups:
|
|
29
|
-
- test
|
|
30
|
-
development: true
|
|
31
|
-
name: ae
|
|
32
|
-
- groups:
|
|
33
|
-
- test
|
|
34
|
-
development: true
|
|
35
|
-
name: lemon
|
|
36
|
-
conflicts: []
|
|
37
|
-
alternatives: []
|
|
38
|
-
resources:
|
|
39
|
-
- type: home
|
|
40
|
-
uri: http://rubyworks.github.com/ansi
|
|
41
|
-
label: Homepage
|
|
42
|
-
- type: docs
|
|
43
|
-
uri: http://rubydoc.info/gems/ansi/frames
|
|
44
|
-
label: Documentation
|
|
45
|
-
- type: code
|
|
46
|
-
uri: http://github.com/rubyworks/ansi
|
|
47
|
-
label: Source Code
|
|
48
|
-
- type: bugs
|
|
49
|
-
uri: http://github.com/rubyworks/ansi/issues
|
|
50
|
-
label: Issue Tracker
|
|
51
|
-
- type: mail
|
|
52
|
-
uri: http://groups.google.com/group/rubyworks-mailinglist
|
|
53
|
-
label: Mailing List
|
|
54
|
-
repositories:
|
|
55
|
-
- name: upstream
|
|
56
|
-
scm: git
|
|
57
|
-
uri: git://github.com/rubyworks/ansi.git
|
|
58
|
-
categories: []
|
|
59
|
-
copyrights:
|
|
60
|
-
- holder: Rubyworks
|
|
61
|
-
year: '2009'
|
|
62
|
-
license: BSD-2-Clause
|
|
63
|
-
customs: []
|
|
64
|
-
paths:
|
|
65
|
-
lib:
|
|
66
|
-
- lib
|
|
67
|
-
name: ansi
|
|
68
|
-
title: ANSI
|
|
69
|
-
version: 1.5.0
|
|
70
|
-
summary: ANSI at your fingertips!
|
|
71
|
-
description: The ANSI project is a superlative collection of ANSI escape code related
|
|
72
|
-
libraries eabling ANSI colorization and stylization of console output. Byte for
|
|
73
|
-
byte ANSI is the best ANSI code library available for the Ruby programming language.
|
|
74
|
-
orgranizations:
|
|
75
|
-
- Rubyworks
|
|
76
|
-
created: '2009-08-01'
|
|
77
|
-
date: '2015-01-16'
|
data/.yardopts
DELETED
data/DEMO.md
DELETED
|
@@ -1,451 +0,0 @@
|
|
|
1
|
-
# ANSI::Code
|
|
2
|
-
|
|
3
|
-
Require the library.
|
|
4
|
-
|
|
5
|
-
require 'ansi/code'
|
|
6
|
-
|
|
7
|
-
ANSI::Code can be used as a functions module.
|
|
8
|
-
|
|
9
|
-
str = ANSI::Code.red + "Hello" + ANSI::Code.blue + "World"
|
|
10
|
-
str.assert == "\e[31mHello\e[34mWorld"
|
|
11
|
-
|
|
12
|
-
If a block is supplied to each method then yielded value will
|
|
13
|
-
be wrapped in the ANSI code and clear code.
|
|
14
|
-
|
|
15
|
-
str = ANSI::Code.red{ "Hello" } + ANSI::Code.blue{ "World" }
|
|
16
|
-
str.assert == "\e[31mHello\e[0m\e[34mWorld\e[0m"
|
|
17
|
-
|
|
18
|
-
More conveniently the ANSI::Code module extends ANSI itself.
|
|
19
|
-
|
|
20
|
-
str = ANSI.red + "Hello" + ANSI.blue + "World"
|
|
21
|
-
str.assert == "\e[31mHello\e[34mWorld"
|
|
22
|
-
|
|
23
|
-
str = ANSI.red{ "Hello" } + ANSI.blue{ "World" }
|
|
24
|
-
str.assert == "\e[31mHello\e[0m\e[34mWorld\e[0m"
|
|
25
|
-
|
|
26
|
-
In the appropriate context the ANSI::Code module can also be
|
|
27
|
-
included, making its methods directly accessible.
|
|
28
|
-
|
|
29
|
-
include ANSI::Code
|
|
30
|
-
|
|
31
|
-
str = red + "Hello" + blue + "World"
|
|
32
|
-
str.assert == "\e[31mHello\e[34mWorld"
|
|
33
|
-
|
|
34
|
-
str = red{ "Hello" } + blue{ "World" }
|
|
35
|
-
str.assert == "\e[31mHello\e[0m\e[34mWorld\e[0m"
|
|
36
|
-
|
|
37
|
-
Along with the single font colors, the library include background colors.
|
|
38
|
-
|
|
39
|
-
str = on_red + "Hello"
|
|
40
|
-
str.assert == "\e[41mHello"
|
|
41
|
-
|
|
42
|
-
As well as combined color methods.
|
|
43
|
-
|
|
44
|
-
str = white_on_red + "Hello"
|
|
45
|
-
str.assert == "\e[37m\e[41mHello"
|
|
46
|
-
|
|
47
|
-
The ANSI::Code module supports most standard ANSI codes, though
|
|
48
|
-
not all platforms support every code, so YMMV.
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
# String Extensions
|
|
52
|
-
|
|
53
|
-
In addition the library offers an extension to String class
|
|
54
|
-
called #ansi, which allows some of the ANSI::Code methods
|
|
55
|
-
to be called in a more object-oriented fashion.
|
|
56
|
-
|
|
57
|
-
require 'ansi/core'
|
|
58
|
-
|
|
59
|
-
str = "Hello".ansi(:red) + "World".ansi(:blue)
|
|
60
|
-
str.assert == "\e[31mHello\e[0m\e[34mWorld\e[0m"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
# ANSI::Logger
|
|
64
|
-
|
|
65
|
-
Require the ANSI::Logger library.
|
|
66
|
-
|
|
67
|
-
require 'ansi/logger'
|
|
68
|
-
|
|
69
|
-
Create a new ANSI::Logger
|
|
70
|
-
|
|
71
|
-
log = ANSI::Logger.new(STDOUT)
|
|
72
|
-
|
|
73
|
-
Info logging appears normal.
|
|
74
|
-
|
|
75
|
-
log.info{"Info logs are green.\n"}
|
|
76
|
-
|
|
77
|
-
Warn logging appears yellow.
|
|
78
|
-
|
|
79
|
-
log.warn{"Warn logs are yellow.\n"}
|
|
80
|
-
|
|
81
|
-
Debug logging appears cyan.
|
|
82
|
-
|
|
83
|
-
log.debug{"Debug logs are cyan.\n"}
|
|
84
|
-
|
|
85
|
-
Error logging appears red.
|
|
86
|
-
|
|
87
|
-
log.error{"Error logs are red.\n"}
|
|
88
|
-
|
|
89
|
-
Fatal logging appears bright red.
|
|
90
|
-
|
|
91
|
-
log.fatal{"Fatal logs are bold red!\n"}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
# ANSI::Progressbar
|
|
95
|
-
|
|
96
|
-
Pretty progress bars are easy to construct.
|
|
97
|
-
|
|
98
|
-
require 'ansi/progressbar'
|
|
99
|
-
|
|
100
|
-
pbar = ANSI::Progressbar.new("Test Bar", 100)
|
|
101
|
-
|
|
102
|
-
Running the bar simply requires calling the #inc method during
|
|
103
|
-
a loop and calling #finish when done.
|
|
104
|
-
|
|
105
|
-
100.times do |i|
|
|
106
|
-
sleep 0.01
|
|
107
|
-
pbar.inc
|
|
108
|
-
end
|
|
109
|
-
pbar.finish
|
|
110
|
-
|
|
111
|
-
We will use this same rountine in all the examples below, so lets
|
|
112
|
-
make a quick macro for it. Notice we have to use #reset first
|
|
113
|
-
before reusing the same progress bar.
|
|
114
|
-
|
|
115
|
-
def run(pbar)
|
|
116
|
-
pbar.reset
|
|
117
|
-
100.times do |i|
|
|
118
|
-
sleep 0.01
|
|
119
|
-
pbar.inc
|
|
120
|
-
end
|
|
121
|
-
pbar.finish
|
|
122
|
-
puts
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
The progress bar can be stylized in almost any way.
|
|
126
|
-
The #format setter provides control over the parts
|
|
127
|
-
that appear on the line. For example, by default the
|
|
128
|
-
format is:
|
|
129
|
-
|
|
130
|
-
pbar.format("%-14s %3d%% %s %s", :title, :percentage, :bar, :stat)
|
|
131
|
-
|
|
132
|
-
So lets vary it up to demonstrate the case.
|
|
133
|
-
|
|
134
|
-
pbar.format("%-14s %3d%% %s %s", :title, :percentage, :stat, :bar)
|
|
135
|
-
run(pbar)
|
|
136
|
-
|
|
137
|
-
The progress bar has an extra build in format intended for use with
|
|
138
|
-
file downloads called #transer_mode.
|
|
139
|
-
|
|
140
|
-
pbar.transfer_mode
|
|
141
|
-
run(pbar)
|
|
142
|
-
|
|
143
|
-
Calling this methods is the same as calling:
|
|
144
|
-
|
|
145
|
-
pbar.format("%-14s %3d%% %s %s",:title, :percentage, :bar, :stat_for_file_transfer)
|
|
146
|
-
run(pbar)
|
|
147
|
-
|
|
148
|
-
The #style setter allows each part of the line be modified with ANSI codes. And the
|
|
149
|
-
#bar_mark writer can be used to change the character used to make the bar.
|
|
150
|
-
|
|
151
|
-
pbar.standard_mode
|
|
152
|
-
pbar.style(:title => [:red], :bar=>[:blue])
|
|
153
|
-
pbar.bar_mark = "="
|
|
154
|
-
run(pbar)
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
# ANSI::Mixin
|
|
158
|
-
|
|
159
|
-
The ANSI::Mixin module is design for including into
|
|
160
|
-
String-like classes. It will support any class that defines
|
|
161
|
-
a #to_s method.
|
|
162
|
-
|
|
163
|
-
require 'ansi/mixin'
|
|
164
|
-
|
|
165
|
-
In this demonstration we will simply include it in the
|
|
166
|
-
core String class.
|
|
167
|
-
|
|
168
|
-
class ::String
|
|
169
|
-
include ANSI::Mixin
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
Now all strings will have access to ANSI's style and color
|
|
173
|
-
codes via simple method calls.
|
|
174
|
-
|
|
175
|
-
"roses".red.assert == "\e[31mroses\e[0m"
|
|
176
|
-
|
|
177
|
-
"violets".blue.assert == "\e[34mviolets\e[0m"
|
|
178
|
-
|
|
179
|
-
"sugar".italic.assert == "\e[3msugar\e[0m"
|
|
180
|
-
|
|
181
|
-
The method can be combined, of course.
|
|
182
|
-
|
|
183
|
-
"you".italic.bold.assert == "\e[1m\e[3myou\e[0m\e[0m"
|
|
184
|
-
|
|
185
|
-
The mixin also supports background methods.
|
|
186
|
-
|
|
187
|
-
"envy".on_green.assert == "\e[42menvy\e[0m"
|
|
188
|
-
|
|
189
|
-
And it also supports the combined foreground-on-background
|
|
190
|
-
methods.
|
|
191
|
-
|
|
192
|
-
"b&w".white_on_black.assert == "\e[37m\e[40mb&w\e[0m"
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
# ANSI::String
|
|
196
|
-
|
|
197
|
-
The ANSI::String class is a very sophisticated implementation
|
|
198
|
-
of Ruby's standard String class, but one that can handle
|
|
199
|
-
ANSI codes seamlessly.
|
|
200
|
-
|
|
201
|
-
require 'ansi/string'
|
|
202
|
-
|
|
203
|
-
flower1 = ANSI::String.new("Roses")
|
|
204
|
-
flower2 = ANSI::String.new("Violets")
|
|
205
|
-
|
|
206
|
-
Like any other string.
|
|
207
|
-
|
|
208
|
-
flower1.to_s.assert == "Roses"
|
|
209
|
-
flower2.to_s.assert == "Violets"
|
|
210
|
-
|
|
211
|
-
Bet now we can add color.
|
|
212
|
-
|
|
213
|
-
flower1.red!
|
|
214
|
-
flower2.blue!
|
|
215
|
-
|
|
216
|
-
flower1.to_s.assert == "\e[31mRoses\e[0m"
|
|
217
|
-
flower2.to_s.assert == "\e[34mViolets\e[0m"
|
|
218
|
-
|
|
219
|
-
Despite that the string representation now contains ANSI codes,
|
|
220
|
-
we can still manipulate the string in much the same way that
|
|
221
|
-
we manipulate an ordinary string.
|
|
222
|
-
|
|
223
|
-
flower1.size.assert == 5
|
|
224
|
-
flower2.size.assert == 7
|
|
225
|
-
|
|
226
|
-
Like ordinary strings we can concatenate the two strings
|
|
227
|
-
|
|
228
|
-
flowers = flower1 + ' ' + flower2
|
|
229
|
-
flowers.to_s.assert == "\e[31mRoses\e[0m \e[34mViolets\e[0m"
|
|
230
|
-
|
|
231
|
-
flowers.size.assert == 13
|
|
232
|
-
|
|
233
|
-
Standard case conversion such as #upcase and #downcase work.
|
|
234
|
-
|
|
235
|
-
flower1.upcase.to_s.assert == "\e[31mROSES\e[0m"
|
|
236
|
-
flower1.downcase.to_s.assert == "\e[31mroses\e[0m"
|
|
237
|
-
|
|
238
|
-
Some of the most difficult methods to re-implement were the
|
|
239
|
-
substitution methods such as #sub and #gsub. They are still
|
|
240
|
-
somewhat more limited than the original string methods, but
|
|
241
|
-
their primary functionality should work.
|
|
242
|
-
|
|
243
|
-
flower1.gsub('s', 'z').to_s.assert == "\e[31mRozez\e[0m"
|
|
244
|
-
|
|
245
|
-
There are still a number of methods that need implementation.
|
|
246
|
-
ANSI::String is currently a very partial implementation. But
|
|
247
|
-
as you can see from the methods it does currently support,
|
|
248
|
-
is it already useful.
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
# ANSI::Columns
|
|
252
|
-
|
|
253
|
-
The +Columns+ class makes it easy to create nice looking text columns,
|
|
254
|
-
sorted from top to bottom, right to left (as opposed to the other way
|
|
255
|
-
around).
|
|
256
|
-
|
|
257
|
-
require 'ansi/columns'
|
|
258
|
-
|
|
259
|
-
list = %w{a b c d e f g h i j k l}
|
|
260
|
-
|
|
261
|
-
columns = ANSI::Columns.new(list)
|
|
262
|
-
|
|
263
|
-
columns.to_s(4)
|
|
264
|
-
|
|
265
|
-
The output will be:
|
|
266
|
-
|
|
267
|
-
a d g j
|
|
268
|
-
b e h k
|
|
269
|
-
c f i l
|
|
270
|
-
|
|
271
|
-
Besides an array of elements, Columns.new can take a string in which
|
|
272
|
-
the elements are divided by newlines characters. The default column
|
|
273
|
-
size can also be given to the initializer.
|
|
274
|
-
|
|
275
|
-
list = "a\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl"
|
|
276
|
-
|
|
277
|
-
columns = ANSI::Columns.new(list, :columns=>6)
|
|
278
|
-
|
|
279
|
-
columns.to_s
|
|
280
|
-
|
|
281
|
-
The output will be:
|
|
282
|
-
|
|
283
|
-
a c e g i k
|
|
284
|
-
b d f h j l
|
|
285
|
-
|
|
286
|
-
If the column count is +nil+, then the number of columns will be calculated
|
|
287
|
-
as a best fit for the current terminal window.
|
|
288
|
-
|
|
289
|
-
## Padding
|
|
290
|
-
|
|
291
|
-
Columns can adjust the padding between cells.
|
|
292
|
-
|
|
293
|
-
list = %w{a b c d e f g h i j k l}
|
|
294
|
-
|
|
295
|
-
columns = ANSI::Columns.new(list, :padding=>2)
|
|
296
|
-
|
|
297
|
-
columns.to_s(4)
|
|
298
|
-
|
|
299
|
-
The output will be:
|
|
300
|
-
|
|
301
|
-
a d g j
|
|
302
|
-
b e h k
|
|
303
|
-
c f i l
|
|
304
|
-
|
|
305
|
-
## Alignment
|
|
306
|
-
|
|
307
|
-
Columns can also be aligned either left or right.
|
|
308
|
-
|
|
309
|
-
list = %w{xx xx xx yy y yy z zz z}
|
|
310
|
-
|
|
311
|
-
columns = ANSI::Columns.new(list, :align=>:right)
|
|
312
|
-
|
|
313
|
-
columns.to_s(3)
|
|
314
|
-
|
|
315
|
-
The output will be:
|
|
316
|
-
|
|
317
|
-
xx yy z
|
|
318
|
-
xx y zz
|
|
319
|
-
xx yy z
|
|
320
|
-
|
|
321
|
-
## Format
|
|
322
|
-
|
|
323
|
-
Lastly, columns can be augmented with ANSI codes. This is done through
|
|
324
|
-
a formatting block. The block can take up to three parameters, the cell
|
|
325
|
-
content, the column and row numbers, or the cell and the column and row
|
|
326
|
-
numbers.
|
|
327
|
-
|
|
328
|
-
list = %w{a b c d e f g h i j k l}
|
|
329
|
-
|
|
330
|
-
columns = ANSI::Columns.new(list){ |c,r| r % 2 == 0 ? :red : :blue }
|
|
331
|
-
|
|
332
|
-
out = columns.to_s(4)
|
|
333
|
-
|
|
334
|
-
out.assert == (
|
|
335
|
-
"\e[31ma \e[0m\e[31md \e[0m\e[31mg \e[0m\e[31mj \e[0m\n" +
|
|
336
|
-
"\e[34mb \e[0m\e[34me \e[0m\e[34mh \e[0m\e[34mk \e[0m\n" +
|
|
337
|
-
"\e[31mc \e[0m\e[31mf \e[0m\e[31mi \e[0m\e[31ml \e[0m\n"
|
|
338
|
-
)
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
# ANSI::Table
|
|
342
|
-
|
|
343
|
-
The ANSI::Table class can be used to output tabular data with nicely
|
|
344
|
-
formated ASCII cell borders.
|
|
345
|
-
|
|
346
|
-
require 'ansi/table'
|
|
347
|
-
|
|
348
|
-
The constructor takes an 2-dimensional array.
|
|
349
|
-
|
|
350
|
-
data = [
|
|
351
|
-
[ 10, 20, 30 ],
|
|
352
|
-
[ 20, 10, 20 ],
|
|
353
|
-
[ 50, 40, 20 ]
|
|
354
|
-
]
|
|
355
|
-
|
|
356
|
-
table = ANSI::Table.new(data)
|
|
357
|
-
|
|
358
|
-
table.to_s
|
|
359
|
-
|
|
360
|
-
The output will be:
|
|
361
|
-
|
|
362
|
-
+----+----+----+
|
|
363
|
-
| 10 | 20 | 30 |
|
|
364
|
-
| 20 | 10 | 20 |
|
|
365
|
-
| 50 | 40 | 20 |
|
|
366
|
-
+----+----+----+
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
# ANSI::Diff
|
|
371
|
-
|
|
372
|
-
require 'ansi/diff'
|
|
373
|
-
|
|
374
|
-
a = 'abcYefg'
|
|
375
|
-
b = 'abcXefg'
|
|
376
|
-
|
|
377
|
-
diff = ANSI::Diff.new(a,b)
|
|
378
|
-
|
|
379
|
-
diff.to_s.assert == "\e[31mabc\e[0m\e[33mYefg\e[0m\n\e[31mabc\e[0mXefg"
|
|
380
|
-
|
|
381
|
-
Try another.
|
|
382
|
-
|
|
383
|
-
a = 'abc'
|
|
384
|
-
b = 'abcdef'
|
|
385
|
-
|
|
386
|
-
diff = ANSI::Diff.new(a,b)
|
|
387
|
-
|
|
388
|
-
diff.to_s.assert == "\e[31mabc\e[0m\n\e[31mabc\e[0mdef"
|
|
389
|
-
|
|
390
|
-
And another.
|
|
391
|
-
|
|
392
|
-
a = 'abcXXXghi'
|
|
393
|
-
b = 'abcdefghi'
|
|
394
|
-
|
|
395
|
-
diff = ANSI::Diff.new(a,b)
|
|
396
|
-
|
|
397
|
-
diff.to_s.assert == "\e[31mabc\e[0m\e[33mXXXghi\e[0m\n\e[31mabc\e[0mdefghi"
|
|
398
|
-
|
|
399
|
-
And another.
|
|
400
|
-
|
|
401
|
-
a = 'abcXXXdefghi'
|
|
402
|
-
b = 'abcdefghi'
|
|
403
|
-
|
|
404
|
-
diff = ANSI::Diff.new(a,b)
|
|
405
|
-
|
|
406
|
-
diff.to_s.assert == "\e[31mabc\e[0m\e[33mXXX\e[0m\e[35mdefghi\e[0m\n\e[31mabc\e[0m\e[35mdefghi\e[0m"
|
|
407
|
-
|
|
408
|
-
Comparison that is mostly different.
|
|
409
|
-
|
|
410
|
-
a = 'abcpppz123'
|
|
411
|
-
b = 'abcxyzzz43'
|
|
412
|
-
|
|
413
|
-
diff = ANSI::Diff.new(a,b)
|
|
414
|
-
|
|
415
|
-
diff.to_s.assert == "\e[31mabc\e[0m\e[33mpppz123\e[0m\n\e[31mabc\e[0mxyzzz43"
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
# ANSI::BBCode
|
|
419
|
-
|
|
420
|
-
The BBCode module provides methods for converting between
|
|
421
|
-
BBCodes, basic HTML and ANSI codes.
|
|
422
|
-
|
|
423
|
-
require 'ansi/bbcode'
|
|
424
|
-
|
|
425
|
-
BBCodes are color and style codes in square brackets, quite
|
|
426
|
-
popular with on line forums.
|
|
427
|
-
|
|
428
|
-
bbcode = "this is [COLOR=red]red[/COLOR], this is [B]bold[/B]"
|
|
429
|
-
|
|
430
|
-
We can convert this to ANSI code simply enough:
|
|
431
|
-
|
|
432
|
-
ansi = ANSI::BBCode.bbcode_to_ansi(bbcode)
|
|
433
|
-
|
|
434
|
-
ansi.assert == "this is \e[0;31mred\e[0m, this is \e[1mbold\e[0m\n"
|
|
435
|
-
|
|
436
|
-
In addition the BBCode module supports conversion to simple HTML.
|
|
437
|
-
|
|
438
|
-
html = ANSI::BBCode.bbcode_to_html(bbcode)
|
|
439
|
-
|
|
440
|
-
html.assert == "this is <font color=\"red\">red</font>, this is <strong>bold</strong><br />\n"
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
# ANSI::Terminal
|
|
444
|
-
|
|
445
|
-
We should be ables to get the terminal width via the `terminal_width` method.
|
|
446
|
-
|
|
447
|
-
width = ANSI::Terminal.terminal_width
|
|
448
|
-
|
|
449
|
-
Fixnum.assert === width
|
|
450
|
-
|
|
451
|
-
|
data/lib/ansi.yml
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
revision: 2013
|
|
3
|
-
type: ruby
|
|
4
|
-
sources:
|
|
5
|
-
- INDEX.yml
|
|
6
|
-
authors:
|
|
7
|
-
- name: Thomas Sawyer
|
|
8
|
-
email: transfire@gmail.com
|
|
9
|
-
- name: Florian Frank
|
|
10
|
-
organizations: []
|
|
11
|
-
requirements:
|
|
12
|
-
- groups:
|
|
13
|
-
- build
|
|
14
|
-
development: true
|
|
15
|
-
name: mast
|
|
16
|
-
- groups:
|
|
17
|
-
- build
|
|
18
|
-
development: true
|
|
19
|
-
name: indexer
|
|
20
|
-
- groups:
|
|
21
|
-
- build
|
|
22
|
-
development: true
|
|
23
|
-
name: ergo
|
|
24
|
-
- groups:
|
|
25
|
-
- test
|
|
26
|
-
development: true
|
|
27
|
-
name: qed
|
|
28
|
-
- groups:
|
|
29
|
-
- test
|
|
30
|
-
development: true
|
|
31
|
-
name: ae
|
|
32
|
-
- groups:
|
|
33
|
-
- test
|
|
34
|
-
development: true
|
|
35
|
-
name: lemon
|
|
36
|
-
conflicts: []
|
|
37
|
-
alternatives: []
|
|
38
|
-
resources:
|
|
39
|
-
- type: home
|
|
40
|
-
uri: http://rubyworks.github.com/ansi
|
|
41
|
-
label: Homepage
|
|
42
|
-
- type: docs
|
|
43
|
-
uri: http://rubydoc.info/gems/ansi/frames
|
|
44
|
-
label: Documentation
|
|
45
|
-
- type: code
|
|
46
|
-
uri: http://github.com/rubyworks/ansi
|
|
47
|
-
label: Source Code
|
|
48
|
-
- type: bugs
|
|
49
|
-
uri: http://github.com/rubyworks/ansi/issues
|
|
50
|
-
label: Issue Tracker
|
|
51
|
-
- type: mail
|
|
52
|
-
uri: http://groups.google.com/group/rubyworks-mailinglist
|
|
53
|
-
label: Mailing List
|
|
54
|
-
repositories:
|
|
55
|
-
- name: upstream
|
|
56
|
-
scm: git
|
|
57
|
-
uri: git://github.com/rubyworks/ansi.git
|
|
58
|
-
categories: []
|
|
59
|
-
copyrights:
|
|
60
|
-
- holder: Rubyworks
|
|
61
|
-
year: '2009'
|
|
62
|
-
license: BSD-2-Clause
|
|
63
|
-
customs: []
|
|
64
|
-
paths:
|
|
65
|
-
lib:
|
|
66
|
-
- lib
|
|
67
|
-
name: ansi
|
|
68
|
-
title: ANSI
|
|
69
|
-
version: 1.5.0
|
|
70
|
-
summary: ANSI at your fingertips!
|
|
71
|
-
description: The ANSI project is a superlative collection of ANSI escape code related
|
|
72
|
-
libraries eabling ANSI colorization and stylization of console output. Byte for
|
|
73
|
-
byte ANSI is the best ANSI code library available for the Ruby programming language.
|
|
74
|
-
orgranizations:
|
|
75
|
-
- Rubyworks
|
|
76
|
-
created: '2009-08-01'
|
|
77
|
-
date: '2015-01-16'
|
data/test/case_ansicode.rb
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
require 'ansi/code'
|
|
3
|
-
|
|
4
|
-
testcase ANSI::Code do
|
|
5
|
-
|
|
6
|
-
method :red do
|
|
7
|
-
test do
|
|
8
|
-
str = ANSI::Code.red
|
|
9
|
-
out = "\e[31m"
|
|
10
|
-
out.assert == str
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
test "with block notation" do
|
|
14
|
-
str = ANSI::Code.red { "Hello" }
|
|
15
|
-
out = "\e[31mHello\e[0m"
|
|
16
|
-
out.assert == str
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
method :blue do
|
|
21
|
-
test do
|
|
22
|
-
str = ANSI::Code.blue
|
|
23
|
-
out = "\e[34m"
|
|
24
|
-
out.assert == str
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
test "with block notation" do
|
|
28
|
-
str = ANSI::Code.blue { "World" }
|
|
29
|
-
out = "\e[34mWorld\e[0m"
|
|
30
|
-
out.assert == str
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
method :hex do
|
|
35
|
-
test do
|
|
36
|
-
str = ANSI::Code.hex("#000000")
|
|
37
|
-
out = "0"
|
|
38
|
-
out.assert == str
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
end
|
|
43
|
-
|
data/test/case_bbcode.rb
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
require 'ansi/bbcode'
|
|
3
|
-
|
|
4
|
-
testcase ANSI::BBCode do
|
|
5
|
-
|
|
6
|
-
class_method :bbcode_to_ansi do
|
|
7
|
-
test do
|
|
8
|
-
str = "this is [COLOR=red]red[/COLOR], this is [B]bold[/B]"
|
|
9
|
-
out = "this is \e[0;31mred\e[0m, this is \e[1mbold\e[0m\n"
|
|
10
|
-
out.assert == ANSI::BBCode.bbcode_to_ansi(str)
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
class_method :bbcode_to_html do
|
|
15
|
-
test do
|
|
16
|
-
str = "this is [COLOR=red]red[/COLOR], this is [B]bold[/B]"
|
|
17
|
-
out = "this is <font color=\"red\">red</font>, this is <strong>bold</strong><br />\n"
|
|
18
|
-
out.assert == ANSI::BBCode.bbcode_to_html(str)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
class_method :ansi_to_html do
|
|
23
|
-
test do
|
|
24
|
-
str = "this is \e[0;31mred\e[0m, this is \e[1mbold\e[0m\n" +
|
|
25
|
-
"this is a line without any ansi code\n" +
|
|
26
|
-
"this is \e[0;31mred\e[0m, this is \e[1mbold\e[0m\n"
|
|
27
|
-
out = "this is <font color=\"red\">red</font>, this is <strong>bold</strong><br />\n" +
|
|
28
|
-
"this is a line without any ansi code<br />\n" +
|
|
29
|
-
"this is <font color=\"red\">red</font>, this is <strong>bold</strong><br />\n"
|
|
30
|
-
out.assert == ANSI::BBCode.ansi_to_html(str)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
end
|
|
35
|
-
|
data/test/case_mixin.rb
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
require 'ansi/mixin'
|
|
3
|
-
|
|
4
|
-
testcase ANSI::Mixin do
|
|
5
|
-
|
|
6
|
-
# TODO: subclass
|
|
7
|
-
class ::String
|
|
8
|
-
include ANSI::Mixin
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
method :red do
|
|
12
|
-
test do
|
|
13
|
-
str = "Hello".red
|
|
14
|
-
out = "\e[31mHello\e[0m"
|
|
15
|
-
out.assert == str
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
method :blue do
|
|
20
|
-
test do
|
|
21
|
-
str = "World".blue
|
|
22
|
-
out = "\e[34mWorld\e[0m"
|
|
23
|
-
out.assert == str
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
method :display do
|
|
28
|
-
test do
|
|
29
|
-
str = "Hello".display(4,10)
|
|
30
|
-
out = "\e[s\e[4;10HHello\e[u"
|
|
31
|
-
out.assert == str
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
end
|
data/test/case_progressbar.rb
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
require 'stringio'
|
|
3
|
-
require 'ansi/progressbar'
|
|
4
|
-
|
|
5
|
-
testcase ANSI::Progressbar do
|
|
6
|
-
|
|
7
|
-
method :initialize do
|
|
8
|
-
test do
|
|
9
|
-
stio = StringIO.new
|
|
10
|
-
pbar = ANSI::Progressbar.new("Test Bar", 10, stio) do |b|
|
|
11
|
-
b.style(:title => [:red], :bar=>[:blue])
|
|
12
|
-
end
|
|
13
|
-
10.times do |i|
|
|
14
|
-
sleep 0.1
|
|
15
|
-
pbar.inc
|
|
16
|
-
end
|
|
17
|
-
true
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
end
|
data/test/test_helper.rb
DELETED