yummi 0.7.1 → 0.8.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.
- data/bin/yummi +11 -3
- data/examples/license_box.rb +1 -1
- data/lib/yummi.rb +15 -8
- data/lib/yummi/version.rb +1 -1
- metadata +3 -3
data/bin/yummi
CHANGED
@@ -31,6 +31,12 @@ opt = OptionParser::new
|
|
31
31
|
opt.on '-c COLOR', '--color=COLOR', 'Colorize using the given color' do |color|
|
32
32
|
@color = color
|
33
33
|
end
|
34
|
+
opt.on '-s STYLE', '--style=STYLE', Array, 'Sets the styles to use (bold, highlight, underline, blink, ...)' do |styles|
|
35
|
+
@styles = styles
|
36
|
+
end
|
37
|
+
opt.on '-f FORMAT', '--format=FORMAT', 'Sets the format to use (a "%s" means the colorized message)' do |format|
|
38
|
+
@format = format
|
39
|
+
end
|
34
40
|
opt.on '-p PATTERNS', '--pattern=PATTERNS', Array, 'Sets a pattern to colorize each line' do |patterns|
|
35
41
|
@colorizer = Yummi::Colorizers.pattern(patterns)
|
36
42
|
end
|
@@ -67,11 +73,13 @@ end
|
|
67
73
|
opt.parse! ARGV
|
68
74
|
|
69
75
|
def print_out message
|
70
|
-
if @color
|
71
|
-
|
76
|
+
output_text = if @color
|
77
|
+
Yummi::colorize message, @color, @styles
|
72
78
|
elsif @colorizer
|
73
|
-
|
79
|
+
@colorizer.colorize message
|
74
80
|
end
|
81
|
+
output_text = "#{@format}" % output_text if @format
|
82
|
+
puts output_text
|
75
83
|
end
|
76
84
|
|
77
85
|
if @message
|
data/examples/license_box.rb
CHANGED
@@ -36,7 +36,7 @@ opt.on '--align ALIGN', 'Sets the default alignment to use' do |align|
|
|
36
36
|
@box.style.align = align.to_sym
|
37
37
|
end
|
38
38
|
opt.on '--width WIDTH', Integer, 'Sets the text box width' do |width|
|
39
|
-
@box.style.
|
39
|
+
@box.style.width = width
|
40
40
|
end
|
41
41
|
opt.on '--left PATTERN', 'Sets the left line pattern' do |pattern|
|
42
42
|
@box.style.border[:left] = pattern
|
data/lib/yummi.rb
CHANGED
@@ -113,18 +113,25 @@ module Yummi
|
|
113
113
|
#
|
114
114
|
# Colorizes the text using the given color.
|
115
115
|
#
|
116
|
-
#
|
116
|
+
# Examples:
|
117
|
+
#
|
118
|
+
# Yummi.colorize "message", :red # produces a red text
|
119
|
+
# Yummi.colorize "message", :bold_red # produces a bold (intensive) red text
|
120
|
+
# Yummi.colorize "message", :red , :bold # produces a red text
|
117
121
|
#
|
118
122
|
# see #Color#colorize
|
119
123
|
#
|
120
|
-
def self.colorize string, color
|
124
|
+
def self.colorize string, color, styles = []
|
125
|
+
styles ||= [] # prevents nil arguments
|
121
126
|
#check if there is more than one color classifier
|
122
|
-
|
123
|
-
|
124
|
-
color =
|
125
|
-
|
126
|
-
|
127
|
-
|
127
|
+
if styles.empty?
|
128
|
+
styles = color.to_s.split(/_/)
|
129
|
+
color = styles.last
|
130
|
+
styles.delete_at(-1)
|
131
|
+
end
|
132
|
+
unless styles.empty?
|
133
|
+
[*styles].each do |style|
|
134
|
+
string = Color.colorize(string, "#{style}_#{color}")
|
128
135
|
end
|
129
136
|
string
|
130
137
|
else
|
data/lib/yummi/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yummi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
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: 2013-
|
12
|
+
date: 2013-03-31 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A tool to colorize your console application.
|
15
15
|
email:
|
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
74
|
version: '0'
|
75
75
|
requirements: []
|
76
76
|
rubyforge_project:
|
77
|
-
rubygems_version: 1.8.
|
77
|
+
rubygems_version: 1.8.25
|
78
78
|
signing_key:
|
79
79
|
specification_version: 3
|
80
80
|
summary: A tool to colorize your console application.
|