truncato 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 1.9.3-p385
data/Gemfile CHANGED
@@ -23,4 +23,5 @@ end
23
23
 
24
24
  group :benchrmark do
25
25
  gem 'html_truncator'
26
+ gem 'peppercorn'
26
27
  end
data/README.md CHANGED
@@ -48,12 +48,14 @@ The results comparing truncato with other libs:
48
48
  <th>Truncato</th>
49
49
  <th><a href="https://github.com/ianwhite/truncate_html">truncate_html</a></th>
50
50
  <th><a href="https://github.com/nono/HTML-Truncator">HTML Truncator</a></th>
51
+ <th><a href="https://github.com/wadewest/peppercorn">peppercorn</a></th>
51
52
  </tr>
52
53
  <tr>
53
54
  <th>Time for truncating a 4MB XML document to 4KB</th>
54
55
  <td>1.5 s</td>
55
56
  <td>20 s</td>
56
57
  <td>220 s</td>
58
+ <td>232 s</td>
57
59
  </tr>
58
60
  </table>
59
61
 
data/Rakefile CHANGED
@@ -38,16 +38,6 @@ end
38
38
 
39
39
  task :default => :spec
40
40
 
41
- require 'rake/rdoctask'
42
- Rake::RDocTask.new do |rdoc|
43
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
-
45
- rdoc.rdoc_dir = 'rdoc'
46
- rdoc.title = "solid_assert #{version}"
47
- rdoc.rdoc_files.include('README*')
48
- rdoc.rdoc_files.include('lib/**/*.rb')
49
- end
50
-
51
41
  $:.unshift File.join(File.dirname(__FILE__), 'benchmark')
52
42
 
53
43
  require 'nokogiri'
data/VERSION CHANGED
@@ -1,2 +1 @@
1
- 0.7.2
2
-
1
+ 0.7.3
@@ -15,9 +15,10 @@ module Truncato
15
15
  end
16
16
 
17
17
  def run_comparison
18
- run_suite [Truncato, VendorHtmlTruncatorAdapter]
18
+ run_suite [Truncato, VendorHtmlTruncatorAdapter, PeppercornAdapter]
19
19
  end
20
20
 
21
+
21
22
  private
22
23
 
23
24
  def run_suite(truncation_classes)
@@ -0,0 +1,9 @@
1
+ # Adapter for comparing https://github.com/nono/HTML-Truncator
2
+ module Truncato
3
+ class PeppercornAdapter
4
+ def self.truncate string, options
5
+ string.truncate_html options[:max_length], :tail=>options[:tail]
6
+ end
7
+ end
8
+ end
9
+
@@ -5,6 +5,7 @@ require 'bundler'
5
5
  require 'nokogiri'
6
6
  require 'truncato'
7
7
  require 'html_truncator'
8
+ require 'peppercorn'
8
9
  require 'benchmark'
9
10
 
10
11
  Bundler.setup
@@ -1,3 +1,6 @@
1
+ require 'nokogiri'
2
+ require 'htmlentities'
3
+
1
4
  class TruncatedSaxDocument < Nokogiri::XML::SAX::Document
2
5
  attr_reader :truncated_string, :max_length, :max_length_reached, :tail, :count_tags, :filtered_attributes
3
6
 
@@ -100,4 +103,4 @@ class TruncatedSaxDocument < Nokogiri::XML::SAX::Document
100
103
  def overriden_tag_length
101
104
  @count_tags ? nil : 0
102
105
  end
103
- end
106
+ end
@@ -46,13 +46,13 @@ describe "Truncato" do
46
46
  source: "<div><p attr1='1'>some text</p></div>",
47
47
  expected: "<div><p attr1='1'>some...</p></div>"
48
48
 
49
- it_should_truncate "html text with attribute containing entities respecting them", with: {max_length: 3, count_tags: false, filtered_attributes: ['attr1', 'attr2']},
49
+ it_should_truncate "html text with attribute containing entities respecting them", with: {max_length: 3, count_tags: false, filtered_attributes: ['attr2']},
50
50
  source: "<p attr1='&gt;some'>text</p>",
51
- expected: "<p attr1='&gt;some'>text</p>"
51
+ expected: "<p attr1='&gt;some'>tex...</p>"
52
52
 
53
53
  it_should_truncate "html text with 2 attributes filtering one of them", with: {max_length: 30, count_tags: false, filtered_attributes: ['attr2']},
54
- source: "<p attr1='1' attr2='2'>some text</p>",
55
- expected: "<p>som...</p>"
54
+ source: "<p attr1='1'>some text</p>",
55
+ expected: "<p attr1='1'>some text</p>"
56
56
 
57
57
  it_should_truncate "html text with 2 attributes filtering all of them", with: {max_length: 3, count_tags: false, filtered_attributes: ['attr1', 'attr2']},
58
58
  source: "<p attr1='1' attr2='2'>some text</p>",
data/truncato.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "truncato"
8
- s.version = "0.7.2"
8
+ s.version = "0.7.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jorge Manrubia"]
12
- s.date = "2012-11-13"
12
+ s.date = "2013-03-13"
13
13
  s.description = "Ruby tool for truncating HTML strings keeping a valid HTML markup"
