paint 0.8.6 → 0.8.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.rdoc +3 -0
- data/LICENSE.txt +1 -1
- data/README.rdoc +3 -3
- data/Rakefile +1 -1
- data/lib/paint.rb +10 -7
- data/lib/paint/version.rb +1 -1
- data/paint.gemspec +4 -4
- data/spec/paint_spec.rb +5 -1
- metadata +34 -50
- data/.gemtest +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ced283d5b465e7b6542cfd6753100e230498dbe9
|
4
|
+
data.tar.gz: e816d3cf009e99ef5e2f9797bd7c0605c5790f77
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f6706e6a54863b5504137291bdb1e300bcdc8a5950f8525fdf9b1bc6828bd45c0cada92f4211735dc766f28c2c102b1eb02fc62b0afe635834ba324aea5a97f4
|
7
|
+
data.tar.gz: 5af21b99c6074ec374766b8e2aa0995240bb2e22f84d1873c134722008223fd3db6d9e8b1f892098105d997831f07bd75d77f8a961d25f96246647b58b235a74
|
data/CHANGELOG.rdoc
CHANGED
data/LICENSE.txt
CHANGED
data/README.rdoc
CHANGED
@@ -29,7 +29,7 @@ In Ruby do:
|
|
29
29
|
|
30
30
|
The only method you need to know to get started is: <tt>Paint.[]</tt>
|
31
31
|
|
32
|
-
The first argument given to <tt>Paint.[]</tt> is the string to colorize (if the object is not a string, <tt>to_s</tt> will be called on
|
32
|
+
The first argument given to <tt>Paint.[]</tt> is the string to colorize (if the object is not a string, <tt>to_s</tt> will be called on it). The other arguments describe how to modify/colorize the string. Let's learn by example:
|
33
33
|
|
34
34
|
Paint['Ruby', :red] # sets ansi color red
|
35
35
|
Paint['Ruby', :red, :bright] # also applies bright/bold effect
|
@@ -46,7 +46,7 @@ The first argument given to <tt>Paint.[]</tt> is the string to colorize (if the
|
|
46
46
|
Paint['Ruby', :italic, :encircle, :rapid_blink, :overline] # probably not supported effects
|
47
47
|
Paint['Ruby'] # don't pass any argument and the string will not be changed
|
48
48
|
|
49
|
-
|
49
|
+
When you pass multiple colors, the first one is taken as foreground color and the second one defines the background color, every other will be ignored. To only change the background color, you have to pass a <tt>nil</tt> first. Effects can be passed in any order.
|
50
50
|
|
51
51
|
You can find more examples in the specs.
|
52
52
|
|
@@ -161,7 +161,7 @@ There are some supporting methods available. You can get a <tt>p</tt> like alter
|
|
161
161
|
|
162
162
|
Another helper method is <tt>Paint.unpaint</tt>, which removes any ansi colors:
|
163
163
|
|
164
|
-
Paint.unpaint( Paint['
|
164
|
+
Paint.unpaint( Paint['Ruby', :red, :bright] ).should == 'Ruby'
|
165
165
|
|
166
166
|
== J-_-L
|
167
167
|
|
data/Rakefile
CHANGED
@@ -29,7 +29,7 @@ end
|
|
29
29
|
|
30
30
|
desc "Install the gem locally"
|
31
31
|
task :install => :gem do
|
32
|
-
sh %{gem install pkg/#{gemspec.name}-#{gemspec.version} --no-rdoc --no-ri}
|
32
|
+
sh %{gem install pkg/#{gemspec.name}-#{gemspec.version}.gem --no-rdoc --no-ri}
|
33
33
|
end
|
34
34
|
|
35
35
|
desc "Generate the gemspec"
|
data/lib/paint.rb
CHANGED
@@ -85,11 +85,11 @@ module Paint
|
|
85
85
|
# See README.rdoc for details
|
86
86
|
def [](string, *options)
|
87
87
|
return string.to_s if mode.zero? || options.empty?
|
88
|
-
|
88
|
+
|
89
89
|
if options.size == 1 && !options.first.respond_to?(:to_ary)
|
90
90
|
options = options.first
|
91
91
|
end
|
92
|
-
|
92
|
+
|
93
93
|
cache[options] + string.to_s + NOTHING
|
94
94
|
end
|
95
95
|
|
@@ -140,12 +140,12 @@ module Paint
|
|
140
140
|
|
141
141
|
when nil
|
142
142
|
color_seen = :set
|
143
|
-
|
143
|
+
|
144
144
|
else
|
145
145
|
raise ArgumentError, "Invalid argument: #{ option.inspect }"
|
146
146
|
|
147
147
|
end
|
148
|
-
|
148
|
+
|
149
149
|
if color_seen == :set
|
150
150
|
colors = ANSI_COLORS_BACKGROUND
|
151
151
|
color_seen = true
|
@@ -214,11 +214,14 @@ module Paint
|
|
214
214
|
end
|
215
215
|
|
216
216
|
private
|
217
|
-
|
217
|
+
|
218
218
|
def cache
|
219
|
-
@cache
|
219
|
+
return @cache if @cache
|
220
|
+
@cache = Hash.new { |h, k| h[k] = color(*k) }
|
221
|
+
def @cache.[](*k) k.include?(:random) ? Paint.color(*k) : super end
|
222
|
+
@cache
|
220
223
|
end
|
221
|
-
|
224
|
+
|
222
225
|
# Returns nearest supported 256-color an rgb value, without fore-/background information
|
223
226
|
# Inspired by the rainbow gem
|
224
227
|
def rgb_value(red, green, blue)
|
data/lib/paint/version.rb
CHANGED
data/paint.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
require 'rubygems' unless defined? Gem
|
3
3
|
require File.dirname(__FILE__) + "/lib/paint/version"
|
4
|
-
|
4
|
+
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "paint"
|
7
7
|
s.version = Paint::VERSION
|
@@ -11,15 +11,15 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.summary = "Terminal painter!"
|
12
12
|
s.description = "Terminal painter / no string extensions / 256 color support / effect support / define custom shortcuts / basic usage: Paint['string', :red, :bright]"
|
13
13
|
s.required_ruby_version = '>= 1.8.7'
|
14
|
-
s.files = Dir.glob(%w[{lib,test,spec}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c}]) + %w{Rakefile paint.gemspec
|
14
|
+
s.files = Dir.glob(%w[{lib,test,spec}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c}]) + %w{Rakefile paint.gemspec}
|
15
15
|
s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
|
16
16
|
s.license = 'MIT'
|
17
17
|
s.add_development_dependency 'rspec'
|
18
18
|
s.add_development_dependency 'rspec-core'
|
19
19
|
s.add_development_dependency 'rake'
|
20
|
-
s.add_development_dependency 'rainbow'
|
20
|
+
s.add_development_dependency 'rainbow', '1.1.4'
|
21
21
|
s.add_development_dependency 'term-ansicolor'
|
22
|
-
|
22
|
+
|
23
23
|
len = s.homepage.size
|
24
24
|
s.post_install_message = \
|
25
25
|
(" ┌── " + "info ".ljust(len-2,'%') + "─┐\n" +
|
data/spec/paint_spec.rb
CHANGED
@@ -47,8 +47,12 @@ describe 'Paint.[]' do
|
|
47
47
|
it 'colorizes using a random ansi foreground color' do
|
48
48
|
Paint['J-_-L', :random].should =~ /\e\[3\dmJ-_-L\e\[0m/
|
49
49
|
end
|
50
|
+
|
51
|
+
it 'does not cache randomness' do
|
52
|
+
(0..99).map{ Paint['J-_-L', :random] }.uniq.size.should > 1
|
53
|
+
end
|
50
54
|
end
|
51
|
-
|
55
|
+
|
52
56
|
context '(with two colors)' do
|
53
57
|
it 'interprets the first color as foreground color and the second one as background color' do
|
54
58
|
Paint['J-_-L', :yellow, :red].should == "\e[33;41mJ-_-L\e[0m"
|
metadata
CHANGED
@@ -1,97 +1,86 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paint
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
5
|
-
prerelease:
|
4
|
+
version: 0.8.7
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jan Lelis
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-01-19 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rspec-core
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rake
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rainbow
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '='
|
68
60
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
61
|
+
version: 1.1.4
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '='
|
76
67
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
68
|
+
version: 1.1.4
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: term-ansicolor
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - ">="
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - ">="
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
|
-
description:
|
83
|
+
description: 'Terminal painter / no string extensions / 256 color support / effect
|
95
84
|
support / define custom shortcuts / basic usage: Paint[''string'', :red, :bright]'
|
96
85
|
email: mail@janlelis.de
|
97
86
|
executables: []
|
@@ -100,52 +89,47 @@ extra_rdoc_files:
|
|
100
89
|
- README.rdoc
|
101
90
|
- LICENSE.txt
|
102
91
|
files:
|
103
|
-
-
|
104
|
-
- lib/paint/shortcuts.rb
|
105
|
-
- lib/paint/rgb_colors_ansi.rb
|
106
|
-
- lib/paint/pa.rb
|
107
|
-
- lib/paint/util.rb
|
108
|
-
- lib/paint/rgb_colors.rb
|
109
|
-
- lib/paint.rb
|
110
|
-
- spec/paint_shortcuts_spec.rb
|
111
|
-
- spec/spec_helper.rb
|
112
|
-
- spec/paint_mode_spec.rb
|
113
|
-
- spec/paint_spec.rb
|
114
|
-
- spec/paint_methods_spec.rb
|
92
|
+
- CHANGELOG.rdoc
|
115
93
|
- LICENSE.txt
|
116
94
|
- README.rdoc
|
117
|
-
- CHANGELOG.rdoc
|
118
95
|
- Rakefile
|
96
|
+
- lib/paint.rb
|
97
|
+
- lib/paint/pa.rb
|
98
|
+
- lib/paint/rgb_colors.rb
|
99
|
+
- lib/paint/rgb_colors_ansi.rb
|
100
|
+
- lib/paint/shortcuts.rb
|
101
|
+
- lib/paint/util.rb
|
102
|
+
- lib/paint/version.rb
|
119
103
|
- paint.gemspec
|
120
|
-
- .
|
104
|
+
- spec/paint_methods_spec.rb
|
105
|
+
- spec/paint_mode_spec.rb
|
106
|
+
- spec/paint_shortcuts_spec.rb
|
107
|
+
- spec/paint_spec.rb
|
108
|
+
- spec/spec_helper.rb
|
121
109
|
homepage: https://github.com/janlelis/paint
|
122
110
|
licenses:
|
123
111
|
- MIT
|
124
|
-
|
112
|
+
metadata: {}
|
113
|
+
post_install_message: " ┌── info ───────────────────────────┐\n J-_-L │ https://github.com/janlelis/paint
|
125
114
|
│\n ├── usage ──────────────────────────┤\n │ require 'paint' │\n
|
126
115
|
\ │ puts Paint['J-_-L', :red] # \e[31mJ-_-L\e[0m │\n └───────────────────────────────────┘"
|
127
116
|
rdoc_options: []
|
128
117
|
require_paths:
|
129
118
|
- lib
|
130
119
|
required_ruby_version: !ruby/object:Gem::Requirement
|
131
|
-
none: false
|
132
120
|
requirements:
|
133
|
-
- -
|
121
|
+
- - ">="
|
134
122
|
- !ruby/object:Gem::Version
|
135
123
|
version: 1.8.7
|
136
124
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
125
|
requirements:
|
139
|
-
- -
|
126
|
+
- - ">="
|
140
127
|
- !ruby/object:Gem::Version
|
141
128
|
version: '0'
|
142
|
-
segments:
|
143
|
-
- 0
|
144
|
-
hash: -2257675358826790756
|
145
129
|
requirements: []
|
146
130
|
rubyforge_project:
|
147
|
-
rubygems_version:
|
131
|
+
rubygems_version: 2.2.1
|
148
132
|
signing_key:
|
149
|
-
specification_version:
|
133
|
+
specification_version: 4
|
150
134
|
summary: Terminal painter!
|
151
135
|
test_files: []
|
data/.gemtest
DELETED
File without changes
|