text_alignment 0.12.3 → 0.12.4
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 +34 -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: ef51eeed4c82f3ddc211a1474a35c8b61a621ed7acb6bd801a62885c2c342448
|
4
|
+
data.tar.gz: 15b1d020f78a96e152459324d921092c5bd39477f856417fd30e4283d22399ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 473a18002d40bf3db81e0f42ffe3fbcc3ff5b1281964c2d5391a57b34ff07ff973ca86e5fe34dcbe2537410b46105e05a60772ffc27ed6667443062558201952
|
7
|
+
data.tar.gz: a8ddf9b9a2bd19b1e7303fcdf83fd862bbe8b601f2de88aa59c5d51b5a7184a0ee00fde86877390267ffd3cf8619c6a52bffabd9cb5b95be4ab34d20f81e1fab
|
@@ -78,6 +78,34 @@ TextAlignment::CHAR_MAPPING = [
|
|
78
78
|
['"', "''"]
|
79
79
|
]
|
80
80
|
|
81
|
+
# build a string of every Unicode whitespace codepoint \s covers:
|
82
|
+
ALL_WS = [
|
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
|
+
].join
|
81
109
|
|
82
110
|
class TextAlignment::CharMapping
|
83
111
|
attr_reader :mapped_text, :index_enmap
|
@@ -197,11 +225,15 @@ class TextAlignment::CharMapping
|
|
197
225
|
end
|
198
226
|
|
199
227
|
def squeeze_ws_1!(text)
|
200
|
-
text.gsub!(/\s{2,}/, ' ')
|
228
|
+
# Below should have (almost) the same semantics as text.gsub!(/\s{2,}/, ' ')
|
229
|
+
non_space_ws = ALL_WS.delete(" ")
|
230
|
+
text.tr!(non_space_ws, " ")
|
231
|
+
text.squeeze!(" ")
|
201
232
|
end
|
202
233
|
|
203
234
|
def squeeze_ws_0!(text)
|
204
|
-
text.gsub!(/\s+/, '')
|
235
|
+
# Below should have the same semantics as text.gsub!(/\s+/, '')
|
236
|
+
text.delete!(ALL_WS)
|
205
237
|
end
|
206
238
|
|
207
239
|
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.4
|
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
|