This file contains 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
Action Pack | |
* #concat is now deprecated in favor of using <%= %> helpers [YK] | |
* Block helpers now return Strings, so you can use <%= form_for @foo do |f| %>. | |
<% form_for do |f| %> still works with deprecation notices [YK] | |
* Add a new #mount method on the router that does not anchor the PATH_INFO | |
at the end [YK & CL] |
This file contains 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
def morse s;26.times{|i|s.gsub!(/#{(97+i).chr}/i,%w[.- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- .-. ... - ..- ...- .-- -..- -.-- --..][i])};s;end |
This file contains 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
require "test/unit" | |
class MaskTest < Test::Unit::TestCase | |
def test_morse | |
assert_equal ".-", morse("a") | |
assert_equal "-...", morse("b") | |
assert_equal "......-...-..--- .-----.-..-..-..", morse("Hello World") | |
end | |
end |
This file contains 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
def morse s;26.times{|i|s.gsub!(/#{(97+i).chr}/i,%w[.- -... -.-. -.. . ..-. --. .... .. .--- -.- .-.. -- -. --- .--. --.- .-. ... - ..- ...- .-- -..- -.-- --..][i])};s;end |
This file contains 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
def luhn? n;s=0;n.size.times{|i|x=n[-(i+1),1].to_i*(i%2+1);s+=x>9?x+1:x};s%10==0;end |
This file contains 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
def morse s;26.times{|i|s.gsub! /#{(97+i).chr}/i,("$be5 J8G#T6P'&9Sl/,!-H0cfk"[i]-31).to_s(3).tr("12",".-")};s;end |
This file contains 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
require "test/unit" | |
require File.dirname(__FILE__) + '/business_hours' | |
class BusinessHoursTest < Test::Unit::TestCase | |
def setup | |
@hours = BusinessHours.new("8:00 AM", "5:00 PM") | |
end | |
def test_within_working_hours | |
assert_equal Time.parse("Dec 21, 2009 3:05 PM"), @hours.calculate_deadline(5*60, "Dec 21, 2009 3:00 PM") |
This file contains 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
module RailsAdmin | |
module AuthorizationAdapters | |
class CanCanAdapter | |
def filter_objects(objects) | |
objects.accessible_by(current_ability) | |
end | |
def authorize_action(action, class, object) | |
current_ability.authorize! action.to_sym, (object || class) | |
end |
This file contains 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
namespace :deploy do | |
desc "Make sure there is something to deploy" | |
task :check_revision, :roles => :web do | |
unless `git rev-parse HEAD` == `git rev-parse origin/master` | |
puts "WARNING: HEAD is not the same as origin/master" | |
puts "Run `git push` to sync changes." | |
exit | |
end | |
end | |
end |
This file contains 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
$ rake rails:update | |
Generating app/assets directory and content. (same as 3.1 app generator) | |
Do you want to move all public/stylesheets into app/assets/stylesheets? (recommended) [y] | |
Moving public/stylesheets into app/assets/stylesheets... | |
Existing application.css, merging content to the end of app/assets/stylesheets/application.css. |