Skip to content

Instantly share code, notes, and snippets.

View gregoriokusowski's full-sized avatar

Gregório Chalinski Kusowski gregoriokusowski

View GitHub Profile
@gregoriokusowski
gregoriokusowski / key_finder.rb
Created February 21, 2011 14:29
A helper that finds the informed word(when running in shell), and gives all the options, with the respectives I18n keys, like "activerecord.models.attributes.etc.name"
require 'yaml'
@sentence = ARGV.shift
def find(path, map)
map.each do |key, value|
if value.is_a? Hash
find("#{path}#{key}.", value)
else
puts "#{path}#{key} - #{value}" if value =~ /#{@sentence}/
@gregoriokusowski
gregoriokusowski / runner.rb
Created February 21, 2011 14:23
a rails model used to create all "validates_numericality_of" validations based on the schema. The code sux a bit, and have a lot of smells, but is working by now...
class TheModel
def name
@model_name
end
def initialize(line)
@model_name = extract_name(line).to_s.singularize
end