demojify
A Ruby gem to convert all emoji in script files to ASCII-friendly text representations in the format [emoji_name].
Installation
Install the gem:
gem install demojifyOr add it to your Gemfile:
gem 'demojify'Usage
Command Line
Convert emoji in all script files in the current directory and subdirectories:
demojifyConvert emoji in a specific directory:
demojify /path/to/projectPreview changes without modifying files (dry-run mode):
demojify --dry-runShow help:
demojify --helpIn Ruby Code
require 'demojify'
# Convert emoji in text
text = "Hello 😀 World 🚀"
result = Demojify::Converter.convert(text)
# => "Hello [grinning] World [rocket]"
# Process files in a directory
processor = Demojify::Processor.new(root_dir: ".", dry_run: false)
result = processor.process!
# => { total: 10, changed: 3 }Supported File Types
The gem processes the following script file types:
- Ruby (
.rb) - Python (
.py) - JavaScript (
.js,.jsx) - TypeScript (
.ts,.tsx) - Shell scripts (
.sh,.bash,.zsh) - Perl (
.pl) - PHP (
.php) - Java (
.java) - C/C++ (
.c,.cpp,.h,.hpp) - Go (
.go) - Rust (
.rs)
How It Works
The gem:
- Recursively scans the specified directory for script files
- Reads each file and detects emoji characters
- Converts emoji to their text representation:
😀→[grinning] - Writes the modified content back to the file (unless in dry-run mode)
Development
After checking out the repo, run bundle install to install dependencies. Then, run bundle exec rspec to run the tests.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/stringsn88keys/demojify.
License
The gem is available as open source under the terms of the MIT License.