Code Monkey home page Code Monkey logo

dry-inflector.cr's Introduction

Inflector (port of dry-inflector) Build Status

This is an attempt to bring Dry::Inflector Inflector](https://github.com/dry-rb/ry-inflector) to Crystal.

Installation

Add this to your application's shard.yml:

dependencies:
    inflector:
    github: dsisnero/dry-inflector.cr
    version: "~> 0.1.8"

Somewhere in your app initialization, require "dry-inflector".

Inflector.cr passes specs with Crystal versions starting at 0.17.4 and continuing through 0.24.2.

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 = Dry::Inflector.new
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_ey("Message")                      # => "message_id"
inflector.ordinalize(1)                               # => "1st"
inflector.ordinal(1)                                  # => "st"
inflector.dasherize("puni_puni")                      # => "puni-puni"

TODO

  • Enable additional tests (tests have been mostly ported from ActiveSupport::Inflector)
  • Hook up Travis CI

Contributing

  1. Fork it ( https://github.com/dsisnero/dry-inflector.cr/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

  • dry-rb Dry-Rb Core Team is greatly appreciated for what they have built and extensive documentation
  • dsisnero Paul Hoffer - creator, maintainer

License

See LICENSE file.

dry-inflector.cr's People

Contributors

dsisnero avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.