summarise 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4549b404c0250a7e913afe1b1247780d9b9f9a8c
4
- data.tar.gz: 0425dad62e064bcda31a344e3e2f1090fdc366f5
3
+ metadata.gz: 3b5ff8dfcb80b9cf5afed172e338d524cb85b238
4
+ data.tar.gz: c8aed0f72f8f827f9f4e8740b7c84f5a344b4064
5
5
  SHA512:
6
- metadata.gz: 25095bf4d65810117f6ea85af6a690b3f9b366c0305fbd4bf60fdfd94464a92144ec5f3bdb3ffc6eb715c88f7b6a686b5cfde35ebebce0141a32cb6744ce9574
7
- data.tar.gz: 459d0050b81960fef503db0eaaea3cbe5efeeb406d1ac5e2cf673293f6a1e04e147ac61b28634fa9c38bb4ca1d422661713139c1f26ddd115b2c216b8bb709a6
6
+ metadata.gz: d6e663f316c0ae7ac068b367654dab3eabac47ce2ab25d0c4b0a8c8b4fea539fbe4645707995d210b01e81edc850e2a3ad329ba99d64b1c0c722669c65c41a86
7
+ data.tar.gz: 0a9f0a45f3b9d60965a47da5bba1941149f72f6d8102933faecab4f1140f2f64ec8b9d9ad019f864c6faed73eebd63f86d0b6ed38bcc5c8529af2966b23262b0
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Summarise
2
2
 
3
- Summarise is a small gem which extends String, allowing you to create summaries of strings while respecting word boundaries, something I need to do a lot.
3
+ Summarise is a small gem which extends String, allowing you to create summaries of strings and html fragments while respecting word boundaries, something I need to do a lot.
4
4
 
5
5
  ## Usage
6
6
 
@@ -45,6 +45,9 @@ Or install it yourself as:
45
45
 
46
46
  $ gem install summarise
47
47
 
48
+ ## Requires
49
+
50
+ The gem uses Nokogiri to handle html fragments.
48
51
 
49
52
  ## Contributing
50
53
 
@@ -1,13 +1,15 @@
1
+ require "nokogiri"
1
2
 
2
3
  module Summarise
3
4
  module StringExtensions
4
5
  def summarise(l=200, args={})
6
+
5
7
  i = 0
6
- summary = self.split.map{ |word| word if (i += word.length) < l}.compact.join(' ')
8
+ summary = self.split.map{ |word| word if (i += Nokogiri::HTML(word).text.length) < l}.compact.join(' ')
7
9
  if args[:suffix] && self != summary
8
10
  summary << args[:suffix]
9
11
  end
10
- summary
12
+ Nokogiri::HTML::DocumentFragment.parse(summary).to_s
11
13
  end
12
14
 
13
15
  def summarisable?(length=200)
@@ -1,3 +1,3 @@
1
1
  module Summarise
2
- VERSION = "1.0.4"
2
+ VERSION = "1.0.5"
3
3
  end
@@ -21,4 +21,5 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
23
  spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "nokogiri"
24
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: summarise
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Johnson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-03 00:00:00.000000000 Z
11
+ date: 2013-10-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: Adds a methods to allow you to summarise strings
56
70
  email:
57
71
  - nicholas@forwardadvance.com