inflector
Version, currently 0.1.69 versions
github.com/anykeyh/inflector.cr
String inflectors for Crystal, ported from ActiveSupport (Rails) Inflector functionality.
Nothing has been indexed for 0.1.6 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
inflector:
github: anykeyh/inflector.cr
version: ~> 0.1.6Then run:
shards installshard.yml
No shard.yml has been indexed for 0.1.6. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
Inflector (port of ActiveSupport::Inflector) 
This is an attempt to bring ActiveSupport's Inflector to Crystal. It started as a test idea for another project (Native Ruby extensions in Crystal), but then worked well enough that I decided to turn it into its own project.
Installation
Add this to your application's shard.yml:
dependencies:
inflector:
github: phoffer/inflector.cr
version: "~> 0.1.8"
Somewhere in your app initialization, require "inflector".
Inflector.cr passes specs with Crystal versions 0.17.4, 0.18.7, 0.19.2, 0.20.0, and 0.21.0 (current).
Additionally, there are core extensions to String and Int. If you want these, then require "inflector/core_ext instead of the standard require.
Usage
Some examples are probably best. There is a full set of examples in spec/inflector/readme_spec.cr
Inflector.camelize("active_model") # => "ActiveModel"
Inflector.underscore("ActiveModel") # => "active_model"
Inflector.humanize("employee_salary") # => "Employee salary"
Inflector.humanize("author_id") # => "Author"
Inflector.upcase_first("what a Lovely Day") # => "What a Lovely Day"
Inflector.titleize("x-men: the last stand") # => "X Men: The Last Stand"
Inflector.classify("ham_and_eggs") # => "HamAndEgg"
Inflector.demodulize("CoreExt::String::Inflections") # => "Inflections"
Inflector.deconstantize("Net::HTTP") # => "Net"
Inflector.foreign_key("Message") # => "message_id"
Inflector.ordinalize(1) # => "1st"
Inflector.ordinal(1) # => "st"
Inflector.dasherize("puni_puni") # => "puni-puni"
Additionally, these are available if you required the core extensions. Additional examples are in spec/inflector/core_ext_spec
1.ordinalize # => "1st"
1.ordinal # => "st"
"post".pluralize # => "posts"
"octopus".pluralize # => "octopi"
"posts".singularize # => "post"
"active_record".camelize # => "ActiveRecord"
"man from the boondocks".titleize # => "Man From The Boondocks"
"CoreExt::String::Inflections".demodulize # => "Inflections"
"Net::HTTP".deconstantize # => "Net"
"fancyCategory".tableize # => "fancy_categories"
"ham_and_eggs".classify # => "HamAndEgg"
"employee_salary".humanize # => "Employee salary"
"what a Lovely Day".upcase_first # => "What a Lovely Day"
"Message".foreign_key # => "message_id"
TODO
- [ ] Enable additional tests (tests have been mostly ported from ActiveSupport::Inflector)
- [x] Hook up Travis CI
Contributing
- Fork it ( https://github.com/phoffer/inflector.cr/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.6- Tagged
- Mar 27, 2021
- Commit
2e642742ec0d- Indexed
- not yet
Dependents
No indexed shard depends on this one yet.
Repository
github.com/anykeyh/inflector.cr
Metadata
- Created
- Aug 16, 2026
- Updated
- Aug 16, 2026
- Synced
- Aug 16, 2026
- Versions
- 9