Git Product home page Git Product logo

fsck's Introduction

Fsck

Fsck allows you to express your feelings while you're developing. It does this by allowing you to add words to method names on the fly.

Installation

gem install fsck

Examples

Fsck allows you to have a sense of closure during your everyday development life. Here's some examples:

A difficult problem causing you frustration? Tell it how you feel.

# all i want is to sum the goddamn elements
sum = 0
(1..10).each_fucking_element { |e| sum += e }

Find a method that you think rocks? Show it your praise.

# inject rocks!
(1..10).awesome_inject_is_awesome(&:+)

Usage

Spot Usage

Fsck comes as a module that you can include wherever you want.

require "fsck"

class MyClass
  include Fsck

  def my_method
    42
  end
end

my_object = MyClass.new
my_object.calling_my_awesome_method # => 42

Deep Usage

Fsck also provides a way to use its functionality on every object in ruby.

require "fsck/deep"

42.gimme_succ # => 43
ary = Array.new_array_please # => []

Fsck: How does it work?

Fsck achieves its functionality by tapping into method_missing. The first time a fscked method is called, every method defined on the object is examined. The method with the longest name is assumed to be the intended method, and the fscked method is aliased to this method.

The examination process splits the word of each method name, building a regular expression that allows for any number of other words to be inserted anywhere in the method name. If you aren't careful with the words you choose, you may unintentionally call another method.

# you may expect this to call #each, but it will instead call #each_value
my_hash.what_i_need_is_each_set_of_key_plus_value { |k,v| puts k }

Origin

Fsck is named after the use of the Unix file system utility, specifically as it is applied to profanity.

NOTE: This gem has nothing to do with the Unix file system utility

Disclaimer

Because Fsck now uses method aliasing, there's only a slight performance hit on the first call to a fscked method. This should be inline with many other gems out there. Performance aside, using this gem will have quite an impact on the maintainability of your code. Use at your own risk.

License

MIT License. Copyright 2011 Chris Thorn.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.