law_string 1.1.0 → 1.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/.gitignore +1 -0
- data/.rspec +0 -1
- data/.travis.yml +0 -1
- data/Gemfile.lock +21 -14
- data/README.md +4 -3
- data/law_string.gemspec +11 -11
- data/lib/law_string.rb +10 -5
- metadata +17 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ea200f0e77915f4e4ac7e20013731cb64224c017c48b73ca6287943d2b5d372
|
4
|
+
data.tar.gz: f46191e76441e1d05b4643f026395151c7d39b42243c5f125c1d25f5d313837d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b5e6944a4cb85927bee3d9cc772ea3a541123b48fa3fec0f097ccdcc480810c2561949d8a5ae74612d8bea05de2c71093be892179974556e1eaa709d34adeb9
|
7
|
+
data.tar.gz: 4ef6701fe230b1ef645204b0788f9cf5c3ee6c9270d8ffa0c3e950fd47485214bc4399f8a54aaf40e452a7f793c4522aa7e2a22b22ece31d7eca05daf7871211
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,35 +1,42 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
law_string (1.
|
4
|
+
law_string (1.2.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
diff-lcs (1.3)
|
10
|
+
docile (1.3.1)
|
11
|
+
json (2.1.0)
|
10
12
|
rake (10.5.0)
|
11
|
-
rspec (3.
|
12
|
-
rspec-core (~> 3.
|
13
|
-
rspec-expectations (~> 3.
|
14
|
-
rspec-mocks (~> 3.
|
15
|
-
rspec-core (3.
|
16
|
-
rspec-support (~> 3.
|
17
|
-
rspec-expectations (3.
|
13
|
+
rspec (3.8.0)
|
14
|
+
rspec-core (~> 3.8.0)
|
15
|
+
rspec-expectations (~> 3.8.0)
|
16
|
+
rspec-mocks (~> 3.8.0)
|
17
|
+
rspec-core (3.8.0)
|
18
|
+
rspec-support (~> 3.8.0)
|
19
|
+
rspec-expectations (3.8.1)
|
18
20
|
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
-
rspec-support (~> 3.
|
20
|
-
rspec-mocks (3.
|
21
|
+
rspec-support (~> 3.8.0)
|
22
|
+
rspec-mocks (3.8.0)
|
21
23
|
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
-
rspec-support (~> 3.
|
23
|
-
rspec-support (3.
|
24
|
+
rspec-support (~> 3.8.0)
|
25
|
+
rspec-support (3.8.0)
|
26
|
+
simplecov (0.16.1)
|
27
|
+
docile (~> 1.1)
|
28
|
+
json (>= 1.8, < 3)
|
29
|
+
simplecov-html (~> 0.10.0)
|
30
|
+
simplecov-html (0.10.2)
|
24
31
|
|
25
32
|
PLATFORMS
|
26
33
|
ruby
|
27
34
|
|
28
35
|
DEPENDENCIES
|
29
|
-
bundler (~> 1.16)
|
30
36
|
law_string!
|
31
37
|
rake (~> 10.0)
|
32
38
|
rspec (~> 3.0)
|
39
|
+
simplecov
|
33
40
|
|
34
41
|
BUNDLED WITH
|
35
|
-
1.
|
42
|
+
2.1.4
|
data/README.md
CHANGED
@@ -26,7 +26,8 @@ Or install it yourself as:
|
|
26
26
|
Provides;
|
27
27
|
|
28
28
|
* `#add_typograpy` e.g., changing ASCII quotes to true double quotes
|
29
|
-
* `#
|
30
|
-
* `#initials
|
29
|
+
* `#initialism?` to detect, e.g., "ATM". Very rudimentary.
|
30
|
+
* `#initials?` to detect, e.g., "A.S.C.A.P."
|
31
|
+
* `#titleize` enhanced for English-language legal texts, coded to reduce memory allocations.
|
31
32
|
|
32
|
-
See the tests for details.
|
33
|
+
See [the tests](https://github.com/public-law/law_string/blob/master/spec/law_string_spec.rb) for details.
|
data/law_string.gemspec
CHANGED
@@ -4,24 +4,24 @@ lib = File.expand_path('lib', __dir__)
|
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
-
spec.version = '1.
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
7
|
+
spec.name = 'law_string'
|
8
|
+
spec.version = '1.2.0'
|
9
|
+
spec.authors = ['Robb Shecter']
|
10
|
+
spec.email = ['robb@public.law']
|
11
11
|
|
12
12
|
spec.summary = 'String Utils including a specialized #titleize.'
|
13
13
|
spec.description = 'A set of utils narrowly written to support Public.Law. Focus on reducing object instantation at the cost of readability.'
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
14
|
+
spec.homepage = 'https://github.com/public-law/law_string'
|
15
|
+
spec.license = 'MIT'
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
18
|
f.match(%r{^(test|spec|features)/})
|
19
19
|
end
|
20
|
-
spec.bindir =
|
20
|
+
spec.bindir = 'exe'
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
-
spec.require_paths = [
|
22
|
+
spec.require_paths = ['lib']
|
23
23
|
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
24
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
26
|
+
spec.add_development_dependency 'simplecov'
|
27
27
|
end
|
data/lib/law_string.rb
CHANGED
@@ -9,8 +9,8 @@ class String
|
|
9
9
|
NOT_CAPITALIZED = Set.new %w[a an and at but by for in nor of on or out so the to up yet].freeze
|
10
10
|
INITIALISMS = Set.new %w[atm].freeze
|
11
11
|
|
12
|
-
INITIALS_REGEX = /^([a-zA-Z]\.)
|
13
|
-
WHITESPACES_REGEX = /[[:space:]]
|
12
|
+
INITIALS_REGEX = /^([a-zA-Z]\.)+$/.freeze
|
13
|
+
WHITESPACES_REGEX = /[[:space:]]/.freeze
|
14
14
|
|
15
15
|
def in?(an_array)
|
16
16
|
an_array.include?(self)
|
@@ -37,7 +37,7 @@ class String
|
|
37
37
|
# rules. It's coded to reduce object allocation.
|
38
38
|
#
|
39
39
|
def titleize
|
40
|
-
new_string =
|
40
|
+
new_string = clone(freeze: false)
|
41
41
|
|
42
42
|
new_string.tr!('_', ' ')
|
43
43
|
final_string = new_string.split(WHITESPACES_REGEX)
|
@@ -83,7 +83,7 @@ class String
|
|
83
83
|
end
|
84
84
|
|
85
85
|
#
|
86
|
-
# Return a new string enhanced with typographic characters:
|
86
|
+
# Return a new string enhanced with UTF-8 typographic characters:
|
87
87
|
# Single quotes: ’
|
88
88
|
# Section sign: §
|
89
89
|
# Double quotes: “”
|
@@ -94,6 +94,10 @@ class String
|
|
94
94
|
.gsub(/"([^"]+)"/, '“\1”')
|
95
95
|
end
|
96
96
|
|
97
|
+
def add_html_typography
|
98
|
+
gsub(%r{\b(\d+)/(\d+)\b}, '<sup>\1</sup>⁄<sub>\2</sub>')
|
99
|
+
end
|
100
|
+
|
97
101
|
#
|
98
102
|
# Take text with potential encoding problems and
|
99
103
|
# aggressively make it safe for UTF-8 import.
|
@@ -105,13 +109,14 @@ class String
|
|
105
109
|
def capitalize_first_letter
|
106
110
|
return '' if self == ''
|
107
111
|
|
108
|
-
new_string =
|
112
|
+
new_string = clone(freeze: false)
|
109
113
|
new_string.capitalize_first_letter!
|
110
114
|
new_string
|
111
115
|
end
|
112
116
|
|
113
117
|
def capitalize_first_letter!
|
114
118
|
return self if self == ''
|
119
|
+
|
115
120
|
self[0] = self[0].upcase
|
116
121
|
end
|
117
122
|
end
|
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: law_string
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robb Shecter
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '10.0'
|
20
20
|
type: :development
|
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: '10.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '3.0'
|
34
34
|
type: :development
|
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: '3.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: simplecov
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
description: A set of utils narrowly written to support Public.Law. Focus on reducing
|
56
56
|
object instantation at the cost of readability.
|
57
57
|
email:
|
@@ -76,7 +76,7 @@ homepage: https://github.com/public-law/law_string
|
|
76
76
|
licenses:
|
77
77
|
- MIT
|
78
78
|
metadata: {}
|
79
|
-
post_install_message:
|
79
|
+
post_install_message:
|
80
80
|
rdoc_options: []
|
81
81
|
require_paths:
|
82
82
|
- lib
|
@@ -91,9 +91,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: '0'
|
93
93
|
requirements: []
|
94
|
-
|
95
|
-
|
96
|
-
signing_key:
|
94
|
+
rubygems_version: 3.1.4
|
95
|
+
signing_key:
|
97
96
|
specification_version: 4
|
98
97
|
summary: 'String Utils including a specialized #titleize.'
|
99
98
|
test_files: []
|