crayon 0.0.5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +3 -3
- data/.gitignore +2 -0
- data/CHANGELOG.md +26 -0
- data/LICENSE +1 -1
- data/README.md +9 -1
- data/VERSION +1 -1
- data/lib/crayon.rb +4 -2
- data/spec/crayon_spec.rb +18 -0
- metadata +5 -2
data/.document
CHANGED
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
### 1.0.0 : 04/21/10
|
2
|
+
|
3
|
+
* Fixed bug where a method name which has `on_` followed by anything not an allowed color would return an underlined string.
|
4
|
+
* Set `method_missing` to return `Crayon` so color methods can be chained.
|
5
|
+
* Crayon can handle mixed-case method names.
|
6
|
+
|
7
|
+
### 0.0.5 : 04/21/10
|
8
|
+
|
9
|
+
* Moved functionality from passing variables between methods to using instance variables.
|
10
|
+
|
11
|
+
### 0.0.4 : 04/21/10
|
12
|
+
|
13
|
+
* Adds documentation and hides most helper methods from public documentation.
|
14
|
+
|
15
|
+
### 0.0.3 : 04/21/10
|
16
|
+
|
17
|
+
* Switches documentation from RDoc to Markdown
|
18
|
+
* Moves gem dependencies into Gemfile
|
19
|
+
* Switches tests over to RSpec
|
20
|
+
|
21
|
+
|
22
|
+
### 0.0.2 : 03/15/10
|
23
|
+
|
24
|
+
* Swtiches testing to Tinytest
|
25
|
+
* Adds basic functionality
|
26
|
+
* Adds sample output file and rake task
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# crayon
|
2
2
|
|
3
|
-
### current version : 0.0
|
3
|
+
### current version : 1.0.0
|
4
4
|
|
5
5
|
[http://github.com/mikowitz/crayon][github]
|
6
6
|
|
@@ -50,6 +50,14 @@ By default, a newline is added.
|
|
50
50
|
Crayon.puts.cyan("Also on the first line, but with a trailing newline")
|
51
51
|
Crayon.blue("On the second line by itself.")
|
52
52
|
|
53
|
+
You can also chain color calls without having to call `Crayon` multiple times
|
54
|
+
|
55
|
+
Crayon.print.red("red").blue("blue").puts.green("green")
|
56
|
+
|
57
|
+
`Crayon` will also handle mixed-case method calls
|
58
|
+
|
59
|
+
Crayon.ReD_ON_gREEN("It's Christmas!")
|
60
|
+
|
53
61
|
## Flexibility
|
54
62
|
|
55
63
|
The order of elements in the method name is unimportant. For example
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
1.0.0
|
data/lib/crayon.rb
CHANGED
@@ -27,6 +27,7 @@ module Crayon
|
|
27
27
|
parse_method_name
|
28
28
|
io.print prepare_string(string)
|
29
29
|
nullify_variables
|
30
|
+
Crayon
|
30
31
|
end
|
31
32
|
|
32
33
|
##
|
@@ -35,7 +36,7 @@ module Crayon
|
|
35
36
|
# Crayon.parse_method_name(:bold_red_on_green) #=> "['red', 'green', ['bold']]"
|
36
37
|
# @private
|
37
38
|
def parse_method_name
|
38
|
-
@method_name = @method_name.to_s.split("_")
|
39
|
+
@method_name = @method_name.to_s.downcase.split("_")
|
39
40
|
@background = parse_background
|
40
41
|
@foreground = parse_foreground
|
41
42
|
@formatting = parse_formatting
|
@@ -46,7 +47,8 @@ module Crayon
|
|
46
47
|
_idx = @method_name.index("on")
|
47
48
|
if _idx
|
48
49
|
@method_name.delete("on")
|
49
|
-
|
50
|
+
_background = @method_name.delete_at(_idx)
|
51
|
+
_background if COLORS.keys.include?(_background)
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
data/spec/crayon_spec.rb
CHANGED
@@ -45,6 +45,9 @@ describe "Crayon" do
|
|
45
45
|
Crayon.newline?.should be
|
46
46
|
end
|
47
47
|
end
|
48
|
+
it "chaining color calls should be allowed by return Crayon from method_missing" do
|
49
|
+
Crayon.red("OK").should == Crayon
|
50
|
+
end
|
48
51
|
describe "method_missing" do
|
49
52
|
describe "should call :prepare string" do
|
50
53
|
before { Crayon.should_receive(:prepare_string).with("hello") }
|
@@ -79,6 +82,21 @@ describe "Crayon" do
|
|
79
82
|
test_parse_method_name(:red_green, "red", nil, [])
|
80
83
|
test_parse_method_name(:red_bold_underline, "red", nil, ["bold", "underline"])
|
81
84
|
test_parse_method_name(:underline_on_green_bold, nil, "green", ["underline", "bold"])
|
85
|
+
|
86
|
+
describe "with mixed-case input" do
|
87
|
+
test_parse_method_name(:RED, "red", nil, [])
|
88
|
+
test_parse_method_name(:ON_red, nil, "red", [])
|
89
|
+
test_parse_method_name(:bOld, nil, nil, ["bold"])
|
90
|
+
|
91
|
+
test_parse_method_name(:BlUe_on_GREEN, "blue", "green", [])
|
92
|
+
test_parse_method_name(:UNDERline_oN_Green_BOLD, nil, "green", ["underline", "bold"])
|
93
|
+
end
|
94
|
+
|
95
|
+
describe "with invalid input" do
|
96
|
+
test_parse_method_name(:notacolor, nil, nil, [])
|
97
|
+
test_parse_method_name(:on_notacolor, nil, nil, [])
|
98
|
+
test_parse_method_name(:blue_on_notacolor, "blue", nil, [])
|
99
|
+
end
|
82
100
|
end
|
83
101
|
|
84
102
|
describe "prepare_string" do
|
metadata
CHANGED
@@ -3,10 +3,10 @@ name: crayon
|
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
|
+
- 1
|
6
7
|
- 0
|
7
8
|
- 0
|
8
|
-
|
9
|
-
version: 0.0.5
|
9
|
+
version: 1.0.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Michael Berkowitz
|
@@ -26,10 +26,12 @@ extensions: []
|
|
26
26
|
|
27
27
|
extra_rdoc_files:
|
28
28
|
- LICENSE
|
29
|
+
- README.html
|
29
30
|
- README.md
|
30
31
|
files:
|
31
32
|
- .document
|
32
33
|
- .gitignore
|
34
|
+
- CHANGELOG.md
|
33
35
|
- Gemfile
|
34
36
|
- LICENSE
|
35
37
|
- README.md
|
@@ -39,6 +41,7 @@ files:
|
|
39
41
|
- spec/crayon_spec.rb
|
40
42
|
- spec/helper.rb
|
41
43
|
- spec/spec.opts
|
44
|
+
- README.html
|
42
45
|
has_rdoc: true
|
43
46
|
homepage: http://github.com/mikowitz/crayon
|
44
47
|
licenses: []
|