Project

patch_life

0.0
No commit activity in last 3 years
No release in over 3 years
Allows you to define a patch to ruby in a block that only gets executed if you're below the version which obsoletes the patch.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 0
 Project Readme

#Patch Life

Sometimes in Ruby, it's necessary to backport things like security fixes and stability patches to earlier versions, because upgrading a large-scale ecosystem in ruby can require many months of testing, bug fixes, partial rollouts, etc. Occasionally, you need a way to apply newer fixes to older Ruby runtimes.

But, as often happens, large scale ecosystems tend to collect dust, and hide secrets. Todays quick thinking patch could be tomorrows unexpected production issue, because lets face it - you're going to forget you ever did this in 6 months.

The first, uses a Warning, printed every time your application starts, when the patch is loaded. If your defined Ruby Version and Patch level are equal to or older than the version of Ruby you're running the application with, you'll receive a Warning.

define_patch :version => '1.9.3', :patch=> 448, :message => "It's time to remove me, as you've upgraded to a version of ruby where this code is no longer needed"

#Dirty hack that is considered a bold move

The second, allows you to pass the patch into define_patch_life as a block, only to be executed if the defined version / patch level of Ruby is not equal to or higher than the Ruby Version the application is running with.

define_patch :version => '1.9.3', :patch=> 448 do
  #World saving code
end

You can also combine the two, and have the patch execute only if ruby is beneath it's defined version, and have the message emitted as a Warning as well

define_patch :version => '1.9.3', :patch=> 448, :message => "It's time to remove me, as you've upgraded to a version of ruby where this code is no longer needed" do
  #There will be much scorn and derision when this bites someone in the ass
end

##Upcoming Features

Ability to define arbitrary checks to apply patches with (not just based on ruby version)