truncate_html 0.5.1 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/.travis.yml +6 -0
- data/Gemfile +4 -7
- data/Gemfile.lock +91 -78
- data/README.md +97 -0
- data/Rakefile +12 -31
- data/VERSION +1 -1
- data/lib/app/helpers/truncate_html_helper.rb +1 -1
- data/lib/truncate_html/configuration.rb +1 -2
- data/lib/truncate_html/html_string.rb +17 -16
- data/lib/truncate_html/html_truncator.rb +69 -39
- data/lib/truncate_html/version.rb +3 -0
- data/lib/truncate_html.rb +6 -4
- data/spec/helpers/truncate_html_helper_spec.rb +7 -7
- data/spec/rails_root/Gemfile +2 -2
- data/spec/rails_root/Gemfile.lock +84 -71
- data/spec/spec_helper.rb +2 -0
- data/spec/truncate_html/html_string_spec.rb +28 -22
- data/spec/truncate_html/html_truncator_spec.rb +165 -88
- data/spec/truncate_html/truncate_html_spec.rb +15 -0
- data/truncate_html.gemspec +14 -101
- metadata +63 -89
- data/README.markdown +0 -65
data/truncate_html.gemspec
CHANGED
@@ -1,109 +1,22 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path("../lib/truncate_html/version", __FILE__)
|
5
3
|
|
6
4
|
Gem::Specification.new do |s|
|
7
|
-
s.name
|
8
|
-
s.version
|
9
|
-
|
10
|
-
s.
|
11
|
-
s.
|
12
|
-
s.
|
5
|
+
s.name = "truncate_html"
|
6
|
+
s.version = TruncateHtml::VERSION
|
7
|
+
s.authors = ["Harold Giménez"]
|
8
|
+
s.email = ["harold.gimenez@gmail.com"]
|
9
|
+
s.homepage = "https://github.com/hgmnz/truncate_html"
|
10
|
+
s.summary = %q{Uses an API similar to Rails' truncate helper to truncate HTML and close any lingering open tags.}
|
13
11
|
s.description = %q{Truncates html so you don't have to}
|
14
|
-
|
15
|
-
s.
|
16
|
-
"
|
17
|
-
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
"Gemfile",
|
21
|
-
"Gemfile.lock",
|
22
|
-
"History.txt",
|
23
|
-
"LICENSE",
|
24
|
-
"README.markdown",
|
25
|
-
"Rakefile",
|
26
|
-
"VERSION",
|
27
|
-
"init.rb",
|
28
|
-
"lib/app/helpers/truncate_html_helper.rb",
|
29
|
-
"lib/truncate_html.rb",
|
30
|
-
"lib/truncate_html/configuration.rb",
|
31
|
-
"lib/truncate_html/html_string.rb",
|
32
|
-
"lib/truncate_html/html_truncator.rb",
|
33
|
-
"spec/helpers/truncate_html_helper_spec.rb",
|
34
|
-
"spec/rails_root/.bundle/config",
|
35
|
-
"spec/rails_root/Gemfile",
|
36
|
-
"spec/rails_root/Gemfile.lock",
|
37
|
-
"spec/rails_root/app/controllers/application_controller.rb",
|
38
|
-
"spec/rails_root/app/helpers/application_helper.rb",
|
39
|
-
"spec/rails_root/config/application.rb",
|
40
|
-
"spec/rails_root/config/boot.rb",
|
41
|
-
"spec/rails_root/config/database.yml",
|
42
|
-
"spec/rails_root/config/environment.rb",
|
43
|
-
"spec/rails_root/config/environments/development.rb",
|
44
|
-
"spec/rails_root/config/environments/production.rb",
|
45
|
-
"spec/rails_root/config/environments/test.rb",
|
46
|
-
"spec/rails_root/config/initializers/backtrace_silencers.rb",
|
47
|
-
"spec/rails_root/config/initializers/inflections.rb",
|
48
|
-
"spec/rails_root/config/initializers/mime_types.rb",
|
49
|
-
"spec/rails_root/config/initializers/new_rails_defaults.rb",
|
50
|
-
"spec/rails_root/config/initializers/session_store.rb",
|
51
|
-
"spec/rails_root/config/locales/en.yml",
|
52
|
-
"spec/rails_root/config/routes.rb",
|
53
|
-
"spec/rails_root/init.rb",
|
54
|
-
"spec/rails_root/lib/app/helpers/truncate_html_helper.rb",
|
55
|
-
"spec/rails_root/lib/tasks/rspec.rake",
|
56
|
-
"spec/spec.opts",
|
57
|
-
"spec/spec_helper.rb",
|
58
|
-
"spec/truncate_html/configuration_spec.rb",
|
59
|
-
"spec/truncate_html/html_string_spec.rb",
|
60
|
-
"spec/truncate_html/html_truncator_spec.rb",
|
61
|
-
"truncate_html.gemspec"
|
62
|
-
]
|
63
|
-
s.homepage = %q{http://github.com/hgimenez/truncate_html}
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
64
16
|
s.require_paths = ["lib"]
|
65
|
-
s.rubygems_version = %q{1.6.2}
|
66
|
-
s.summary = %q{Uses an API similar to Rails' truncate helper to truncate HTML and close any lingering open tags.}
|
67
|
-
s.test_files = [
|
68
|
-
"spec/helpers/truncate_html_helper_spec.rb",
|
69
|
-
"spec/rails_root/app/controllers/application_controller.rb",
|
70
|
-
"spec/rails_root/app/helpers/application_helper.rb",
|
71
|
-
"spec/rails_root/config/application.rb",
|
72
|
-
"spec/rails_root/config/boot.rb",
|
73
|
-
"spec/rails_root/config/environment.rb",
|
74
|
-
"spec/rails_root/config/environments/development.rb",
|
75
|
-
"spec/rails_root/config/environments/production.rb",
|
76
|
-
"spec/rails_root/config/environments/test.rb",
|
77
|
-
"spec/rails_root/config/initializers/backtrace_silencers.rb",
|
78
|
-
"spec/rails_root/config/initializers/inflections.rb",
|
79
|
-
"spec/rails_root/config/initializers/mime_types.rb",
|
80
|
-
"spec/rails_root/config/initializers/new_rails_defaults.rb",
|
81
|
-
"spec/rails_root/config/initializers/session_store.rb",
|
82
|
-
"spec/rails_root/config/routes.rb",
|
83
|
-
"spec/rails_root/init.rb",
|
84
|
-
"spec/rails_root/lib/app/helpers/truncate_html_helper.rb",
|
85
|
-
"spec/spec_helper.rb",
|
86
|
-
"spec/truncate_html/configuration_spec.rb",
|
87
|
-
"spec/truncate_html/html_string_spec.rb",
|
88
|
-
"spec/truncate_html/html_truncator_spec.rb"
|
89
|
-
]
|
90
17
|
|
91
|
-
|
92
|
-
s.specification_version = 3
|
18
|
+
s.required_ruby_version = '>= 1.9'
|
93
19
|
|
94
|
-
|
95
|
-
|
96
|
-
s.add_development_dependency(%q<rails>, ["= 3.0.3"])
|
97
|
-
s.add_development_dependency(%q<rspec-rails>, ["= 2.3"])
|
98
|
-
else
|
99
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
100
|
-
s.add_dependency(%q<rails>, ["= 3.0.3"])
|
101
|
-
s.add_dependency(%q<rspec-rails>, ["= 2.3"])
|
102
|
-
end
|
103
|
-
else
|
104
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
105
|
-
s.add_dependency(%q<rails>, ["= 3.0.3"])
|
106
|
-
s.add_dependency(%q<rspec-rails>, ["= 2.3"])
|
107
|
-
end
|
20
|
+
s.add_development_dependency "rspec-rails", "~> 2.13"
|
21
|
+
s.add_development_dependency "rails", "~> 3.2.13"
|
108
22
|
end
|
109
|
-
|
metadata
CHANGED
@@ -1,83 +1,57 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: truncate_html
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 5
|
9
|
-
- 1
|
10
|
-
version: 0.5.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.3
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
13
|
-
- Harold
|
6
|
+
authors:
|
7
|
+
- Harold Giménez
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
11
|
+
date: 2014-09-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec-rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.13'
|
22
20
|
type: :development
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
none: false
|
25
|
-
requirements:
|
26
|
-
- - ">="
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 3
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
32
|
-
name: jeweler
|
33
|
-
version_requirements: *id001
|
34
21
|
prerelease: false
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
- !ruby/object:Gem::Version
|
42
|
-
hash: 1
|
43
|
-
segments:
|
44
|
-
- 3
|
45
|
-
- 0
|
46
|
-
- 3
|
47
|
-
version: 3.0.3
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
48
28
|
name: rails
|
49
|
-
|
50
|
-
|
51
|
-
-
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.2.13
|
52
34
|
type: :development
|
53
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
54
|
-
none: false
|
55
|
-
requirements:
|
56
|
-
- - "="
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
hash: 5
|
59
|
-
segments:
|
60
|
-
- 2
|
61
|
-
- 3
|
62
|
-
version: "2.3"
|
63
|
-
name: rspec-rails
|
64
|
-
version_requirements: *id003
|
65
35
|
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.2.13
|
66
41
|
description: Truncates html so you don't have to
|
67
|
-
email:
|
42
|
+
email:
|
43
|
+
- harold.gimenez@gmail.com
|
68
44
|
executables: []
|
69
|
-
|
70
45
|
extensions: []
|
71
|
-
|
72
|
-
|
73
|
-
-
|
74
|
-
-
|
75
|
-
files:
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- ".travis.yml"
|
76
50
|
- Gemfile
|
77
51
|
- Gemfile.lock
|
78
52
|
- History.txt
|
79
53
|
- LICENSE
|
80
|
-
- README.
|
54
|
+
- README.md
|
81
55
|
- Rakefile
|
82
56
|
- VERSION
|
83
57
|
- init.rb
|
@@ -86,6 +60,7 @@ files:
|
|
86
60
|
- lib/truncate_html/configuration.rb
|
87
61
|
- lib/truncate_html/html_string.rb
|
88
62
|
- lib/truncate_html/html_truncator.rb
|
63
|
+
- lib/truncate_html/version.rb
|
89
64
|
- spec/helpers/truncate_html_helper_spec.rb
|
90
65
|
- spec/rails_root/.bundle/config
|
91
66
|
- spec/rails_root/Gemfile
|
@@ -114,47 +89,42 @@ files:
|
|
114
89
|
- spec/truncate_html/configuration_spec.rb
|
115
90
|
- spec/truncate_html/html_string_spec.rb
|
116
91
|
- spec/truncate_html/html_truncator_spec.rb
|
92
|
+
- spec/truncate_html/truncate_html_spec.rb
|
117
93
|
- truncate_html.gemspec
|
118
|
-
|
119
|
-
homepage: http://github.com/hgimenez/truncate_html
|
94
|
+
homepage: https://github.com/hgmnz/truncate_html
|
120
95
|
licenses: []
|
121
|
-
|
96
|
+
metadata: {}
|
122
97
|
post_install_message:
|
123
98
|
rdoc_options: []
|
124
|
-
|
125
|
-
require_paths:
|
99
|
+
require_paths:
|
126
100
|
- lib
|
127
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
128
|
-
|
129
|
-
requirements:
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
130
103
|
- - ">="
|
131
|
-
- !ruby/object:Gem::Version
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
version: "0"
|
136
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
|
-
requirements:
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '1.9'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
139
108
|
- - ">="
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
|
142
|
-
segments:
|
143
|
-
- 0
|
144
|
-
version: "0"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
145
111
|
requirements: []
|
146
|
-
|
147
112
|
rubyforge_project:
|
148
|
-
rubygems_version:
|
113
|
+
rubygems_version: 2.2.2
|
149
114
|
signing_key:
|
150
|
-
specification_version:
|
151
|
-
summary: Uses an API similar to Rails' truncate helper to truncate HTML and close
|
152
|
-
|
115
|
+
specification_version: 4
|
116
|
+
summary: Uses an API similar to Rails' truncate helper to truncate HTML and close
|
117
|
+
any lingering open tags.
|
118
|
+
test_files:
|
153
119
|
- spec/helpers/truncate_html_helper_spec.rb
|
120
|
+
- spec/rails_root/.bundle/config
|
121
|
+
- spec/rails_root/Gemfile
|
122
|
+
- spec/rails_root/Gemfile.lock
|
154
123
|
- spec/rails_root/app/controllers/application_controller.rb
|
155
124
|
- spec/rails_root/app/helpers/application_helper.rb
|
156
125
|
- spec/rails_root/config/application.rb
|
157
126
|
- spec/rails_root/config/boot.rb
|
127
|
+
- spec/rails_root/config/database.yml
|
158
128
|
- spec/rails_root/config/environment.rb
|
159
129
|
- spec/rails_root/config/environments/development.rb
|
160
130
|
- spec/rails_root/config/environments/production.rb
|
@@ -164,10 +134,14 @@ test_files:
|
|
164
134
|
- spec/rails_root/config/initializers/mime_types.rb
|
165
135
|
- spec/rails_root/config/initializers/new_rails_defaults.rb
|
166
136
|
- spec/rails_root/config/initializers/session_store.rb
|
137
|
+
- spec/rails_root/config/locales/en.yml
|
167
138
|
- spec/rails_root/config/routes.rb
|
168
139
|
- spec/rails_root/init.rb
|
169
140
|
- spec/rails_root/lib/app/helpers/truncate_html_helper.rb
|
141
|
+
- spec/rails_root/lib/tasks/rspec.rake
|
142
|
+
- spec/spec.opts
|
170
143
|
- spec/spec_helper.rb
|
171
144
|
- spec/truncate_html/configuration_spec.rb
|
172
145
|
- spec/truncate_html/html_string_spec.rb
|
173
146
|
- spec/truncate_html/html_truncator_spec.rb
|
147
|
+
- spec/truncate_html/truncate_html_spec.rb
|
data/README.markdown
DELETED
@@ -1,65 +0,0 @@
|
|
1
|
-
TruncateHtml
|
2
|
-
============
|
3
|
-
|
4
|
-
truncate_html is a Rails helper plugin that [cuts off](http://www.youtube.com/watch?v=6XG4DIOA7nU) a string of HTML and takes care of closing any lingering open tags. There are many possible solutions to this. This plugin does not have any dependencies, and does all it's work via [regular expressions](http://xkcd.com/208/).
|
5
|
-
|
6
|
-
The API is very similar to Rails' own <code>truncate()</code> method.
|
7
|
-
|
8
|
-
|
9
|
-
Example
|
10
|
-
-------
|
11
|
-
|
12
|
-
some_html = '<ul><li><a href="http://whatever">This is a link</a></li></ul>'
|
13
|
-
truncate_html(some_html, :length => 15, :omission => '...(continued)')
|
14
|
-
=> <ul><li><a href="http://whatever">This...(continued)</a></li></ul>
|
15
|
-
|
16
|
-
A few notes:
|
17
|
-
|
18
|
-
* By default, it will truncate on word boundary.
|
19
|
-
To truncate the HTML string strictly at the specified length, pass in the `:word_boundary => false` option.
|
20
|
-
* If the input HTML is nil, it will return an empty string.
|
21
|
-
* The omission text's length does count toward the resulting string's length.
|
22
|
-
* `<script>` tags will pass right through - they will not count toward the resulting string's length, or be truncated.
|
23
|
-
* The default options are:
|
24
|
-
* :length => 100
|
25
|
-
* :omission => '...'
|
26
|
-
* :word_boundary => true
|
27
|
-
|
28
|
-
You may also set global configuration options.
|
29
|
-
For example, place the following on a sensible place,
|
30
|
-
like `config/initializers/truncate_html.rb`
|
31
|
-
|
32
|
-
TruncateHtml.configure do |config|
|
33
|
-
config.length = 50
|
34
|
-
config.omission = '...(continued)'
|
35
|
-
config.word_boundary = false
|
36
|
-
end
|
37
|
-
|
38
|
-
Installation
|
39
|
-
------------
|
40
|
-
|
41
|
-
The latest gem version for the Rails 2.x series is 0.3.2.
|
42
|
-
To use truncate_html on a Rails 2 app, please install the 0.3.2 version:
|
43
|
-
|
44
|
-
gem install truncate_html -v 0.3.2
|
45
|
-
|
46
|
-
For Rails 3, use the latest truncate_html:
|
47
|
-
|
48
|
-
gem install truncate_html
|
49
|
-
|
50
|
-
Issues or Suggestions
|
51
|
-
---------------------
|
52
|
-
|
53
|
-
Found an issue or have a suggestion? Please report it on [Github's issue tracker](http://github.com/hgimenez/truncate_html/issues).
|
54
|
-
|
55
|
-
Testing
|
56
|
-
-------
|
57
|
-
|
58
|
-
bundle
|
59
|
-
rake
|
60
|
-
|
61
|
-
All green? Go hack.
|
62
|
-
|
63
|
-
Copyright (c) 2009 - 2010 Harold A. Giménez, released under the MIT license
|
64
|
-
|
65
|
-
Thanks to all the [contributors](https://github.com/hgimenez/truncate_html/contributors)!
|