summary 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ v0.6.3. [Fix #3] Exception when the word can't be summarized
2
+
1
3
  v0.6.2. README review
2
4
 
3
5
  v0.6.1. README review
data/lib/summary.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Summary
2
2
  MAJOR = '0'
3
3
  TINY = '6'
4
- PATCH = '2'
4
+ PATCH = '3'
5
5
  VERSION = [MAJOR, TINY, PATCH] * '.'
6
6
 
7
7
  module String
@@ -36,12 +36,10 @@ module Summary
36
36
  # Checks the need of "summarize" the string. When it is needed, the string is splitted.
37
37
  # Then the last dot is removed and the terminator is pushed into the resultant string.
38
38
  def summary
39
- if pure.size > @size
40
- @text = pure[0...pure[0..(@size-backspace)].rindex(' ')]
41
- @text.gsub(/\.$/,'') + @terminator
42
- else
43
- pure
44
- end
39
+ return pure if pure.size < @size or pure !~ /\s/
40
+
41
+ @text = pure[0...pure[0..(@size-backspace)].rindex(' ')]
42
+ @text.gsub(/\.$/,'') + @terminator
45
43
  end
46
44
 
47
45
  protected
data/spec/summary_spec.rb CHANGED
@@ -34,6 +34,17 @@ describe Summary, 'on plain text' do
34
34
  end
35
35
  end
36
36
 
37
+ describe Summary, "when the string is thin" do
38
+ before do
39
+ @text = "test"
40
+ end
41
+
42
+ context "when the summary size is lower than the string size" do
43
+ it "should not summarize the string" do
44
+ @text.summary(2).should == @text
45
+ end
46
+ end
47
+ end
37
48
 
38
49
  describe Summary, 'on html' do
39
50
  before do
data/summary.gemspec CHANGED
@@ -2,12 +2,12 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{summary}
5
- s.version = "0.6.2"
5
+ s.version = "0.6.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Bruno Azisaka Maciel"]
9
9
  s.cert_chain = ["/Users/Bruno/.certs/gem-public_cert.pem"]
10
- s.date = %q{2010-08-07}
10
+ s.date = %q{2010-08-08}
11
11
  s.description = %q{This is a simple gem that generates introduction text from a long text, it will always break the text at the end of the last word near to the limit you informed as argument.}
12
12
  s.email = %q{bruno [at] bubble [dot] com [dot] br}
13
13
  s.extra_rdoc_files = ["CHANGELOG", "README.rdoc", "lib/summary.rb"]
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: summary
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 2
10
- version: 0.6.2
9
+ - 3
10
+ version: 0.6.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bruno Azisaka Maciel
@@ -36,7 +36,7 @@ cert_chain:
36
36
  Qk3muzkQzffuq2/7M5zVVnmOi8M1z563OJCOKtDpzVoeXYNoVIZSpgY7
37
37
  -----END CERTIFICATE-----
38
38
 
39
- date: 2010-08-07 00:00:00 -03:00
39
+ date: 2010-08-08 00:00:00 -03:00
40
40
  default_executable:
41
41
  dependencies: []
42
42
 
metadata.gz.sig CHANGED
@@ -1 +1,4 @@
1
- V+���b��E7�VBL�� �T$���ß[(���
1
+ ���?�*n��S�!yaPd�1>(
2
2
  *rs�]����g��9�z�$�{ep"�O�����aԿπ�QU �U���
3
+ ��-(�Cs��k�[�����lr�IT�_���B���X��lx9��i
4
+ l�*��P��oK��7�� �D���z�{��bU��3��G��j�oU˻:Pn �B"�g�Io�0-���|�+�� q�8��};���1ӟ�F�Ş�\w��O�j���R��׎\
5
+ "����&$"���V�o�}