html_truncator 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/html_truncator.rb +3 -3
  2. metadata +35 -56
@@ -63,14 +63,14 @@ end
63
63
  class Nokogiri::XML::Text
64
64
  def truncate(max, opts)
65
65
  if opts[:length_in_chars]
66
- count = content.length
66
+ count = to_xhtml.length
67
67
  return [to_xhtml, count, opts] if count <= max && max > 0
68
68
  [content.slice(0, max), count, opts]
69
69
  else
70
- words = content.split
70
+ words = to_xhtml.scan(/\s*\S+/)
71
71
  count = words.length
72
72
  return [to_xhtml, count, opts] if count <= max && max > 0
73
- [words.slice(0, max).join(' '), count, opts]
73
+ [words.slice(0, max).join, count, opts]
74
74
  end
75
75
  end
76
76
  end
metadata CHANGED
@@ -1,59 +1,46 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: html_truncator
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 2
8
- - 0
9
- version: 0.2.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Bruno Michel
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-01-28 00:00:00 +01:00
12
+ date: 2011-02-23 00:00:00.000000000 +01:00
18
13
  default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
21
16
  name: nokogiri
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &79281530 !ruby/object:Gem::Requirement
24
18
  none: false
25
- requirements:
19
+ requirements:
26
20
  - - ~>
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 1
30
- - 4
31
- version: "1.4"
21
+ - !ruby/object:Gem::Version
22
+ version: '1.4'
32
23
  type: :runtime
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- name: rspec
36
24
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *79281530
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec
28
+ requirement: &79281290 !ruby/object:Gem::Requirement
38
29
  none: false
39
- requirements:
30
+ requirements:
40
31
  - - ~>
41
- - !ruby/object:Gem::Version
42
- segments:
43
- - 2
44
- - 4
45
- version: "2.4"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.4'
46
34
  type: :development
47
- version_requirements: *id002
35
+ prerelease: false
36
+ version_requirements: *79281290
48
37
  description: Wants to truncate an HTML string properly? This gem is for you.
49
38
  email: bmichel@menfin.info
50
39
  executables: []
51
-
52
40
  extensions: []
53
-
54
- extra_rdoc_files:
41
+ extra_rdoc_files:
55
42
  - README.md
56
- files:
43
+ files:
57
44
  - MIT-LICENSE
58
45
  - README.md
59
46
  - Gemfile
@@ -61,34 +48,26 @@ files:
61
48
  has_rdoc: true
62
49
  homepage: http://github.com/nono/HTML-Truncator
63
50
  licenses: []
64
-
65
51
  post_install_message:
66
52
  rdoc_options: []
67
-
68
- require_paths:
53
+ require_paths:
69
54
  - lib
70
- required_ruby_version: !ruby/object:Gem::Requirement
55
+ required_ruby_version: !ruby/object:Gem::Requirement
71
56
  none: false
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- segments:
76
- - 0
77
- version: "0"
78
- required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
62
  none: false
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- segments:
84
- - 0
85
- version: "0"
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
86
67
  requirements: []
87
-
88
68
  rubyforge_project:
89
- rubygems_version: 1.3.7
69
+ rubygems_version: 1.5.2
90
70
  signing_key:
91
71
  specification_version: 3
92
72
  summary: Wants to truncate an HTML string properly? This gem is for you.
93
73
  test_files: []
94
-