Gorilla Patch
Ruby Gem for refine Ruby Core classes (like Monkey patch).
Installation
$ gem install gorilla_patch
or with bundler
:
# Gemfile
gem 'gorilla_patch'
Usage
require 'gorilla_patch' # or 'gorilla_patch/keys' for specific functionallity
hash = { a: 1, b: 2 }
hash.keys? :a, :b # undefined method!
module Foo
using GorillaPatch::Keys
hash.keys? :a, :b # true
end
hash.keys? :a, :b # undefined method!
What is using
?
What if a method was implemented in new Ruby versions?
Then native method in usage, not a custom implementation.
For example, Hash#except
.
Before custom method declaration there is a check for current Ruby version.
Methods
-
Blank
-
String
,NilClass
#blank?
-
Array
,Hash
-
#reject_blank_strings
-
#reject_blank_strings!
-
#nilify_blank_strings
-
#nilify_blank_strings!
-
-
-
Compact
-
Hash
-
#compact
-
#compact!
-
-
-
DeepDup
-
Object
,Hash
,Array
,Module
,Delegator
#deep_dup
-
-
DeepMerge
-
Hash
-
#deep_merge(other_hash, &block)
-
#deep_merge!(other_hash, &block)
-
-
-
DigEmpty
-
Hash
#dig()
-
-
Except
-
Hash
-
#except(*)
-
#except!(*)
-
-
-
Inflections
-
.acronyms
-
.from_sequel
-
.from_dry_inflector
-
String
,Module
#underscore
-
String
#camelize
-
-
Keys
-
Hash
#keys?(*)
-
-
ModuleParent
-
Module
-
#module_parent_name
-
#module_parent
-
-
-
Namespace
-
String
,Module
,Class
-
#demodulize
-
#deconstantize
-
-
-
Slice
-
Hash
-
#slice(*, nils: false)
-
#slice!(*, nils: false)
-
#slice_reverse!(*, nils: false)
-
-
-
Symbolize
-
Hash
-
#symbolize_keys(deep: false)
-
#symbolize_keys!(deep: false)
-
-
-
Truncate
-
String
#truncate(position, separator: '', omission: '...')
-
Testing
$ rake spec
Development
After checking out the repo, run bundle install
to install dependencies.
Then, run toys rspec
to run the tests.
To install this gem onto your local machine, run toys gem install
.
To release a new version, run toys gem release %version%
.
See how it works here.
Contributing
Bug reports and pull requests are welcome on GitHub.
License
The gem is available as open source under the terms of the MIT License.