truncateHTML 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,38 @@
1
+ truncateHTML
2
+ ==============
3
+ `truncateHTML` truncates text like the Rails `truncate` helper but doesn't break HTML tags, entities, and optionally words.
4
+
5
+ Installation
6
+ ------------
7
+
8
+ The `truncateHTML` gem can be installed by running:
9
+
10
+ gem install truncateHTML
11
+
12
+ Usage
13
+ -----
14
+
15
+ require 'rubygems'
16
+ require 'truncateHTML'
17
+
18
+ A string `html_string` can be truncated by running:
19
+
20
+ truncateHTML.truncate(`html_string`)
21
+
22
+ The following options can be passed to the `trucate` method:
23
+
24
+ - `:max_length` The maximum length of the out put. Defaults to 40
25
+ - `:ellipsis` The last few characters , in case the string is truncated. Defaults to `...`
26
+ - `:words` Splicing words will be avoided if set to ttrue. Defaults to false.
27
+ - `:link` A link will be appended to the truncated string if explicitely passed. Its by default nil.
28
+
29
+ Author
30
+ ------
31
+
32
+ B V Satyaram <[bvsatyaram.com](http://bvsatyaram.com)>
33
+
34
+ - Initially authored By Henrik Nyh <[henrik.nyh.se](http://henrik.nyh.se)> 2008-01-30. Free to modify and redistribute with credit.
35
+ - Modified by Dave Nolan <[textgoeshere.org.uk](http://textgoeshere.org.uk)> 2008-02-06. Ellipsis appended to text of last HTML node. Ellipsis inserted after final word break
36
+ - Modified by Mark Dickson <mark@sitesteaders.com> 2008-12-18. Option to truncate to last full word. Option to include a 'more' link. Check for nil last child
37
+ - Modified by Ken-ichi Ueda <[kueda.net](http://kueda.net)> 2009-09-02. Rails 2.3 compatability (chars -> mb_chars), via Henrik. Hpricot 0.8 compatability (avoid dup on Hpricot::Elem)
38
+ - Modified by B V Satyaram <[bvsatyaram.com](http://bvsatyaram.com)> 2011-03-24. Rails version independent. Making this a gem. Removed mb_chars
@@ -23,7 +23,7 @@ require "hpricot"
23
23
  require "truncateHTML/hpricot_truncator"
24
24
 
25
25
  module TruncateHTML
26
- # Like the Rails _truncate_ helper but doesn't break HTML tags, entities, and optionally. words.
26
+ # Like the Rails _truncate_ helper but doesn't break HTML tags, entities, and optionally words.
27
27
  def self.truncate(text, options={})
28
28
  return if text.nil?
29
29
 
@@ -57,4 +57,4 @@ module TruncateHTML
57
57
 
58
58
  return status ? [return_string, return_status] : return_string
59
59
  end
60
- end
60
+ end
@@ -1,3 +1,3 @@
1
1
  module Truncatehtml
2
- VERSION = "0.0.1"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: truncateHTML
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
5
4
  prerelease: false
6
5
  segments:
6
+ - 1
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ version: 1.0.0
11
10
  platform: ruby
12
11
  authors:
13
12
  - Satyaram B V
@@ -15,18 +14,16 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2011-03-26 00:00:00 +05:30
17
+ date: 2011-05-04 00:00:00 +05:30
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
22
21
  name: hpricot
23
22
  prerelease: false
24
23
  requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
24
  requirements:
27
25
  - - ">="
28
26
  - !ruby/object:Gem::Version
29
- hash: 3
30
27
  segments:
31
28
  - 0
32
29
  version: "0"
@@ -44,6 +41,7 @@ extra_rdoc_files: []
44
41
  files:
45
42
  - .gitignore
46
43
  - Gemfile
44
+ - README.md
47
45
  - Rakefile
48
46
  - lib/truncateHTML.rb
49
47
  - lib/truncateHTML/hpricot_truncator.rb
@@ -60,27 +58,23 @@ rdoc_options: []
60
58
  require_paths:
61
59
  - lib
62
60
  required_ruby_version: !ruby/object:Gem::Requirement
63
- none: false
64
61
  requirements:
65
62
  - - ">="
66
63
  - !ruby/object:Gem::Version
67
- hash: 3
68
64
  segments:
69
65
  - 0
70
66
  version: "0"
71
67
  required_rubygems_version: !ruby/object:Gem::Requirement
72
- none: false
73
68
  requirements:
74
69
  - - ">="
75
70
  - !ruby/object:Gem::Version
76
- hash: 3
77
71
  segments:
78
72
  - 0
79
73
  version: "0"
80
74
  requirements: []
81
75
 
82
76
  rubyforge_project: truncateHTML
83
- rubygems_version: 1.3.7
77
+ rubygems_version: 1.3.6
84
78
  signing_key:
85
79
  specification_version: 3
86
80
  summary: Truncate HTML without breaking HTML tags, entities, and optionally words