truncate_html 0.5.0 → 0.5.1

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.
@@ -1,3 +1,6 @@
1
+ == 0.5.1 2011-04-08
2
+ * Ensure resulting string's length is never greater than supplied length (csquared)
3
+
1
4
  == 0.5.0 2011-01-26
2
5
  * Multibyte support. (smix, parndt)
3
6
 
@@ -62,4 +62,4 @@ All green? Go hack.
62
62
 
63
63
  Copyright (c) 2009 - 2010 Harold A. Giménez, released under the MIT license
64
64
 
65
- Thanks to all the [https://github.com/hgimenez/truncate_html/contributors](contributors)!
65
+ Thanks to all the [contributors](https://github.com/hgimenez/truncate_html/contributors)!
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.5.1
@@ -41,7 +41,7 @@ module TruncateHtml
41
41
 
42
42
  def append_to_result(token)
43
43
  if @word_boundary
44
- @truncated_html << token
44
+ @truncated_html << token if token.html_tag? || @chars_remaining - token.length >= 0
45
45
  else
46
46
  @truncated_html << token[0, @chars_remaining]
47
47
  end
@@ -20,6 +20,10 @@ describe TruncateHtml::HtmlTruncator do
20
20
  truncate('a b c', :length => 4, :omission => '...').should == 'a...'
21
21
  end
22
22
 
23
+ it "never returns a string longer than :length" do
24
+ truncate("test this shit", :length => 10).should == 'test...'
25
+ end
26
+
23
27
  it 'supports omissions longer than the maximum length' do
24
28
  lambda { truncate('', :length => 1, :omission => '...') }.should_not raise_error
25
29
  end
@@ -44,7 +48,7 @@ describe TruncateHtml::HtmlTruncator do
44
48
  end
45
49
 
46
50
  it 'truncates, and closes the <a>, and closes any remaining open tags' do
47
- truncate(@html, :length => 14).should == '<div><ul><li>Look at <a href="foo">this...</a></li></ul></div>'
51
+ truncate(@html, :length => 15).should == '<div><ul><li>Look at <a href="foo">this...</a></li></ul></div>'
48
52
  end
49
53
  end
50
54
 
@@ -54,7 +58,7 @@ describe TruncateHtml::HtmlTruncator do
54
58
  @html = "<p>Look at <strong>this</strong>#{char} More words here</p>"
55
59
  end
56
60
  it 'places the punctuation after the tag without any whitespace' do
57
- truncate(@html, :length => 19).should == "<p>Look at <strong>this</strong>#{char} More...</p>"
61
+ truncate(@html, :length => 19).should == "<p>Look at <strong>this</strong>#{char}...</p>"
58
62
  end
59
63
  end
60
64
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{truncate_html}
8
- s.version = "0.5.0"
8
+ s.version = "0.5.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Harold A. Gimenez"]
12
- s.date = %q{2011-01-26}
12
+ s.date = %q{2011-04-08}
13
13
  s.description = %q{Truncates html so you don't have to}
14
14
  s.email = %q{harold.gimenez@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -62,7 +62,7 @@ Gem::Specification.new do |s|
62
62
  ]
63
63
  s.homepage = %q{http://github.com/hgimenez/truncate_html}
64
64
  s.require_paths = ["lib"]
65
- s.rubygems_version = %q{1.3.7}
65
+ s.rubygems_version = %q{1.6.2}
66
66
  s.summary = %q{Uses an API similar to Rails' truncate helper to truncate HTML and close any lingering open tags.}
67
67
  s.test_files = [
68
68
  "spec/helpers/truncate_html_helper_spec.rb",
@@ -89,7 +89,6 @@ Gem::Specification.new do |s|
89
89
  ]
90
90
 
91
91
  if s.respond_to? :specification_version then
92
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
93
92
  s.specification_version = 3
94
93
 
95
94
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: truncate_html
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 9
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 5
8
- - 0
9
- version: 0.5.0
9
+ - 1
10
+ version: 0.5.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Harold A. Gimenez
@@ -14,51 +15,54 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2011-01-26 00:00:00 -05:00
18
+ date: 2011-04-08 00:00:00 -04:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
- name: jeweler
22
+ type: :development
22
23
  requirement: &id001 !ruby/object:Gem::Requirement
23
24
  none: false
24
25
  requirements:
25
26
  - - ">="
26
27
  - !ruby/object:Gem::Version
28
+ hash: 3
27
29
  segments:
28
30
  - 0
29
31
  version: "0"
30
- type: :development
31
- prerelease: false
32
+ name: jeweler
32
33
  version_requirements: *id001
34
+ prerelease: false
33
35
  - !ruby/object:Gem::Dependency
34
- name: rails
36
+ type: :development
35
37
  requirement: &id002 !ruby/object:Gem::Requirement
36
38
  none: false
37
39
  requirements:
38
40
  - - "="
39
41
  - !ruby/object:Gem::Version
42
+ hash: 1
40
43
  segments:
41
44
  - 3
42
45
  - 0
43
46
  - 3
44
47
  version: 3.0.3
45
- type: :development
46
- prerelease: false
48
+ name: rails
47
49
  version_requirements: *id002
50
+ prerelease: false
48
51
  - !ruby/object:Gem::Dependency
49
- name: rspec-rails
52
+ type: :development
50
53
  requirement: &id003 !ruby/object:Gem::Requirement
51
54
  none: false
52
55
  requirements:
53
56
  - - "="
54
57
  - !ruby/object:Gem::Version
58
+ hash: 5
55
59
  segments:
56
60
  - 2
57
61
  - 3
58
62
  version: "2.3"
59
- type: :development
60
- prerelease: false
63
+ name: rspec-rails
61
64
  version_requirements: *id003
65
+ prerelease: false
62
66
  description: Truncates html so you don't have to
63
67
  email: harold.gimenez@gmail.com
64
68
  executables: []
@@ -125,6 +129,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
129
  requirements:
126
130
  - - ">="
127
131
  - !ruby/object:Gem::Version
132
+ hash: 3
128
133
  segments:
129
134
  - 0
130
135
  version: "0"
@@ -133,13 +138,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
138
  requirements:
134
139
  - - ">="
135
140
  - !ruby/object:Gem::Version
141
+ hash: 3
136
142
  segments:
137
143
  - 0
138
144
  version: "0"
139
145
  requirements: []
140
146
 
141
147
  rubyforge_project:
142
- rubygems_version: 1.3.7
148
+ rubygems_version: 1.6.2
143
149
  signing_key:
144
150
  specification_version: 3
145
151
  summary: Uses an API similar to Rails' truncate helper to truncate HTML and close any lingering open tags.