Rails plugin / collection of little useful methods and such.
Ruby
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
tasks
test
MIT-LICENSE
README.md
Rakefile
init.rb
install.rb
santas_little_helper.gemspec
uninstall.rb

README.md

From The Simpsons Movie (2007)

Bart Simpson: Boy, you made it! But how?
Santa's Little Helper: [subtitled] I did things no dog should. They will haunt me forever.
Bart Simpson: I love you too

SantasLittleHelper

Pretty self explanatory plugin. This is a collection of useful little snippets that I used through out various projects. If there is something you would like to add either check it out and modify it the way you want or let me know and I might add it here. It's dumb just like the famous dog, but it may surprise you. So be really careful and check out source to see what it does.

P.S. I jsut disvored a gem called zucker which provides some of the fanctionality that I use. So check it out if you are interested.

Example

Once loaded just call available methods. See http://github.com/konung/santas_little_helper/blob/master/lib/santas_little_helper.rb for details.

Refactoring

As of version 1.0 some of the methods are being refactored. To keep it more consistent and to avoid conflicts with Ruby defaults, all custom to_h are converted to .to_human. to_h means to Hash in ruby parlence - so this really is to avoid confusion. Also refactored some of the system wide methods to make it easier for cover more OS's in the future.

Rails 3 & Gemfile

Sometimes if you are developing in rails on windows and deploying to linux and platform or implementaion lookups don't work and you are tired of parsing RUBY_PLATFORM, you can do this

in Gemfile at the top require:

require "santas_little_helper"
gem "santas_little_helper"

#then you can do this:

if jruby?
  gem 'activerecord-jdbcmysql-adapter'
  gem 'jdbc-mysql'
  gem 'jruby-openssl'
  gem 'therubyrhino', :group => :assets
  gem 'puma'
else
  gem 'mysql2', '0.3.11'
  gem  'activerecord-mysql2-adapter'
end

CAREFUL!!!!

Be realy careful about using this GEM - it shivs String, True, False & Nil. May add helpful methods to other classes. Please read source for a an up to day list of helpful methods:

  • RUBY_PLATFORM: ruby_platform, ruby_platform?(:os_to_check), windows?, linux?, mac?
  • RUBY_PLATFORM: ruby_implemention, ruby_implemention?(:written_in), jruby?, mri?
  • RUBY_VERSION: ruby_version, ruby_version?('version_to_check')
  • Using Refinements now we can do this ( no more monkey patching like in older versions). So this now only works in version 200 and up.
  • For older monkey patching you would have to use older version of the gem
  • Reverting back to monkeypatching since Refinements only work in main context for now. Feature is experimental,so I'm droping it for now.
  • TrueClass, FalseClass, NilClass , String, Fixnum and Float: to_human, to_i, to_teenager
  • String, Fixnum & Float: to_boolean

Copyright (c) 2010 [Nick Gorbikoff] www.gorbikoff.com, released under the MIT license

                                      .....D$7$DM7.. .  .                    .
                                          ..M$$$$$$$OM?........................
            .. DMMM..                 ......87$$$$$$$77M=.
             .MMMMMMM   ...   .      ........MZ$$$$$$$$$7N....  ..  .... . ...
             ?MMMMMMMO..........            ..I$77$$$$$$$$M...................
             ~MMMMMMMMM:..... .             ....?N7$$$$$$$$N....... ....... .
            . ?MMMMMMMMIND......       . . ~8MMMMNDMMMMND88DMO:..M877OM,.....
              .:MMMMMM$$$$$NO,.        .IM,7.....N$$$$$$$$$$$$$$M7$$$$$$7.  .
                .?877$$$$$$$$7$MN,.....?..8M:....~D$77$77$$$$$$$M$$$$$$$7D=...
               . .M7$$$$$$$$$$$$7$ZNN7:M..........MD?:,,?MZ$$$$$$$$$$$$$$$ZN,.
                  .N$$$$$$$$$$$$$$$$$$$77$ONMMMDD,....... ~M$$$$$NZ$$$$$$$$$OO
                  .:M$$$$$$$$$$$$$$$$$$$$$$$$$$ZD...+MM.....Z$$$7$DO7$$$$$$$$D
                  ...M$$$$$$$$$$$$$$$$$$$$$$$$$Z7...........M$$D87$78$$$$$$$7D
                  ....?M7$$$$$$$$$$$$$$$$$$$$$$$M .. .......N7$M7$$$$$$$$$$$OO
                  .. ...M$$$$$$$$$$$$$$$$$$$$$$$78.........~$$$8Z$$$$$$$$$$$M.
                  ........MO7$$$$$$$$$$$$$$$$$$$$$$MO~.,,?M$$$$$ZZ$$$$$$$$8M..
                  .   .. ...$MZ$7$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$7NZI$77ND....
                         ......IMO7$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$77$8.......
                        ...........$MD$7$7$$$$$$$$$$$$$$$$$$$$$$$$$$$M........
                        .... ........M:.$MMD$77$$$$$$$$$$$$$$$$$$$$$$.. ......
                          .............:8M....,DMZ7$$$$$$$$$$$$$$$$7M........
                                      .OZ$OMMMM ...8N7$$$$$$$$$$$$$M. .
                                     .N$ZZNMMMMMMMM7..$M7$$$$$$$$$$ ...
                                   .  =M7$$7OMMMMMMMMMMMMO$$$$$$$7M....
                                      ..88$$$$78MMN8O888NM$$$$$$$N,....
                                      ....M7$$$$$$7$DNNDNN$$$$$$7=.....
                                     ......M$$$$$$$$$$$$$$$$$$$7M......
                                      .. ..=7$$$$$$$$$$$$$$$$$$N,.  ...
                                     ......?7$$$$$$$$$$$$$$$$$7?.......
                               ............M$$$$$$$$$$$$$$$$$$Z..
                               . .....  ..N$$$$$$$$$$$$$$$$$$$7O
                                  ......MZ$$$$$$$$$$$$$$$$$$$$$M.
                               .....:MO7$$$$$$$$$$$$$$$$$$$$$$$M.
     .................. ..... ....N$$$$$$$$$$$$$$$$$$$$$$$$$$$$M.
     ...........................$O7$$$$$$$$$$$$$$$$$$$$$$$$$$$$M.
     ......8NZ777ZDM:.........+$7$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$N
     ...=M7$$$$$$$$$7M$.....:M$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$7I
