abbreviato 3.1.1 → 3.2.0
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 +4 -4
- data/lib/abbreviato/abbreviato.rb +3 -2
- data/lib/abbreviato/truncated_sax_document.rb +1 -1
- data/lib/abbreviato/version.rb +1 -1
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd6ea1c1918b8910699157f37c1b2022ca99ebe7e72ec6e782608b9d1bf8807b
|
4
|
+
data.tar.gz: 90debdd65f86cbbd4218d9f63e3d51d715e3c0bc7cf5e964ed2a7d0d4df57b24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '039ddca1020918731dfdd278d5776485bbd74d83fd65686eacc54644f9006abfd4fd6b0a691bb1b5ad1e6284ac351ceb5a6707ffb4b0ee1189c6899987644723'
|
7
|
+
data.tar.gz: 80b3abb3c2adc7349d566e5bb5c2f755325c58b0926fbdb831e36db769085e1cb9912a1ca9bc8730ed881b66638a4e309546d5bcae049cbef8baf20688489ca2
|
@@ -22,11 +22,12 @@ module Abbreviato
|
|
22
22
|
# or an entire document (with `HTML`, `HEAD` & `BODY` tags). Setting to true prevents automatic addition of
|
23
23
|
# these tags if they are missing. Defaults to `true`.
|
24
24
|
# @return [[String] the truncated string, [boolean] whether the string was truncated]
|
25
|
-
def self.truncate(source = '', user_options = {})
|
25
|
+
def self.truncate(source = '', user_options = {}, encoding = 'UTF-8')
|
26
26
|
return [nil, false] if source.nil?
|
27
|
+
return ['', false] if source.blank?
|
27
28
|
|
28
29
|
truncated_sax_document = TruncatedSaxDocument.new(DEFAULT_OPTIONS.merge(user_options))
|
29
|
-
parser = Nokogiri::HTML::SAX::Parser.new(truncated_sax_document)
|
30
|
+
parser = Nokogiri::HTML::SAX::Parser.new(truncated_sax_document, encoding)
|
30
31
|
parser.parse(source) { |context| context.replace_entities = false }
|
31
32
|
|
32
33
|
if truncated_sax_document.truncated && user_options[:truncate_incomplete_row]
|
@@ -160,7 +160,7 @@ class TruncatedSaxDocument < Nokogiri::XML::SAX::Document
|
|
160
160
|
|
161
161
|
def append_to_truncated_string(string, overridden_length = nil)
|
162
162
|
@truncated_string << string
|
163
|
-
@estimated_length +=
|
163
|
+
@estimated_length += overridden_length || string.bytesize
|
164
164
|
end
|
165
165
|
|
166
166
|
def attributes_to_string(attributes)
|
data/lib/abbreviato/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abbreviato
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jorge Manrubia
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: htmlentities
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: '1.18'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.
|
40
|
+
version: '1.18'
|
41
41
|
description: Truncate HTML to a specific bytesize, while keeping valid markup
|
42
42
|
email: jorge.manrubia@gmail.com
|
43
43
|
executables: []
|
@@ -57,7 +57,7 @@ homepage: https://github.com/zendesk/abbreviato
|
|
57
57
|
licenses:
|
58
58
|
- MIT
|
59
59
|
metadata: {}
|
60
|
-
post_install_message:
|
60
|
+
post_install_message:
|
61
61
|
rdoc_options: []
|
62
62
|
require_paths:
|
63
63
|
- lib
|
@@ -65,15 +65,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 3.
|
68
|
+
version: '3.1'
|
69
69
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
70
|
requirements:
|
71
71
|
- - ">="
|
72
72
|
- !ruby/object:Gem::Version
|
73
73
|
version: '0'
|
74
74
|
requirements: []
|
75
|
-
rubygems_version: 3.5.
|
76
|
-
signing_key:
|
75
|
+
rubygems_version: 3.5.22
|
76
|
+
signing_key:
|
77
77
|
specification_version: 4
|
78
78
|
summary: A tool for efficiently truncating HTML strings to a specific bytesize
|
79
79
|
test_files: []
|