summary 0.6.5 → 0.6.6

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/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ v0.6.6. Refactoring
2
+
1
3
  v0.6.5. Code improvements and docs
2
4
 
3
5
  v0.6.4. [Fix #2] If the strings are smaller than the terminator it should not be applied
data/lib/summary.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Summary
2
2
  MAJOR = '0'
3
3
  TINY = '6'
4
- PATCH = '3'
4
+ PATCH = '6'
5
5
  VERSION = [MAJOR, TINY, PATCH] * '.'
6
6
 
7
7
  module String
@@ -28,9 +28,7 @@ module Summary
28
28
 
29
29
  class Summarize
30
30
  def initialize(text, size = 100, terminator = '...')
31
- @text = text
32
- @size = size
33
- @terminator = terminator
31
+ @text, @size, @terminator = text, size, terminator
34
32
  end
35
33
 
36
34
  # Checks the need of "summarize" the string. When it is needed, the string is splitted.
@@ -38,8 +36,7 @@ module Summary
38
36
  def summary
39
37
  return pure unless summarizable?
40
38
 
41
- text = pure[0...string_limit]
42
- text = text.gsub(/\.$/,'') + @terminator
39
+ pure[0...string_limit].gsub(/\.$/,'') + @terminator
43
40
  end
44
41
 
45
42
  protected
@@ -50,24 +47,24 @@ module Summary
50
47
 
51
48
  # Cleans up any string removing the html tags, break lines and white spaces.
52
49
  def purify(string)
53
- string.strip.gsub(/<(.|\n)+?>|(\t|\n|\r)+/,'').gsub(/\s+/,' ')
50
+ string.gsub(/(^\s+)|<(.|\n)+?>|(\t|\n|\r)+/,'').gsub(/\s+/,' ')
54
51
  end
55
52
 
56
53
  # Calculates the size limit to summarize the string.
57
54
  def string_limit
58
- @string_limit ||= pure[0..(@size-backspace)].rindex(' ')
55
+ @string_limit ||= pure[0..(@size - backspace)].rindex(' ')
59
56
  end
60
57
 
61
58
  # Verifies if the string can be summarized.
62
59
  def summarizable?
63
- pure.size > @size and pure =~ /\s/ and string_limit >= purify(@terminator).size
60
+ pure.size > @size and pure =~ /\s/ and string_limit >= backspace
64
61
  end
65
62
 
66
63
  # Measures the space needed by the terminator.
67
64
  # Let's say you want a string with 50 chars, and your terminator is a '...'.
68
65
  # That means your string can only have 47 chars + 3 chars from your terminator.
69
66
  def backspace
70
- (@terminator =~ /<(.|\n)+?>/ ? purify(@terminator) : @terminator).size
67
+ @backspace ||= purify(@terminator).size
71
68
  end
72
69
  end
73
70
  end
data/summary.gemspec CHANGED
@@ -2,12 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{summary}
5
- s.version = "0.6.5"
5
+ s.version = "0.6.6"
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
- s.cert_chain = ["/Users/Bruno/.certs/gem-public_cert.pem"]
10
- s.date = %q{2010-08-08}
9
+ s.date = %q{2010-09-04}
11
10
  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
11
  s.email = %q{bruno [at] bubble [dot] com [dot] br}
13
12
  s.extra_rdoc_files = ["CHANGELOG", "README.rdoc", "lib/summary.rb"]
@@ -17,7 +16,6 @@ Gem::Specification.new do |s|
17
16
  s.require_paths = ["lib"]
18
17
  s.rubyforge_project = %q{summary}
19
18
  s.rubygems_version = %q{1.3.7}
20
- s.signing_key = %q{/Users/Bruno/.certs/gem-private_key.pem}
21
19
  s.summary = %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.}
22
20
 
23
21
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -1,42 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: summary
3
3
  version: !ruby/object:Gem::Version
