Project

zenify

0.0
No release in over 3 years
Zenify provides a small utility to normalize whitespace in strings, including Japanese full-width spaces.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

Zenify

Zenify is a tiny Ruby utility gem that normalizes whitespace in strings.

It is especially useful when dealing with Japanese text, as it converts full-width spaces (全角スペース) into normal spaces and collapses consecutive whitespace into a single space.

Requirements

  • Ruby 3.2 or later

Compatibility

Zenify is continuously tested against the following Ruby versions via CI:

  • Ruby 3.2
  • Ruby 3.3
  • Ruby 3.4
  • Ruby 4.0
  • This project is tested on Ruby 3.2–4.0 using GitHub Actions.

Installation

Add this line to your application's Gemfile:

gem "zenify"

And then execute:

bundle install

Or install it yourself as:

gem install zenify

Usage

require "zenify"

Zenify.normalize_spaces("  a  b   ")
# => "a b"

Zenify.normalize_spaces(" こんにちは  世界 ")
# => "こんにちは 世界"

CLI

You can also use Zenify from the command line:

zenify "  a  b   "
# => a b

echo "  a  b   " | zenify
# => a b

# trailing spaces preserved
zenify --no-strip "  a  b   "
# =>  a b

zenify --help
zenify --version

Development

After checking out the repo, run:

bin/setup

Then run the tests:

bundle exec rake test

You can also experiment in an interactive console:

bin/console

To install this gem onto your local machine:

bundle exec rake install

Contributing

Bug reports and pull requests are welcome on GitHub:

https://github.com/ryu/zenify

License

The gem is available as open source under the terms of the MIT License.