yummi 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
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
- puts Yummi::colorize message, @color
76
+ output_text = if @color
77
+ Yummi::colorize message, @color, @styles
72
78
  elsif @colorizer
73
- puts @colorizer.colorize message
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
@@ -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.border[:width] = width
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
- # This method also checks if the color mode is in chain (like in "underline_bold_green").
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
- modes = color.to_s.split(/_/)
123
- if modes.size >= 3
124
- color = modes.last
125
- modes.delete_at(-1)
126
- modes.each do |mode|
127
- string = Color.colorize(string, "#{mode}_#{color}")
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
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Yummi
24
- VERSION = "0.7.1"
24
+ VERSION = "0.8.0"
25
25
  end
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.7.1
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-01-07 00:00:00.000000000 Z
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.24
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.