yummi 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/yummi.rb CHANGED
@@ -187,7 +187,7 @@ module Yummi
187
187
  # Aligns the text to both sides
188
188
  def self.justify text, width
189
189
  extra_spaces = width - text.size
190
- return text if extra_spaces == 0
190
+ return text if extra_spaces < 0
191
191
  words = text.split ' '
192
192
  return text if extra_spaces / (words.size - 1) > 2
193
193
  until extra_spaces == 0
@@ -39,7 +39,7 @@ module Yummi
39
39
  :content => ''
40
40
  }.merge! params
41
41
  @color = params[:color]
42
- @content = params[:content].to_s
42
+ @content = []
43
43
  end
44
44
 
45
45
  #
@@ -56,7 +56,7 @@ module Yummi
56
56
  #
57
57
  def add text, params = {}
58
58
  params = {
59
- :width => @max_width + 1,
59
+ :width => @max_width,
60
60
  :align => @default_align
61
61
  }.merge! params
62
62
  if params[:width]
@@ -64,7 +64,8 @@ module Yummi
64
64
  words = text.gsub($/, ' ').split(' ')
65
65
  buff = ''
66
66
  words.each do |word|
67
- if buff.size + word.size > width
67
+ # go to next line if the current word blows up the width limit
68
+ if buff.size + word.size >= width
68
69
  _add_ buff, params
69
70
  buff = ''
70
71
  end
@@ -98,7 +99,7 @@ module Yummi
98
99
  def to_s
99
100
  width = 0
100
101
  sizes = []
101
- content.each_line do |line|
102
+ content.each do |line|
102
103
  size = (Yummi::Color::raw line.chomp).size
103
104
  sizes << size
104
105
  width = [width, size].max
@@ -108,7 +109,7 @@ module Yummi
108
109
  buff = ''
109
110
  buff << border
110
111
  i = 0
111
- content.each_line do |line|
112
+ content.each do |line|
112
113
  diff = width - sizes[i]
113
114
  buff << pipe << line.chomp << (' ' * diff) << pipe << $/
114
115
  i += 1
@@ -124,7 +125,6 @@ module Yummi
124
125
  text = Yummi::Aligner.align params[:align], text, params[:width]
125
126
  end
126
127
  @content << Yummi.colorize(text, params[:color])
127
- line_break
128
128
  end
129
129
 
130
130
  end
data/lib/yummi/version.rb CHANGED
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Yummi
24
- VERSION = "0.2.0"
24
+ VERSION = "0.2.1"
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.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: