Created
September 30, 2013 06:29
-
-
Save coderek/6760017 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# active support library | |
# Active Support is the Ruby on Rails component responsible for providing Ruby language extensions, utilities, and other transversal stuff. | |
# It offers a richer bottom-line at the language level, targeted both at the development of Rails applications, and at the development of Ruby on Rails itself. | |
# http://guides.rubyonrails.org/active_support_core_extensions.html | |
# examples of functions | |
# blank? and present? | |
# presence | |
# duplicable? | |
# deep_dup | |
# try | |
# class_eval(*args, &block) | |
# acts_like?(duck) | |
# to_param | |
# to_query | |
# with_options | |
# install | |
# jruby -S gem install activesupport | |
# dependencies will be downloaded altogether to your jruby gems folder (you have to figure out where??) | |
# i18n | |
# json | |
# tzinfo | |
# minitest | |
# thread_safe | |
# add dependencies to load path one by one | |
$:.unshift "C:\\jruby-1.7.4\\lib\\ruby\\gems\\shared\\gems\\activesupport-4.0.0\\lib" # replace with your own | |
$:.unshift "C:\\jruby-1.7.4\\lib\\ruby\\gems\\shared\\gems\\i18n-0.6.5\\lib" # replace with your own | |
$:.unshift "C:\\jruby-1.7.4\\lib\\ruby\\gems\\shared\\gems\\thread_safe-0.1.3-java\\lib" # replace with your own | |
$:.unshift "C:\\jruby-1.7.4\\lib\\ruby\\gems\\shared\\gems\\tzinfo-0.3.37\\lib" # replace with your own | |
$:.unshift "C:\\jruby-1.7.4\\lib\\ruby\\gems\\shared\\gems\\json-1.5.0-java\\lib" # replace with your own | |
$:.unshift "C:\\jruby-1.7.4\\lib\\ruby\\gems\\shared\\gems\\minitest-4.7.5\\lib" # replace with your own | |
# ready to go now | |
require 'active_support/core_ext' | |
# test blank? method | |
puts nil.blank? == true | |
puts false.blank? == true | |
puts {}.blank? == true # it's false!? something wrong with this one on windows | |
puts [].blank? == true | |
puts "".blank? == true | |
puts false.blank? == true | |
# test deep_dup | |
array = ['string'] | |
duplicate = array.dup | |
duplicate.push 'another-string' | |
# the object was duplicated, so the element was added only to the duplicate | |
array #=> ['string'] | |
duplicate #=> ['string', 'another-string'] | |
duplicate.first.gsub!('string', 'foo') | |
# first element was not duplicated, it will be changed in both arrays | |
array #=> ['foo'] | |
duplicate #=> ['foo', 'another-string'] | |
# do it again using deep_dup | |
array = ['string'] | |
duplicate = array.deep_dup | |
duplicate.first.gsub!('string', 'foo') | |
p array #=> ['string'] | |
p duplicate #=> ['foo'] | |
# you can do the rest | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment