abbreviato 0.8.1 → 0.8.2
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/LICENSE.txt +2 -1
- data/README.md +7 -13
- data/Rakefile +42 -5
- data/lib/abbreviato/abbreviato.rb +1 -1
- data/lib/abbreviato/version.rb +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db961048425e97e79397a25ade5a974319ec2d9d
|
4
|
+
data.tar.gz: ef5486da63241687f0a08c63a3cc3d9eabb1d24f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5abf874a00105f77ed88ed13c024086c9610dbc9a3a8a74026a29b8f893d21bdc2d1402cbc9008e54753ccc31e1d1ce101a6d9d065a08d11de23a34de7c53ce
|
7
|
+
data.tar.gz: a6b6dc93413665a20ca3969ec5023d05e80d99944fffd37472782dfa204467310dcbf514182753f9a1f7581189f67f6d130767c8471cb5752e7b0c8afa273ecd
|
data/LICENSE.txt
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
Copyright (c) 2011 Jorge Manrubia
|
1
|
+
Original work Copyright (c) 2011 Jorge Manrubia
|
2
|
+
Modified work Copyright (c) 2017 Zendesk, Inc.
|
2
3
|
|
3
4
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
5
|
a copy of this software and associated documentation files (the
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[](https://travis-ci.org/zendesk/abbreviato)
|
2
|
+
|
1
3
|
# abbreviato
|
2
4
|
|
3
5
|
*abbreviato* is a Ruby library for truncating HTML strings keeping the markup valid. It is a fork of github.com/jorgemanrubia/truncato but focused on truncating to a bytesize, not on a per-character basis.
|
@@ -20,10 +22,8 @@ The configuration options are:
|
|
20
22
|
|
21
23
|
* `max_length`: The size, in bytes, to truncate (`30` by default)
|
22
24
|
* `tail`: The string to append when the truncation occurs ('…' by default).
|
23
|
-
|
24
|
-
|
25
|
-
# addition of these tags if they are missing. Defaults to `true`.
|
26
|
-
|
25
|
+
* `fragment`: Indicates whether the document to be truncated is an HTML fragment or an entire document (with `HTML`, `HEAD` & `BODY` tags). Setting to true prevents automatic
|
26
|
+
addition of these tags if they are missing. Defaults to `true`.
|
27
27
|
|
28
28
|
## Performance
|
29
29
|
|
@@ -43,19 +43,13 @@ bundle exec wwtd
|
|
43
43
|
|
44
44
|
## Updating
|
45
45
|
|
46
|
-
Update the version
|
47
46
|
```ruby
|
47
|
+
# Update the version
|
48
48
|
bundle exec bump patch
|
49
|
-
```
|
50
49
|
|
51
|
-
Build
|
52
|
-
```ruby
|
50
|
+
# Build
|
53
51
|
gem build abbreviato.gemspec
|
54
52
|
|
55
|
-
Publish
|
56
|
-
```ruby
|
53
|
+
# Publish
|
57
54
|
gem push abbreviato-x.y.z.gem
|
58
55
|
```
|
59
|
-
|
60
|
-
|
61
|
-
|
data/Rakefile
CHANGED
@@ -1,17 +1,54 @@
|
|
1
|
+
require 'bundler/setup'
|
1
2
|
require 'wwtd/tasks'
|
2
3
|
require 'bundler/gem_tasks'
|
3
4
|
require 'bump/tasks'
|
4
|
-
require 'bundler/setup'
|
5
5
|
|
6
6
|
Bundler::GemHelper.install_tasks
|
7
7
|
|
8
8
|
require 'rspec/core/rake_task'
|
9
9
|
RSpec::Core::RakeTask.new(:spec)
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
if %w[development test].include?(ENV["RAILS_ENV"] ||= 'development')
|
12
|
+
def run_command(command)
|
13
|
+
result = `#{command}`
|
14
|
+
result.force_encoding('binary')
|
15
|
+
raise "Command #{command} failed: #{result}" unless $?.success?
|
16
|
+
result
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'bundler/audit/task'
|
20
|
+
Bundler::Audit::Task.new
|
21
|
+
|
22
|
+
desc "Analyze for code duplication (large, identical syntax trees) with fuzzy matching."
|
23
|
+
task :flay do
|
24
|
+
require 'flay'
|
25
|
+
flay = Flay.run(%w[bin config lib script])
|
26
|
+
flay.report
|
27
|
+
|
28
|
+
threshold = 0
|
29
|
+
raise "Flay total too high! #{flay.total} > #{threshold}" if flay.total > threshold
|
30
|
+
end
|
31
|
+
|
32
|
+
require 'rubocop/rake_task'
|
33
|
+
RuboCop::RakeTask.new
|
34
|
+
|
35
|
+
task :brakecheck do
|
36
|
+
puts "Running brakecheck..."
|
37
|
+
%w[brakecheck brakeman bundler-audit flay rubocop].each do |gem_name|
|
38
|
+
result = `brakecheck #{gem_name}`
|
39
|
+
result.force_encoding('binary')
|
40
|
+
if $?.success?
|
41
|
+
puts "✔ #{gem_name}"
|
42
|
+
else
|
43
|
+
raise "✘ #{gem_name}'s brakecheck failed: #{result}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
true
|
47
|
+
end
|
13
48
|
|
14
|
-
|
15
|
-
|
49
|
+
task :brakeman do
|
50
|
+
run_command "brakeman --exit-on-warn --exit-on-err --format plain --ensure-latest --table-width 999 --force-scan lib --ignore-config .brakeman.ignore"
|
51
|
+
end
|
52
|
+
end
|
16
53
|
|
17
54
|
task default: :wwtd
|
@@ -22,6 +22,6 @@ module Abbreviato
|
|
22
22
|
truncated_sax_document = TruncatedSaxDocument.new(DEFAULT_OPTIONS.merge(user_options))
|
23
23
|
parser = Nokogiri::HTML::SAX::Parser.new(truncated_sax_document)
|
24
24
|
parser.parse(source) { |context| context.replace_entities = false }
|
25
|
-
[truncated_sax_document.truncated_string, truncated_sax_document.truncated]
|
25
|
+
[truncated_sax_document.truncated_string.strip, truncated_sax_document.truncated]
|
26
26
|
end
|
27
27
|
end
|
data/lib/abbreviato/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abbreviato
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jorge Manrubia
|
@@ -11,33 +11,33 @@ cert_chain: []
|
|
11
11
|
date: 2013-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: htmlentities
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 4.3.4
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 4.3.4
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: nokogiri
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 1.8.1
|
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:
|
40
|
+
version: 1.8.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: awesome_print
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -255,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
255
255
|
version: '0'
|
256
256
|
requirements: []
|
257
257
|
rubyforge_project:
|
258
|
-
rubygems_version: 2.
|
258
|
+
rubygems_version: 2.6.11
|
259
259
|
signing_key:
|
260
260
|
specification_version: 4
|
261
261
|
summary: A tool for efficiently truncating HTML strings to a specific bytesize
|