coloring 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +7 -2
- data/README.md +5 -1
- data/lib/coloring.rb +12 -0
- data/lib/coloring/version.rb +1 -1
- data/spec/coloring_spec.rb +14 -2
- metadata +2 -2
data/CHANGELOG.rdoc
CHANGED
@@ -1,7 +1,12 @@
|
|
1
|
-
== 0.0.
|
1
|
+
== 0.0.5 (2012-08-24)
|
2
|
+
* Added class method view_avaliable
|
3
|
+
* Method set_param now protected
|
4
|
+
* Added some tests
|
5
|
+
|
6
|
+
== 0.0.4 (2012-08-22)
|
2
7
|
* Added specs
|
3
8
|
* Added full README
|
4
9
|
* Added this CHANGELOG file
|
5
10
|
|
6
|
-
== 0.0.3
|
11
|
+
== 0.0.3 (2012-08-22)
|
7
12
|
* Start release
|
data/README.md
CHANGED
@@ -5,13 +5,17 @@ Extension for Ruby string class. Extension add methods for coloring text or back
|
|
5
5
|
### Features
|
6
6
|
|
7
7
|
* String.color ( color: black, red, green, yelow, blue, magenta, cyan, white )
|
8
|
-
* String.
|
8
|
+
* String.on\_color( background colors same )
|
9
9
|
* String.bright
|
10
10
|
* String.underline
|
11
11
|
* String.blink
|
12
12
|
* String.negative
|
13
13
|
* String.hide
|
14
14
|
|
15
|
+
Also avaliable class method to view all methods.
|
16
|
+
|
17
|
+
Coloring::view_avaliable
|
18
|
+
|
15
19
|
### Installation
|
16
20
|
|
17
21
|
Add this line to your application's Gemfile:
|
data/lib/coloring.rb
CHANGED
@@ -48,6 +48,8 @@ module Coloring
|
|
48
48
|
param
|
49
49
|
end
|
50
50
|
|
51
|
+
protected :set_param
|
52
|
+
|
51
53
|
# Output method
|
52
54
|
|
53
55
|
def coloring ( params )
|
@@ -61,7 +63,17 @@ module Coloring
|
|
61
63
|
"\033[#{all_params}m" + self + "\033[0m"
|
62
64
|
|
63
65
|
end
|
66
|
+
|
67
|
+
# Class method
|
68
|
+
|
69
|
+
class << self
|
64
70
|
|
71
|
+
def view_avaliable
|
72
|
+
SGRPARAMS.each { |key, value| puts "#{key}".coloring(value) + " > String.#{key}" }
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
65
77
|
end
|
66
78
|
|
67
79
|
String.send(:include, Coloring)
|
data/lib/coloring/version.rb
CHANGED
data/spec/coloring_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe Coloring do
|
|
6
6
|
@sample = "Hello, World!"
|
7
7
|
end
|
8
8
|
|
9
|
-
describe "base
|
9
|
+
describe "all base methods" do
|
10
10
|
|
11
11
|
it "should return value" do
|
12
12
|
@sample.green.should_not be_nil
|
@@ -16,6 +16,14 @@ describe Coloring do
|
|
16
16
|
@sample.red.class.should == String
|
17
17
|
end
|
18
18
|
|
19
|
+
it "should return right content" do
|
20
|
+
@sample.red.should eq("\e[31mHello, World!\e[0m")
|
21
|
+
end
|
22
|
+
|
23
|
+
it "consistently call methods must return right content" do
|
24
|
+
@sample.red.underline.should eq("\e[4m\e[31mHello, World!\e[0m\e[0m")
|
25
|
+
end
|
26
|
+
|
19
27
|
end
|
20
28
|
|
21
29
|
describe "method with params" do
|
@@ -25,13 +33,17 @@ describe Coloring do
|
|
25
33
|
end
|
26
34
|
|
27
35
|
it "should return right class" do
|
28
|
-
@sample.
|
36
|
+
@sample.coloring(:green).class.should == String
|
29
37
|
end
|
30
38
|
|
31
39
|
it "should raise error if wrong parameter for method" do
|
32
40
|
expect { @sample.coloring(:red, :on_blue) }.to raise_error
|
33
41
|
end
|
34
42
|
|
43
|
+
it "should return right content" do
|
44
|
+
@sample.coloring(:green).should eq("\e[32mHello, World!\e[0m")
|
45
|
+
end
|
46
|
+
|
35
47
|
end
|
36
48
|
|
37
49
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coloring
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|