Finishing Moves
Ruby includes a huge amount of default awesomeness that tackles most common development challenges. But every now and then, you find yourself performing contortions to achieve results that, honestly, should feel more natural given the language's design elegance. Finishing Moves is a collection of methods designed to assist in those "why is this awkward?" scenarios.
In the right situation, they kick serious cyclomatic butt.
Installation
Gemfile
gem 'finishing_moves'
Command line
gem install 'finishing_moves'
Documentation
Not sure if this gem is for you? Check out the methods marked with a 💥 first.
-
Array#to_hash_values
💥 Array#to_indexed_hash
Array#to_hash_keys
Array#to_sym_strict
Array#to_sym_loose
-
Enumerable#key_map
💥 Enumerable#key_map_reduce
Hash#delete!
Hash#delete_each
Hash#delete_each!
Integer#length
-
Kernel#nil_chain
💥💥 Kernel#bool_chain
Kernel#silently
Kernel#cascade
Kernel#class_exists?
Numeric#add_percent
Numeric#subtract_percent
Object#same_as
Object#not_nil?
-
Object#numeric?
💥 Object#is_an?
Object#is_not_a?
-
Object#is_one_of?
💥 Object#true?
Object#false?
Object#bool?
Object#true_?
Object#false_?
String#dedupe
String#keyify
String#slugify
String#match?
String#nl2br
String#newline_to
String#remove_whitespace
String#replace_whitespace
-
String#strip_all
💥 String#to_uuid
- Boolean Typecasting (multi-class enhancement)
Ruby Version
Tested against all supported versions of official RVM, currently 2.7.6
and above.
Development approach
- Never override default Ruby behavior, only add functionality.
- Follow the Unix philosophy of "Do one job really well."
- Minimize assumptions, e.g. avoid formatting output, mutating values, and conditional logic flows.
- Play nice with major Ruby players like Rake, Rails, and Sinatra.
- Test all the things.
Bug Reports
Drop us a line in the issues section.
Be sure to include sample code that reproduces the problem.
Add your own finisher!
- Fork this repo
- Write your tests
- Add your finisher
- Repeat steps 2 and 3 until you see a brilliant luster
- Submit a pull request