unpack brazilian-rails

This commit is contained in:
2013-07-14 11:09:25 -04:00
parent 7d287fe530
commit e563725dc5
131 changed files with 5496 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
$:.unshift(File.dirname(__FILE__)) unless
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
require 'rubygems'
require 'action_controller'
require 'active_support'
require 'action_view'
%w(version
br_form_options_helper
br_form_helper).each {|req| require File.dirname(__FILE__) + "/brhelper/#{req}"}
module BrHelper
end

View File

@@ -0,0 +1,13 @@
module ActionView::Helpers::FormHelper
# Helper para seleção de sexo com radio_buttom.
def radio_button_sexo(object, method, options_radio_male = {}, options_radio_female = {})
options_male = { }.update(options_radio_male.stringify_keys)
options_female = { }.update(options_radio_female.stringify_keys)
op1= radio_button(object, method, 'M', options_male)
op2 = radio_button(object, method, 'F', options_female)
"#{op1} Masculino\n#{op2} Feminino"
end
end

View File

@@ -0,0 +1,60 @@
# encoding: UTF-8
module ActionView::Helpers::FormOptionsHelper
ESTADOS_BRASILEIROS = [["Acre", "AC"],
["Alagoas", "AL"],
["Amapá", "AP"],
["Amazonas", "AM"],
["Bahia", "BA"],
["Ceará", "CE"],
["Distrito Federal", "DF"],
["Espírito Santo", "ES"],
["Goiás", "GO"],
["Maranhão", "MA"],
["Mato Grosso", "MT"],
["Mato Grosso do Sul", "MS"],
["Minas Gerais", "MG"],
["Pará", "PA"],
["Paraíba", "PB"],
["Paraná", "PR"],
["Pernambuco", "PE"],
["Piauí", "PI"],
["Rio de Janeiro", "RJ"],
["Rio Grande do Norte", "RN"],
["Rio Grande do Sul", "RS"],
["Rondônia", "RO"],
["Roraima", "RR"],
["Santa Catarina", "SC"],
["São Paulo", "SP"],
["Sergipe", "SE"],
["Tocantins", "TO"]
] unless const_defined?("ESTADOS_BRASILEIROS")
# Helper para montar um select para seleção de estados brasileiros por nome,
# mas com armazenamento da sigla.
def select_estado(object, method, options = {}, html_options = {})
select object, method, ESTADOS_BRASILEIROS, options, html_options
end
# Helper para montar um select para seleção de estados brasileiros por sigla.
def select_uf(object, method, options = {}, html_options = {})
select object, method, ESTADOS_BRASILEIROS.collect {|estado, sigla| sigla}, options, html_options
end
# Retorna uma string com a lista de estados brasileiros para usar em uma tag select,
# com exibição do nome do estado, mas armazenando a sigla.
def option_estados_for_select
options_for_select ESTADOS_BRASILEIROS
end
# Retorna uma string com a lista de estados brasileiros para usar em uma tag select,
# com exibição e armazenamento a sigla.
def option_uf_for_select
options_for_select ESTADOS_BRASILEIROS.collect {|nome,sigla| sigla}
end
# Helper para montar um select para seleção de sexo, armazenando apenas a
# inicial.
def select_sexo(object, method, options = {}, html_options = {})
select object, method, [['Masculino', 'M'], ['Feminino', 'F']], options, html_options
end
end

View File

@@ -0,0 +1,10 @@
module BrHelper
module VERSION #:nodoc:
MAJOR = 3
MINOR = 3
TINY = 0
STRING = "#{MAJOR}.#{MINOR}.#{TINY}"
end
end