.......IM$$$$$$$$$$$$$$78,..?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$.
.... +O$$$$$$$$$$$$$$$$$$$MM$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$D
....M7$$$$$$$7ZZ$$$$$$ONMOZDM$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$7N..
..7D$$$$$$$ZM....N7$MZ7$$$$$$NZ$$$$$$$$$$$$$$$$$$$7$NMMO7$$$$$D=..
.?$$$$$$$$N... ...N7$$$$$$$$$7M$$$$$$$$$$$$$$$$$$D87$$$7$$$$$$N...
I8$$$$$$7M.... .=N$$$$$$$$$$$$$N$$$$$$$$$$$$$$7D$7$$$$$$$$$$$M..
M$$$$$$7M.......O$$$$$$$$$$$$$$O$$$$$$$$$$$$7MZ$$$$$$$$$$$$$$,.
D7$$$$7M.......N7$$$$$$DN7$$$$$7D$$$$$$$$$$ZM7$$$$$$$$$$$$$$M.
N7$$$ZZ . ....M7$$$$787$$7M$$$$$88$$$$$$$ZM7$$$$$$$$$$$$$$$D~.
IMDNN...  .  N77$$$$DO$$$$7M7$$$$87$$$$7N$$$$$$$$$$$$$$$$$7I..       :.
            .Z$$$$$7D$$$$$77M$$$$$NZ$$NO7$$$$$$$$$$$$$$$$7M...       $D..
          . M7$$$$$O7$$$$$$$$87$$$$$MN$$$$$$$$$$$$$$$$$$$M...       ..MDI.
          .:D$$$$$$M$$$$$$$$$NZ$$$$$$$$$$$$$$$$$$$$$$7$$7=....      ..?8$~.
          .+8$$$$$M~7$$$$$$$$7M7$$$$$$$$$$$$$$$$$$$$M$$$M..         .. OZDI.
            $O$78N..Z$$$$$$$$$$N$$$$$$$$$$$$$$$$$7MZ$$$M...          ...M$8....
             .......M7$$$$$$$$7N$$$$$$$$$$$$$$$7MO$$$$M.                ,$78..
             .......78$$$$$$$$$Z7$$$$$$$$$$$78MZ$$$$$N..               ..M78=..
              . .....M$$$$$$$7$$O$$$$$$$$$7DM$$$$$$$87..                .Z$$M..
                   ...8$$$$$$$$$8D7$$7$ON8$$$$$$$$$7?...                 .M$D..
                   ...?D$$$$$$$$$$ZD8Z7$$$$$$$$$$$$M..                  ..D$$..
                   ....:M$$$$$$$$$$$$$$$$77NM$$$$7D.....                ..~77?.
                      .. M$$$$$$$$$$Z888O$$$$$$$7M..   .               ....$$O
                        ..N7$$$$$$$$$$$$$$$$$$$$M...                   ....Z$D
                       . ..M$$$$$$$$$$$$$$$$$$$$....                   ....Z7Z
                         ..=D$$$$$$$$$$$$$$$$$$M....                   ....$$D
                         ...M$$$$$$$$$$$$$$$$$78....                    . :7$Z
                         ...N$$$$$$$$$$$$$$$$$7O....                   ...N$7=.
                         ...M$$$$$$$$$$$$$$$$$7N.. .                   ...M$$ .
                         ..,N$$$$$$$$$$$$$$$$$$8.. .                   ..M7$N..
                          .M$$$$$$$$$$$$$$$$$$$7M...                   .+$$ZO..
                         .=7$$$$$$$$$$$$$$$$$$$$7M.                  . 8Z7$M...
MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM