Whynot
Monkey patches Kernel. For lulz. And for _why day!
Install / Use
/learn @ruby-jokes/WhynotREADME
whynot
Why not?
Installation
Add this line to your application's Gemfile:
gem 'whynot'
And then execute:
$ bundle
Or install it yourself as:
$ gem install whynot
Usage
require 'whynot'
Unconfident Code
Then you can become less confident about your code working. Whynot adds
Kernel#maybe, which takes a block, like so:
maybe do |x,y|
x,y = 1,2
x+y
end
Sometimes it'll return 3, and sometimes nil. Because, why not?
If you would like your code to mostly or occasionally work, you use
Kernel#mostly and Kernel#occasionally, respectively.
Apathetic Code
Whynot also defines Kernel#meh, for when you really don't give a shit.
Sometimes it'll be true, sometimes false. But you don't care about that,
do you?
Production-Only Code
Whynot also defines 'Kernel#fukkit' for when you just want to do it live.
The code will only be executed if RUBY_ENV is equal to production; otherwise, the default value will be returned.
fukkit do # Default handling; returns nil outside of production
# This block is executed in production, and its return value is returned
end
fukkit(42) do # Default handling; returns 42 outside of production
# This block is executed in production, and its return value is returned
end
Contributing
- Fork it ( https://github.com/[my-github-username]/whynot/fork )
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
