Ruby Gem for refine Ruby Core classes (like Monkey patch).
$ gem install gorilla_patch
or with bundler
:
# Gemfile
gem 'gorilla_patch'
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!
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.
-
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: '...')
-
$ rake spec
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.
Bug reports and pull requests are welcome on GitHub.
The gem is available as open source under the terms of the MIT License.