Project

crufty

0.01
No commit activity in last 3 years
No release in over 3 years
Self-destruct your crufty code to ensure it doesn't become permanent.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.10
= 0.10.1
= 2.0.0
~> 10.0
>= 0
 Project Readme

Crufty

Don't let quick fixes turn into permanently crufty code. Give it an expiration date.

Installation

Add this line to your application's Gemfile:

gem 'crufty'

And then execute:

$ bundle

Or install it yourself as:

$ gem install crufty

Usage

WARN_AFTER =  DateTime.parse("2015-12-15 10:00AM -800")
ERROR_AFTER = DateTime.parse("2015-12-20 10:00AM -800")

# TODO: Remove this code before it starts to spit out warnings, 
# and DEFINITELY remove it before it starts raising errors.
crufty(WARN_AFTER, ERROR_AFTER) do
  # Hacky code goes here
end

# If you want the warnings without it erroring:

crufty(WARN_AFTER) do
  # Hacky code goes here
end

# Explicit Usage:

crufty(best_by: WARN_AFTER, expires: ERROR_AFTER) do
  # Hacky code goes here
end

The code will run with a warning after the "Best By" date, and it will raise a Crufty::CodeExpired error if run after the "Expiration Date".

In a Rails app, warnings are sent via Rollbar.warn, otherwise they will be sent to Std Error.

You can override the default warning and error logic:

Crufty.on_stale do |crufty|
  # crufty.best_by
  # crufty.expires
  # crufty.backtrace
  # crufty.invoked_at
end

Crufty.on_expired do |crufty|
  # crufty.best_by
  # crufty.expires
  # crufty.backtrace
  # crufty.invoked_at
end

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/righi/crufty. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.