https://github.com/woodruffw/abbrev.cr
A straightforward port of Ruby's Abbrev to Crystal.
https://github.com/woodruffw/abbrev.cr
abbrev crystal
Last synced: 7 months ago
JSON representation
A straightforward port of Ruby's Abbrev to Crystal.
- Host: GitHub
- URL: https://github.com/woodruffw/abbrev.cr
- Owner: woodruffw
- License: other
- Created: 2018-05-15T00:50:06.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-06-04T01:55:54.000Z (over 5 years ago)
- Last Synced: 2025-03-19T23:06:45.738Z (7 months ago)
- Topics: abbrev, crystal
- Language: Crystal
- Homepage: https://woodruffw.github.io/abbrev.cr/
- Size: 30.3 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
abbrev.cr
=========
[](https://github.com/woodruffw/abbrev.cr/actions?query=workflow%3ACI)A straightforward port of Ruby's
[Abbrev](https://ruby-doc.org/stdlib/libdoc/abbrev/rdoc/Abbrev.html) to Crystal.## Installation
Add this to your application's `shard.yml`:
```yaml
dependencies:
abbrev:
github: woodruffw/abbrev.cr
```## Usage
Usage is nearly identical to Ruby's `Abbrev.abbrev` and `Array#abbrev`, except that the (optional)
`pattern` parameter *has* to be a regular expression:```crystal
require "abbrev"Abbrev.abbrev(%w{crystal})
# => {"crystal" => "crystal", "crysta" => "crystal", "cryst" => "crystal", "crys" => "crystal", "cry" => "crystal", "cr" => "crystal", "c" => "crystal"}Abbrev.abbrev(%w{crystal ruby}, /^r/)
# => {"ruby" => "ruby", "rub" => "ruby", "ru" => "ruby", "r" => "ruby"}%w{crystal is fun}.abbrev
# => {"crystal" => "crystal", "crysta" => "crystal", "cryst" => "crystal", "crys" => "crystal", "cry" => "crystal", "cr" => "crystal", "c" => "crystal", "is" => "is", "i" => "is", "fun" => "fun", "fu" => "fun", "f" => "fun"}
```## Contributing
1. Fork it (https://github.com/woodruffw/abbrev/fork)
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request## Contributors
- [woodruffw](https://github.com/woodruffw) William Woodruff - creator, maintainer