zenify 0.1.1 → 0.1.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/CHANGELOG.md +25 -4
- data/exe/zenify +14 -10
- data/lib/zenify/version.rb +1 -1
- data/lib/zenify.rb +8 -6
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 81b6543553f12e699d66998f92b667e5caa3d295cddd6e314d26335049cbe3f0
|
|
4
|
+
data.tar.gz: 7a504fc73c7426b0bbbe3715e41e4e1ae660bbfe4b47472b3038912e31eb3b46
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b0862fe27ad12c052ae0a83ce3fe0417bdf1dad3d0c4f9832c19e9c43d42ef465daaee4b78f6c48aeccf8d509afa6ce26880f8de97258c889b371e801ae5f9e6
|
|
7
|
+
data.tar.gz: d6cef2751234cab7d4bb3344075aab90cd4b47b73023357a9b69529383c5eee5cf7ae9d7d0f06831aa8cc34d0c7bcd40b7cf6e36980350cd810ebba5eb07465e
|
data/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## [0.1.2] - 2026-01-24
|
|
11
|
+
### Added
|
|
12
|
+
- CLI option `--no-strip` to preserve leading and trailing spaces.
|
|
13
|
+
- Library API enhancement: `Zenify.normalize_spaces` now accepts `strip:` keyword argument.
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
- CLI help text updated to document the new option.
|
|
17
|
+
|
|
18
|
+
---
|
|
2
19
|
|
|
3
20
|
## [0.1.1] - 2026-01-24
|
|
4
21
|
### Added
|
|
5
|
-
-
|
|
22
|
+
- Command-line interface (`zenify`) for normalizing whitespace.
|
|
23
|
+
- CLI options `--help` and `--version`.
|
|
6
24
|
|
|
7
|
-
|
|
25
|
+
---
|
|
8
26
|
|
|
9
|
-
-
|
|
27
|
+
## [0.1.0] - 2026-01-24
|
|
28
|
+
### Added
|
|
29
|
+
- Initial release.
|
|
30
|
+
- `Zenify.normalize_spaces` for normalizing whitespace, including Japanese full-width spaces.
|
data/exe/zenify
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
require "zenify"
|
|
5
5
|
|
|
6
|
+
no_strip = ARGV.delete("--no-strip")
|
|
7
|
+
|
|
6
8
|
if ARGV.include?("--version") || ARGV.include?("-v")
|
|
7
9
|
puts Zenify::VERSION
|
|
8
10
|
exit 0
|
|
@@ -11,20 +13,22 @@ end
|
|
|
11
13
|
if ARGV.include?("--help") || ARGV.include?("-h")
|
|
12
14
|
puts <<~HELP
|
|
13
15
|
Usage:
|
|
14
|
-
zenify "TEXT"
|
|
15
|
-
echo "TEXT" | zenify
|
|
16
|
+
zenify [options] "TEXT"
|
|
17
|
+
echo "TEXT" | zenify [options]
|
|
16
18
|
|
|
17
19
|
Options:
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
+
--no-strip Do not strip leading/trailing spaces
|
|
21
|
+
-h, --help Show help
|
|
22
|
+
-v, --version Show version
|
|
20
23
|
HELP
|
|
21
24
|
exit 0
|
|
22
25
|
end
|
|
23
26
|
|
|
24
|
-
input =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
input =
|
|
28
|
+
if ARGV.empty?
|
|
29
|
+
$stdin.read
|
|
30
|
+
else
|
|
31
|
+
ARGV.join(" ")
|
|
32
|
+
end
|
|
29
33
|
|
|
30
|
-
puts Zenify.normalize_spaces(input)
|
|
34
|
+
puts Zenify.normalize_spaces(input, strip: !no_strip)
|
data/lib/zenify/version.rb
CHANGED
data/lib/zenify.rb
CHANGED
|
@@ -9,11 +9,13 @@ module Zenify
|
|
|
9
9
|
# Normalize whitespace in a string:
|
|
10
10
|
# - Convert Japanese full-width spaces to normal spaces
|
|
11
11
|
# - Collapse consecutive spaces/tabs into a single space
|
|
12
|
-
# -
|
|
13
|
-
def self.normalize_spaces(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
# - Optionally trim leading/trailing spaces (default: true)
|
|
13
|
+
def self.normalize_spaces(str, strip: true)
|
|
14
|
+
result =
|
|
15
|
+
str.to_s
|
|
16
|
+
.tr("\u3000", " ") # Convert full-width spaces to normal spaces
|
|
17
|
+
.gsub(/[ \t]+/, " ") # Collapse consecutive spaces/tabs into a single space
|
|
18
|
+
|
|
19
|
+
strip ? result.strip : result
|
|
18
20
|
end
|
|
19
21
|
end
|