0.0
No release in over a year
Refine Ruby Core classes with methods like Active Support.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.9
~> 1.36.0
~> 5.0
~> 2.0
~> 0.12.1
~> 0.21.0
~> 0.13.0
 Project Readme

Gorilla Patch

Cirrus CI - Base Branch Build Status Codecov branch Code Climate Depfu Inline docs license Gem

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?

It's standard feature.

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.