https://github.com/alexwayfer/gorilla_patch
Ruby Gem for refine Ruby Core classes.
https://github.com/alexwayfer/gorilla_patch
Last synced: 11 months ago
JSON representation
Ruby Gem for refine Ruby Core classes.
- Host: GitHub
- URL: https://github.com/alexwayfer/gorilla_patch
- Owner: AlexWayfer
- License: mit
- Created: 2016-05-24T21:31:58.000Z (almost 10 years ago)
- Default Branch: main
- Last Pushed: 2025-04-02T19:15:36.000Z (11 months ago)
- Last Synced: 2025-04-09T22:09:08.689Z (11 months ago)
- Language: Ruby
- Size: 213 KB
- Stars: 3
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Gorilla Patch
[](https://cirrus-ci.com/github/AlexWayfer/gorilla_patch)
[](https://codecov.io/gh/AlexWayfer/gorilla_patch)
[](https://codeclimate.com/github/AlexWayfer/gorilla_patch)
[](https://depfu.com/repos/github/AlexWayfer/gorilla_patch)
[](https://inch-ci.org/github/AlexWayfer/gorilla_patch)
[](https://github.com/AlexWayfer/gorilla_patch/blob/main/LICENSE.txt)
[](https://rubygems.org/gems/gorilla_patch)
Ruby Gem for refine Ruby Core classes (like [Monkey patch](https://en.wikipedia.org/wiki/Monkey_patch)).
## Installation
```bash
$ gem install gorilla_patch
```
or with `bundler`:
```ruby
# Gemfile
gem 'gorilla_patch'
```
## Usage
```ruby
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`?
[It's standard feature](http://ruby-doc.org/core/doc/syntax/refinements_rdoc.html).
### 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](https://github.com/AlexWayfer/gem_toys#release).
## Contributing
Bug reports and pull requests are welcome on [GitHub](https://github.com/AlexWayfer/gorilla_patch).
## License
The gem is available as open source under the terms of the
[MIT License](https://opensource.org/licenses/MIT).