{"id":22201912,"url":"https://github.com/jimmycuadra/guerilla_patch","last_synced_at":"2025-07-27T04:31:17.575Z","repository":{"id":5320526,"uuid":"6503311","full_name":"jimmycuadra/guerilla_patch","owner":"jimmycuadra","description":"Monkey patch objects using Ruby 2.0 refinements, if available.","archived":false,"fork":false,"pushed_at":"2012-11-04T11:59:17.000Z","size":128,"stargazers_count":27,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-24T22:42:46.132Z","etag":null,"topics":["library","monkey-patching","ruby","ruby-refinements"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"jinhang/my-RPC-Framwork","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jimmycuadra.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-11-02T08:19:39.000Z","updated_at":"2019-08-13T15:11:14.000Z","dependencies_parsed_at":"2022-09-09T13:41:00.965Z","dependency_job_id":null,"html_url":"https://github.com/jimmycuadra/guerilla_patch","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimmycuadra%2Fguerilla_patch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimmycuadra%2Fguerilla_patch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimmycuadra%2Fguerilla_patch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jimmycuadra%2Fguerilla_patch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jimmycuadra","download_url":"https://codeload.github.com/jimmycuadra/guerilla_patch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227760018,"owners_count":17815626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["library","monkey-patching","ruby","ruby-refinements"],"created_at":"2024-12-02T16:11:41.450Z","updated_at":"2024-12-02T16:11:41.964Z","avatar_url":"https://github.com/jimmycuadra.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/jimmycuadra/guerilla_patch.png)](https://travis-ci.org/jimmycuadra/guerilla_patch)\n\n# GuerillaPatch\n\n**GuerillaPatch** is a Ruby gem to ease the transition to Ruby 2.0 when redefining behavior in existing objects (monkey patching). Ruby 2.0 introduces a new feature called *refinements* which allows you to create monkey patches that only exist in a scope where the refinement is explicitly included, preventing your changes from affected code that has not opted in.\n\nUsing GuerillaPatch, you can use a common interface for writing a monkey patch that will use refinements if available, working seemlessly for both Ruby 1.9 and Ruby 2.0.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n    gem 'guerilla_patch'\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself with:\n\n    $ gem install guerilla_patch\n\n## Usage\n\nTo create a new monkey patch, use `GuerillaPatch.patch`. The first argument is the object you are patching, and the second argument is the name to use for the refinement if run under Ruby 2.0. Pass a block with the methods you want to add to the object, or any other modifications you want to make.\n\n``` ruby\nGuerillaPatch.patch(Fixnum, \"TimeExtensions\") do\n  def minutes\n    self * 60\n  end\nend\n```\n\nThen, in Ruby 1.9:\n\n``` ruby\n2.minutes # =\u003e 120\n```\n\nAnd in Ruby 2.0:\n\n``` ruby\nclass MyApp\n  using TimeExtensions\n\n  def minutes_to_seconds(m)\n    m.minutes\n  end\nend\n\nMyApp.new.minutes_to_seconds(2) # =\u003e 120\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjimmycuadra%2Fguerilla_patch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjimmycuadra%2Fguerilla_patch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjimmycuadra%2Fguerilla_patch/lists"}