4
- hash: 13
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 6
9
- - 5
10
- version: 0.6.5
9
+ - 6
10
+ version: 0.6.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Bruno Azisaka Maciel
14
14
  autorequire:
15
15
  bindir: bin
16
- cert_chain:
17
- - |
18
- -----BEGIN CERTIFICATE-----
19
- MIIDVjCCAj6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBRMQ4wDAYDVQQDDAVicnVu
20
- bzEWMBQGCgmSJomT8ixkARkWBmJ1YmJsZTETMBEGCgmSJomT8ixkARkWA2NvbTES
21
- MBAGCgmSJomT8ixkARkWAmJyMB4XDTEwMDcwOTAzMDgzMloXDTExMDcwOTAzMDgz
22
- MlowUTEOMAwGA1UEAwwFYnJ1bm8xFjAUBgoJkiaJk/IsZAEZFgZidWJibGUxEzAR
23
- BgoJkiaJk/IsZAEZFgNjb20xEjAQBgoJkiaJk/IsZAEZFgJicjCCASIwDQYJKoZI
24
- hvcNAQEBBQADggEPADCCAQoCggEBALtBRcHEtEyyr7zSrkS37jKiPEWiKZZhbTZH
25
- 5Yy7x2RA4DI6aUzGWVJ5IE18kdFuGu5rZ1k6Wcf2dGELAs7Os7MeWxXaCvmmJDHa
26
- 4eR6iFjfqAqocU927YIjOClBABWnJghDW7QqxgFvHYMVRj2/WgrHx8mUbZp0RJkU
27
- IlWi4RVEpRhJghKvD5zBaVUqDO8fdgLls21g/j/ouLCPfqvuh90dxR1uiDa89JPE
28
- EbOVJPGgceZL7FnVPQokPWS4jTAkm0nKpmElOU1vggplY+qULDAusufWDS6YlAsb
29
- o0my/uovLSkzqHPeXgMgUgxafycD2NEUz0L0Zi0+41/8+7KT25MCAwEAAaM5MDcw
30
- CQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFJyLvNXo0jpfTs0oRrsr
31
- ZJ64XDKJMA0GCSqGSIb3DQEBBQUAA4IBAQCssdnvIqs6+DnfVb4SCAsAgzECIFTx
32
- dKX39I17hMRhb9K0yvDXsA++LIVQfMuvnR3oVaP8blRdGMyRIB+QPEBcCJiW1Ljp
33
- vuAgyiicxDjoikfwONWISxeW64LHqJGRvxZOMtxWGd7Vsc655hJUoOBnK2Vi5rKx
34
- 1FO4o7EKd+KD1emJtoTmKS0B7fuszwy3ux6H9kRBtNtjKhvvu4AB7gXS5b0ypSz6
35
- QCNVuBCPE7+WCKOZZ8Dk6I99EHFlHQmIcnxMbs/tQRJ5cP/PET9k9WH3jTY+MNs2
36
- Qk3muzkQzffuq2/7M5zVVnmOi8M1z563OJCOKtDpzVoeXYNoVIZSpgY7
37
- -----END CERTIFICATE-----
16
+ cert_chain: []
38
17
 
39
- date: 2010-08-08 00:00:00 -03:00
18
+ date: 2010-09-04 00:00:00 -03:00
40
19
  default_executable:
41
20
  dependencies: []
42
21
 
data.tar.gz.sig DELETED
Binary file
metadata.gz.sig DELETED
@@ -1 +0,0 @@
1
- k�#�m�����n��Io]ܓ-%n//�i&�z�x9L'�%iU�xITN-�U�t�q������ݒ���f��������"N��J@��A�V����b�T$�͙��T.��V8" �@T�exH,���Ԓ�l+t��V�Zw=T��\�e^ξ�du��mW��.e�4�&]P" ���ؘ���e�P��>�����H�\�-2�5-2������ۨ�%S�JO�Xɗr]�t3H%D���ȥ�㙵�d�Kܧ