text_alignment 0.12.3 → 0.12.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 +4 -4
- data/lib/text_alignment/char_mapping.rb +37 -2
- data/lib/text_alignment/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 114903b5eadb97510472440eb492bfd91b382ba7cdb906ad840272f6d7d4252d
|
4
|
+
data.tar.gz: e52f48a1ff2123ce77a9c6f752d0b5dc11cc478f68bd5cbe2dae311d70c31461
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce526f33870d860e7e156bb8b4912641ba66e11d84d38eb75bba4e48c4fe966a0a5d66ae09aded5ceba5303ccac4deaf08595c5fcb0c6cd3e3eba3fbca292806
|
7
|
+
data.tar.gz: 162a088d2656827c4ce74e059cdbdd36b69dd4d92a3da7a42ced4cf5ec173e0e75f8ae4bcbac8d7be65f852bbaf33fb223fbdec09738ef94a9300126d87800e6
|
@@ -78,6 +78,37 @@ TextAlignment::CHAR_MAPPING = [
|
|
78
78
|
['"', "''"]
|
79
79
|
]
|
80
80
|
|
81
|
+
# build a string of every Unicode whitespace codepoint \s covers:
|
82
|
+
_WS_LIST = [
|
83
|
+
"\u0009", # CHARACTER TABULATION
|
84
|
+
"\u000A", # LINE FEED
|
85
|
+
"\u000B", # LINE TABULATION
|
86
|
+
"\u000C", # FORM FEED
|
87
|
+
"\u000D", # CARRIAGE RETURN
|
88
|
+
"\u0020", # SPACE
|
89
|
+
"\u0085", # NEXT LINE
|
90
|
+
"\u00A0", # NO-BREAK SPACE
|
91
|
+
"\u1680", # OGHAM SPACE MARK
|
92
|
+
"\u2000", # EN QUAD
|
93
|
+
"\u2001", # EM QUAD
|
94
|
+
"\u2002", # EN SPACE
|
95
|
+
"\u2003", # EM SPACE
|
96
|
+
"\u2004", # THREE-PER-EM SPACE
|
97
|
+
"\u2005", # FOUR-PER-EM SPACE
|
98
|
+
"\u2006", # SIX-PER-EM SPACE
|
99
|
+
"\u2007", # FIGURE SPACE
|
100
|
+
"\u2008", # PUNCTUATION SPACE
|
101
|
+
"\u2009", # THIN SPACE
|
102
|
+
"\u200A", # HAIR SPACE
|
103
|
+
"\u2028", # LINE SEPARATOR
|
104
|
+
"\u2029", # PARAGRAPH SEPARATOR
|
105
|
+
"\u202F", # NARROW NO-BREAK SPACE
|
106
|
+
"\u205F", # MEDIUM MATHEMATICAL SPACE
|
107
|
+
"\u3000", # IDEOGRAPHIC SPACE
|
108
|
+
].freeze
|
109
|
+
|
110
|
+
ALL_WS = _WS_LIST.join.freeze
|
111
|
+
Ractor.make_shareable(ALL_WS)
|
81
112
|
|
82
113
|
class TextAlignment::CharMapping
|
83
114
|
attr_reader :mapped_text, :index_enmap
|
@@ -197,11 +228,15 @@ class TextAlignment::CharMapping
|
|
197
228
|
end
|
198
229
|
|
199
230
|
def squeeze_ws_1!(text)
|
200
|
-
text.gsub!(/\s{2,}/, ' ')
|
231
|
+
# Below should have (almost) the same semantics as text.gsub!(/\s{2,}/, ' ')
|
232
|
+
non_space_ws = ALL_WS.delete(" ")
|
233
|
+
text.tr!(non_space_ws, " ")
|
234
|
+
text.squeeze!(" ")
|
201
235
|
end
|
202
236
|
|
203
237
|
def squeeze_ws_0!(text)
|
204
|
-
text.gsub!(/\s+/, '')
|
238
|
+
# Below should have the same semantics as text.gsub!(/\s+/, '')
|
239
|
+
text.delete!(ALL_WS)
|
205
240
|
end
|
206
241
|
|
207
242
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: text_alignment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jin-Dong Kim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-dictionary
|
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: '0'
|
113
113
|
requirements: []
|
114
|
-
rubygems_version: 3.4.
|
114
|
+
rubygems_version: 3.4.10
|
115
115
|
signing_key:
|
116
116
|
specification_version: 4
|
117
117
|
summary: Ruby class for aligning two character strings
|