truncate_html 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ == 0.2.2 2009-12-23
2
+ * Fix issue #4: Handle case when supplied length is smaller than omission (ghazel)
3
+
4
+ == 0.2.1 2009-12-18
5
+ * Fix issue #3: Handle case when input html contins a script tag.
6
+
7
+ == 0.2.0 2009-11-23
8
+ * Fix issue #2: The omission text's length is now included in the returned
9
+ string's calculation. This is more consistent with the rails truncate
10
+ helper's behavior.
11
+
12
+ == 0.1.2 2009-09-25
13
+ * Fix issue #1: Handle case when input html is nil.
14
+
15
+ == 0.1.1 2009-08-25
16
+ * Fixed issue with regex which would not recognize <a> tags that contain slashes.
17
+ * Other refactoring and improvements to spec coverage.
18
+
19
+ == 0.1.0 2009-08-03
20
+ * Wrote truncate_html. Initial release.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -12,7 +12,7 @@ module TruncateHtml
12
12
  options[:length] ||= 100
13
13
  options[:omission] ||= '...'
14
14
  @chars_remaining = options[:length] - options[:omission].length
15
- @open_tags, result = [], []
15
+ @open_tags, result = [], ['']
16
16
 
17
17
  html_tokens.each do |str|
18
18
  if @chars_remaining > 0
@@ -14,6 +14,14 @@ describe TruncateHtmlHelper do
14
14
  truncate_html('a b c', :length => 4, :omission => '...').should == 'a...'
15
15
  end
16
16
 
17
+ it 'supports omissions longer than the maximum length' do
18
+ lambda { truncate_html('', :length => 1, :omission => '...') }.should_not raise_error
19
+ end
20
+
21
+ it 'returns the omission when the specified length is smaller than the omission' do
22
+ truncate_html('a b c', :length => 2, :omission => '...').should == '...'
23
+ end
24
+
17
25
  context 'the input html is nil' do
18
26
  it 'returns an empty string' do
19
27
  truncate_html(nil).should be_empty
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{truncate_html}
8
- s.version = "0.2.1"
8
+ s.version = "0.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["hgimenez"]
12
- s.date = %q{2009-12-18}
12
+ s.date = %q{2009-12-23}
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 = [
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
17
17
  ]
18
18
  s.files = [
19
19
  ".gitignore",
20
+ "History.txt",
20
21
  "README.markdown",
21
22
  "Rakefile",
22
23
  "VERSION",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: truncate_html
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - hgimenez
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-18 00:00:00 -05:00
12
+ date: 2009-12-23 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -23,6 +23,7 @@ extra_rdoc_files:
23
23
  - README.markdown
24
24
  files:
25
25
  - .gitignore
26
+ - History.txt
26
27
  - README.markdown
27
28
  - Rakefile
28
29
  - VERSION