14
14
  s.email = "jorge.manrubia@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
17
17
  "README.md"
18
18
  ]
19
19
  s.files = [
20
+ ".ruby-version",
20
21
  ".rvmrc",
21
22
  "Gemfile",
22
23
  "LICENSE.txt",
@@ -24,6 +25,7 @@ Gem::Specification.new do |s|
24
25
  "Rakefile",
25
26
  "VERSION",
26
27
  "benchmark/truncato/benchmark_runner.rb",
28
+ "benchmark/truncato/vendor/peppercorn_adapter.rb",
27
29
  "benchmark/truncato/vendor/vendor_html_truncator_adapter.rb",
28
30
  "benchmark/truncato_benchmark.rb",
29
31
  "lib/truncato.rb",
@@ -37,7 +39,7 @@ Gem::Specification.new do |s|
37
39
  s.homepage = "https://github.com/jorgemanrubia/truncato"
38
40
  s.licenses = ["MIT"]
39
41
  s.require_paths = ["lib"]
40
- s.rubygems_version = "1.8.24"
42
+ s.rubygems_version = "1.8.23"
41
43
  s.summary = "A tool for truncating HTML strings efficiently"
42
44
 
43
45
  if s.respond_to? :specification_version then
@@ -55,6 +57,8 @@ Gem::Specification.new do |s|
55
57
  s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
56
58
  s.add_development_dependency(%q<bundler>, ["~> 1.2.1"])
57
59
  s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
60
+ s.add_development_dependency(%q<bundler>, ["~> 1.2.1"])
61
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
58
62
  else
59
63
  s.add_dependency(%q<truncato>, [">= 0"])
60
64
  s.add_dependency(%q<nokogiri>, ["~> 1.5.5"])
@@ -67,6 +71,8 @@ Gem::Specification.new do |s|
67
71
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
68
72
  s.add_dependency(%q<bundler>, ["~> 1.2.1"])
69
73
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
74
+ s.add_dependency(%q<bundler>, ["~> 1.2.1"])
75
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
70
76
  end
71
77
  else
72
78
  s.add_dependency(%q<truncato>, [">= 0"])
@@ -80,6 +86,8 @@ Gem::Specification.new do |s|
80
86
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
81
87
  s.add_dependency(%q<bundler>, ["~> 1.2.1"])
82
88
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
89
+ s.add_dependency(%q<bundler>, ["~> 1.2.1"])
90
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
83
91
  end
84
92
  end
85
93
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: truncato
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-13 00:00:00.000000000 Z
12
+ date: 2013-03-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: truncato
@@ -187,6 +187,38 @@ dependencies:
187
187
  - - ~>
188
188
  - !ruby/object:Gem::Version
189
189
  version: 1.8.4
190
+ - !ruby/object:Gem::Dependency
191
+ name: bundler
192
+ requirement: !ruby/object:Gem::Requirement
193
+ none: false
194
+ requirements:
195
+ - - ~>
196
+ - !ruby/object:Gem::Version
197
+ version: 1.2.1
198
+ type: :development
199
+ prerelease: false
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ~>
204
+ - !ruby/object:Gem::Version
205
+ version: 1.2.1
206
+ - !ruby/object:Gem::Dependency
207
+ name: jeweler
208
+ requirement: !ruby/object:Gem::Requirement
209
+ none: false
210
+ requirements:
211
+ - - ~>
212
+ - !ruby/object:Gem::Version
213
+ version: 1.8.4
214
+ type: :development
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ~>
220
+ - !ruby/object:Gem::Version
221
+ version: 1.8.4
190
222
  description: Ruby tool for truncating HTML strings keeping a valid HTML markup
191
223
  email: jorge.manrubia@gmail.com
192
224
  executables: []
@@ -195,6 +227,7 @@ extra_rdoc_files:
195
227
  - LICENSE.txt
196
228
  - README.md
197
229
  files:
230
+ - .ruby-version
198
231
  - .rvmrc
199
232
  - Gemfile
200
233
  - LICENSE.txt
@@ -202,6 +235,7 @@ files:
202
235
  - Rakefile
203
236
  - VERSION
204
237
  - benchmark/truncato/benchmark_runner.rb
238
+ - benchmark/truncato/vendor/peppercorn_adapter.rb
205
239
  - benchmark/truncato/vendor/vendor_html_truncator_adapter.rb
206
240
  - benchmark/truncato_benchmark.rb
207
241
  - lib/truncato.rb
@@ -226,7 +260,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
226
260
  version: '0'
227
261
  segments:
228
262
  - 0
229
- hash: -4126738111465282499
263
+ hash: 1479395706551271193
230
264
  required_rubygems_version: !ruby/object:Gem::Requirement
231
265
  none: false
232
266
  requirements:
@@ -235,7 +269,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
235
269
  version: '0'
236
270
  requirements: []
237
271
  rubyforge_project:
238
- rubygems_version: 1.8.24
272
+ rubygems_version: 1.8.23
239
273
  signing_key:
240
274
  specification_version: 3
241
275
  summary: A tool for truncating HTML strings efficiently