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
# Rake task for listing all Cucumber features defined | |
namespace :cucumber do | |
task :features do | |
list = { :given => [], :when => [], :then => [] } | |
files = Dir.glob(File.join(File.dirname(__FILE__),'features','**','*.rb')).each do |f| | |
File.readlines(f).select { |l| l =~ /\s*[^#]?\s*(Given|When|Then)\s\// }.each do |line| | |
line =~ /(Given|When|Then)\s+(\/\^?)?([^$\/]+)(\$?\/)?/ | |
type = $1.downcase.to_sym | |
name = "#{$1} #{$3}".strip |
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
# I have read http://api.rubyonrails.org/classes/ActionDispatch/Routing/Mapper/Resources.html#method-i-resources | |
# and remain clueless. | |
MyApp::Application.routes.draw do | |
resources :blogs do | |
resources :comments | |
end | |
# then imagine tons of routing below this | |
end |
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
# hotness = age_in_minutes / (votes**2.5) | |
def original_hotness(now, created_at, votes) | |
age_in_minutes = (((created_at.to_f / 60).floor * 60) - ((now.to_f / 60).floor * 60)) / -60 | |
age_in_minutes / (votes**2.5) | |
end | |
def new_hotness(now, created_at, votes) |