brstring 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +0 -0
- data/MIT-LICENSE +20 -0
- data/README +1 -0
- data/Rakefile +100 -0
- data/lib/brstring/string_portuguese.rb +151 -0
- data/lib/brstring/version.rb +9 -0
- data/lib/brstring.rb +13 -0
- data/test/string_portuguese_test.rb +152 -0
- data/test/test_helper.rb +15 -0
- metadata +74 -0
data/CHANGELOG
ADDED
File without changes
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 [name of plugin creator]
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Aqui vai o README
|
data/Rakefile
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/testtask'
|
4
|
+
require 'rake/rdoctask'
|
5
|
+
require 'rake/packagetask'
|
6
|
+
require 'rake/gempackagetask'
|
7
|
+
require 'rake/contrib/sshpublisher'
|
8
|
+
require File.join(File.dirname(__FILE__), 'lib', 'brstring', 'version')
|
9
|
+
|
10
|
+
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
11
|
+
PKG_NAME = 'brstring'
|
12
|
+
PKG_VERSION = BrString::VERSION::STRING + PKG_BUILD
|
13
|
+
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
14
|
+
|
15
|
+
RELEASE_NAME = "REL #{PKG_VERSION}"
|
16
|
+
|
17
|
+
RUBY_FORGE_PROJECT = "brstring"
|
18
|
+
RUBY_FORGE_USER = "tapajos"
|
19
|
+
|
20
|
+
desc "Default Task"
|
21
|
+
task :default => [ :test ]
|
22
|
+
|
23
|
+
# Run the unit tests
|
24
|
+
Rake::TestTask.new { |t|
|
25
|
+
t.libs << "test"
|
26
|
+
t.pattern = 'test/*_test.rb'
|
27
|
+
t.verbose = true
|
28
|
+
t.warning = false
|
29
|
+
}
|
30
|
+
|
31
|
+
|
32
|
+
#Generate the RDoc documentation
|
33
|
+
Rake::RDocTask.new { |rdoc|
|
34
|
+
rdoc.rdoc_dir = 'doc'
|
35
|
+
rdoc.title = "Brazilian Rails -- String"
|
36
|
+
rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
|
37
|
+
rdoc.options << '--charset' << 'utf-8'
|
38
|
+
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
39
|
+
rdoc.rdoc_files.include('README', 'CHANGELOG')
|
40
|
+
rdoc.rdoc_files.include('lib/**/*')
|
41
|
+
}
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
# Create compressed packages
|
46
|
+
spec = Gem::Specification.new do |s|
|
47
|
+
s.platform = Gem::Platform::RUBY
|
48
|
+
s.name = PKG_NAME
|
49
|
+
s.summary = "brstring é uma das gems que compoem o Brazilian Rails"
|
50
|
+
s.description = %q{brstring é uma das gems que compoem o Brazilian Rails}
|
51
|
+
s.version = PKG_VERSION
|
52
|
+
|
53
|
+
s.authors = ["Marcos Tapajós", "Celestino Gomes", "Andre Kupkosvki", "Vinícius Teles"]
|
54
|
+
s.email = "tapajos@gmail.com"
|
55
|
+
s.rubyforge_project = "brstring"
|
56
|
+
s.homepage = "http://www.improveit.com.br/software_livre/brazilian_rails"
|
57
|
+
|
58
|
+
s.add_dependency('activesupport', '>= 1.4.2')
|
59
|
+
|
60
|
+
|
61
|
+
s.has_rdoc = true
|
62
|
+
s.requirements << 'none'
|
63
|
+
s.require_path = 'lib'
|
64
|
+
# s.autorequire = 'brstring'
|
65
|
+
|
66
|
+
s.files = [ "Rakefile", "README", "CHANGELOG", "MIT-LICENSE" ]
|
67
|
+
s.files = s.files + Dir.glob( "lib/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
|
68
|
+
s.files = s.files + Dir.glob( "test/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
|
69
|
+
end
|
70
|
+
|
71
|
+
Rake::GemPackageTask.new(spec) do |p|
|
72
|
+
p.gem_spec = spec
|
73
|
+
p.need_tar = true
|
74
|
+
p.need_zip = true
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
# desc "Publish the API documentation"
|
79
|
+
# task :pgem => [:package] do
|
80
|
+
# Rake::SshFilePublisher.new("wrath.rubyonrails.org", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
|
81
|
+
# end
|
82
|
+
#
|
83
|
+
# desc "Publish the API documentation"
|
84
|
+
# task :pdoc => [:rdoc] do
|
85
|
+
# Rake::SshDirPublisher.new("wrath.rubyonrails.org", "public_html/am", "doc").upload
|
86
|
+
# end
|
87
|
+
#
|
88
|
+
|
89
|
+
desc "Publish the release files to RubyForge."
|
90
|
+
task :release => [ :package ] do
|
91
|
+
require 'rubyforge'
|
92
|
+
require 'rake/contrib/rubyforgepublisher'
|
93
|
+
|
94
|
+
packages = %w( gem tgz zip ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" }
|
95
|
+
|
96
|
+
rubyforge = RubyForge.new
|
97
|
+
rubyforge.configure
|
98
|
+
rubyforge.login
|
99
|
+
rubyforge.add_release("brazilian-rails", PKG_NAME, "REL #{PKG_VERSION}", *packages)
|
100
|
+
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
class String
|
2
|
+
MINUSCULAS_COM_ACENTO = 'áéíóúâêîôûàèìòùäëïöüãõñç'
|
3
|
+
MAIUSCULAS_COM_ACENTO = 'ÁÉÍÓÚÂÊÎÔÛÀÈÌÒÙÄËÏÖÜÃÕÑÇ'
|
4
|
+
|
5
|
+
MINUSCULAS = "abcdefghijklmnopqrstuvwxyz#{MINUSCULAS_COM_ACENTO}"
|
6
|
+
MAIUSCULAS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ#{MAIUSCULAS_COM_ACENTO}"
|
7
|
+
|
8
|
+
# Normaliza nomes proprios
|
9
|
+
#
|
10
|
+
# Exemplo:
|
11
|
+
# String.nome_proprio('maria de souza dos santos e silva da costa') ==> 'Maria de Souza dos Santos e Silva da Costa'
|
12
|
+
def self.nome_proprio(texto)
|
13
|
+
return texto if texto.blank?
|
14
|
+
self.titleize(texto).gsub(/ D(a|e|o|as|os) /, ' d\1 ').gsub(/ E /, ' e ')
|
15
|
+
end
|
16
|
+
|
17
|
+
# Normaliza nomes proprios
|
18
|
+
#
|
19
|
+
# Exemplo:
|
20
|
+
# 'maria de souza dos santos e silva da costa'.nome_proprio ==> 'Maria de Souza dos Santos e Silva da Costa'
|
21
|
+
def nome_proprio
|
22
|
+
String.nome_proprio(self)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Normaliza nomes proprios na própria instância.
|
26
|
+
#
|
27
|
+
# Exemplo:
|
28
|
+
# texto = 'maria de souza dos santos e silva da costa'
|
29
|
+
# texto.nome_proprio!
|
30
|
+
# texto ==> 'Maria de Souza dos Santos e Silva da Costa'
|
31
|
+
def nome_proprio!
|
32
|
+
self.gsub!(/^.*$/, String.nome_proprio(self)) if self
|
33
|
+
end
|
34
|
+
|
35
|
+
# Remove as letras acentuadas
|
36
|
+
#
|
37
|
+
# Exemplo:
|
38
|
+
# String.remover_acentos('texto está com acentuação') ==> 'texto esta com acentuacao'
|
39
|
+
def self.remover_acentos(texto)
|
40
|
+
return texto if texto.blank?
|
41
|
+
texto = texto.gsub(/[á|à|ã|â|ä]/, 'a').gsub(/(é|è|ê|ë)/, 'e').gsub(/(í|ì|î|ï)/, 'i').gsub(/(ó|ò|õ|ô|ö)/, 'o').gsub(/(ú|ù|û|ü)/, 'u')
|
42
|
+
texto = texto.gsub(/(Á|À|Ã|Â|Ä)/, 'A').gsub(/(É|È|Ê|Ë)/, 'E').gsub(/(Í|Ì|Î|Ï)/, 'I').gsub(/(Ó|Ò|Õ|Ô|Ö)/, 'O').gsub(/(Ú|Ù|Û|Ü)/, 'U')
|
43
|
+
texto = texto.gsub(/ñ/, 'n').gsub(/Ñ/, 'N')
|
44
|
+
texto = texto.gsub(/ç/, 'c').gsub(/Ç/, 'C')
|
45
|
+
texto
|
46
|
+
end
|
47
|
+
|
48
|
+
# Remove as letras acentuadas
|
49
|
+
#
|
50
|
+
# Exemplo:
|
51
|
+
# 'texto está com acentuação'.remover_acentos ==> 'texto esta com acentuacao'
|
52
|
+
def remover_acentos
|
53
|
+
String.remover_acentos(self)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Remove as letras acentuadas na própria instância.
|
57
|
+
#
|
58
|
+
# Exemplo:
|
59
|
+
# texto = 'texto está com acentuação'
|
60
|
+
# texto.remover_acentos!
|
61
|
+
# texto ==> 'texto esta com acentuacao'
|
62
|
+
def remover_acentos!
|
63
|
+
self.gsub!(/^.*$/, String.remover_acentos(self)) if self
|
64
|
+
end
|
65
|
+
|
66
|
+
# Retorna uma string com caracteres maiusculos
|
67
|
+
#
|
68
|
+
# Exemplo:
|
69
|
+
# String.upcase('texto com acentuação' ==> 'TEXTO COM ACENTUAÇÃO'
|
70
|
+
def self.upcase(texto)
|
71
|
+
return texto if texto.blank?
|
72
|
+
texto.tr(MINUSCULAS, MAIUSCULAS)
|
73
|
+
end
|
74
|
+
|
75
|
+
# Retorna uma string com caracteres maiusculos
|
76
|
+
#
|
77
|
+
# Exemplo:
|
78
|
+
# 'texto com acentuação'.upcase ==> 'TEXTO COM ACENTUAÇÃO'
|
79
|
+
def upcase
|
80
|
+
String.upcase(self)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Converte para caracteres maiusculos na própria instância
|
84
|
+
#
|
85
|
+
# Exemplo:
|
86
|
+
# texto = 'texto com acentuação'
|
87
|
+
# texto.upcase
|
88
|
+
# texto ==> 'TEXTO COM ACENTUAÇÃO'
|
89
|
+
def upcase!
|
90
|
+
self.gsub!(/^.*$/, String.upcase(self)) if self
|
91
|
+
end
|
92
|
+
|
93
|
+
# Retorna uma string com caracteres minúsculos
|
94
|
+
#
|
95
|
+
# Exemplo:
|
96
|
+
# String.downcase('TEXTO COM ACENTUAÇÃO') ==> 'texto com acentuação'
|
97
|
+
def self.downcase(texto)
|
98
|
+
return texto if texto.blank?
|
99
|
+
texto.tr(MAIUSCULAS, MINUSCULAS)
|
100
|
+
end
|
101
|
+
|
102
|
+
# Retorna uma string com caracteres minúsculos
|
103
|
+
#
|
104
|
+
# Exemplo:
|
105
|
+
# 'TEXTO COM ACENTUAÇÃO'.downcase ==> 'texto com acentuação'
|
106
|
+
def downcase
|
107
|
+
String.downcase(self)
|
108
|
+
end
|
109
|
+
|
110
|
+
# Converte para caracteres minúsculos na própria instância
|
111
|
+
#
|
112
|
+
# Exemplo:
|
113
|
+
# texto = 'TEXTO COM ACENTUAÇÃO'
|
114
|
+
# texto.downcase
|
115
|
+
# texto ==> 'texto com acentuação'
|
116
|
+
def downcase!
|
117
|
+
self.gsub!(/^.*$/, String.downcase(self)) if self
|
118
|
+
end
|
119
|
+
|
120
|
+
# Passa a primeira letra de cada palavra para maiúscula e as demais para minúsculas.
|
121
|
+
#
|
122
|
+
# Exemplo:
|
123
|
+
# String.titleize('o livro esta sobre a mesa!') ==> 'O Livro Esta Sobre A Mesa!'
|
124
|
+
def self.titleize(texto)
|
125
|
+
return texto if texto.blank?
|
126
|
+
texto = texto.downcase
|
127
|
+
texto.chars[0] = texto.chars.first.upcase
|
128
|
+
texto = texto.gsub(/\s[a-z#{String::MINUSCULAS_COM_ACENTO}]/) {|a| a.upcase }
|
129
|
+
texto
|
130
|
+
end
|
131
|
+
|
132
|
+
# Passa a primeira letra de cada palavra para maiúscula e as demais para minúsculas.
|
133
|
+
#
|
134
|
+
# Exemplo:
|
135
|
+
# 'o livro esta sobre a mesa!'.titleize ==> 'O Livro Esta Sobre A Mesa!'
|
136
|
+
def titleize
|
137
|
+
String.titleize(self)
|
138
|
+
end
|
139
|
+
|
140
|
+
# Passa a primeira letra de cada palavra para maiúscula e as demais para minúsculas na própria instância.
|
141
|
+
#
|
142
|
+
# Exemplo:
|
143
|
+
# texto = 'o livro esta sobre a mesa!'
|
144
|
+
# texto.titleize!
|
145
|
+
# texto ==> 'O Livro Esta Sobre A Mesa!'
|
146
|
+
def titleize!
|
147
|
+
self.gsub!(/^.*$/, String.titleize(self)) if self
|
148
|
+
end
|
149
|
+
|
150
|
+
|
151
|
+
end
|
data/lib/brstring.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
$KCODE = 'utf-8'
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'activesupport'
|
8
|
+
|
9
|
+
%w(version
|
10
|
+
string_portuguese).each {|req| require File.dirname(__FILE__) + "/brstring/#{req}"}
|
11
|
+
|
12
|
+
module BrString
|
13
|
+
end
|
@@ -0,0 +1,152 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
|
3
|
+
NOMES_PROPRIOS = {
|
4
|
+
'Paulo Gomes' => 'paulo gomes',
|
5
|
+
'Pedro da Silva' => 'pedro da silva',
|
6
|
+
'Jonas de Souza' => 'jonas de souza',
|
7
|
+
'Maria do Carmo' => 'maria do carmo',
|
8
|
+
'Silva e Souza' => 'silva e souza',
|
9
|
+
'Jardim das Oliveiras' => 'jardim das oliveiras',
|
10
|
+
'José dos Santos' => 'josé dos santos',
|
11
|
+
'Tomé Gomes da Silva de Souza' => 'tomé gomes da silva de souza',
|
12
|
+
'Maria do Carmo e Souza das Couves dos Santos' => 'maria do carmo e souza das couves dos santos',
|
13
|
+
'Átila da Silva' => 'átila da silva',
|
14
|
+
'Érica da Silva' => 'érica da silva',
|
15
|
+
'Íris Santos' => 'íris santos',
|
16
|
+
'Paulo dos Santos' => 'paulo dos saNTos',
|
17
|
+
' José da Silva ' => ' josé da silva ',
|
18
|
+
'' => ''
|
19
|
+
} #:nodoc:
|
20
|
+
|
21
|
+
NOMES_TITLEIZE = {
|
22
|
+
'José Silva' => 'josé silva',
|
23
|
+
'José Silva' => 'JOSÉ SILVA',
|
24
|
+
'José Da Silva' => 'josé da silva',
|
25
|
+
' José Da Silva ' => ' josé da silva ',
|
26
|
+
'Átila Da Silva' => 'átila da silva',
|
27
|
+
"Á É Í Ó Ú À È Ì Ò Ù Ã Õ Â Ê Î Ô Û Ä Ë Ï Ö Ü" => 'á é í ó ú à è ì ò ù ã õ â ê î ô û ä ë ï ö ü'
|
28
|
+
} #:nodoc:
|
29
|
+
|
30
|
+
class StringPortugueseTest < Test::Unit::TestCase
|
31
|
+
def test_letras_maiusculas
|
32
|
+
assert_equal 'ABCDEFGHIJKLMNOPQRSTUVWXYZÁÉÍÓÚÂÊÎÔÛÀÈÌÒÙÄËÏÖÜÃÕÑÇ', String::MAIUSCULAS
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_letras_minusculas
|
36
|
+
assert_equal 'abcdefghijklmnopqrstuvwxyzáéíóúâêîôûàèìòùäëïöüãõñç', String::MINUSCULAS
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_string_nome_proprio
|
40
|
+
NOMES_PROPRIOS.each {|key, value| assert_equal key, String.nome_proprio(value) }
|
41
|
+
|
42
|
+
palavras_excluidas = %w(? ! @ # $ % & * \ / ? , . ; ] [ } { = + 0 1 2 3 4 5 6 7 8 9)
|
43
|
+
|
44
|
+
palavras_excluidas.each do |char|
|
45
|
+
assert_equal char, String.nome_proprio(char), "Não deveria alterar o caracter '#{char}'"
|
46
|
+
end
|
47
|
+
|
48
|
+
assert_nil String.nome_proprio(nil)
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_nome_proprio
|
52
|
+
NOMES_PROPRIOS.each {|key, value| assert_equal key, value.nome_proprio }
|
53
|
+
|
54
|
+
palavras_excluidas = %w(? ! @ # $ % & * \ / ? , . ; ] [ } { = + 0 1 2 3 4 5 6 7 8 9)
|
55
|
+
|
56
|
+
palavras_excluidas.each do |char|
|
57
|
+
assert_equal char, char.nome_proprio, "Não deveria alterar o caracter '#{char}'"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_nome_proprio!
|
62
|
+
NOMES_PROPRIOS.each do |key, value|
|
63
|
+
nome = value
|
64
|
+
nome.nome_proprio!
|
65
|
+
assert_equal key, nome
|
66
|
+
end
|
67
|
+
|
68
|
+
palavras_excluidas = %w(? ! @ # $ % & * \ / ? , . ; ] [ } { = + 0 1 2 3 4 5 6 7 8 9)
|
69
|
+
|
70
|
+
palavras_excluidas.each do |char|
|
71
|
+
nome = char.clone
|
72
|
+
nome.nome_proprio!
|
73
|
+
assert_equal char, nome, "Não deveria alterar o caracter '#{char}'"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def test_string_remover_acentos
|
78
|
+
assert_equal 'aeiouAEIOU', String.remover_acentos("áéíóúÁÉÍÓÚ")
|
79
|
+
assert_equal 'aeiouAEIOU', String.remover_acentos("âêîôûÂÊÎÔÛ")
|
80
|
+
assert_equal 'aeiouAEIOU', String.remover_acentos("àèìòùÀÈÌÒÙ")
|
81
|
+
assert_equal 'aeiouAEIOU', String.remover_acentos("äëïöüÄËÏÖÜ")
|
82
|
+
assert_equal 'aoAO', String.remover_acentos("ãõÃÕ")
|
83
|
+
assert_equal 'nN', String.remover_acentos("ñÑ")
|
84
|
+
assert_equal 'cC', String.remover_acentos("çÇ")
|
85
|
+
assert_equal 'aeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaoAOnNcC', String.remover_acentos("áéíóúÁÉÍÓÚâêîôûÂÊÎÔÛàèìòùÀÈÌÒÙäëïöüÄËÏÖÜãõÃÕñÑçÇ")
|
86
|
+
assert_nil String.remover_acentos(nil)
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_remover_acentos
|
90
|
+
assert_equal 'aeiouAEIOU', "áéíóúÁÉÍÓÚ".remover_acentos
|
91
|
+
assert_equal 'aeiouAEIOU', "âêîôûÂÊÎÔÛ".remover_acentos
|
92
|
+
assert_equal 'aeiouAEIOU', "àèìòùÀÈÌÒÙ".remover_acentos
|
93
|
+
assert_equal 'aeiouAEIOU', "äëïöüÄËÏÖÜ".remover_acentos
|
94
|
+
assert_equal 'aoAO', "ãõÃÕ".remover_acentos
|
95
|
+
assert_equal 'nN', "ñÑ".remover_acentos
|
96
|
+
assert_equal 'cC', "çÇ".remover_acentos
|
97
|
+
assert_equal 'aeiouAEIOUaeiouAEIOUaeiouAEIOUaeiouAEIOUaoAOnNcC', "áéíóúÁÉÍÓÚâêîôûÂÊÎÔÛàèìòùÀÈÌÒÙäëïöüÄËÏÖÜãõÃÕñÑçÇ".remover_acentos
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_remover_acentos!
|
101
|
+
string = 'áéíóúÁÉÍÓÚ'
|
102
|
+
string.remover_acentos!
|
103
|
+
assert_equal 'aeiouAEIOU', string
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_string_downcase
|
107
|
+
assert_equal String::MINUSCULAS, String.downcase(String::MAIUSCULAS)
|
108
|
+
assert_nil String.downcase(nil)
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_downcase
|
112
|
+
assert_equal String::MINUSCULAS, String::MAIUSCULAS.downcase
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_downcase!
|
116
|
+
string = String::MAIUSCULAS.clone
|
117
|
+
string.downcase!
|
118
|
+
assert_equal String::MINUSCULAS, string
|
119
|
+
end
|
120
|
+
|
121
|
+
def test_string_upcase
|
122
|
+
assert_equal String::MAIUSCULAS, String.upcase(String::MINUSCULAS)
|
123
|
+
assert_nil String.upcase(nil)
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_upcase
|
127
|
+
assert_equal String::MAIUSCULAS, String::MINUSCULAS.upcase
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_upcase!
|
131
|
+
string = String::MINUSCULAS.clone
|
132
|
+
string.upcase!
|
133
|
+
assert_equal String::MAIUSCULAS, string
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_string_titleize
|
137
|
+
NOMES_TITLEIZE.each {|k,v| assert_equal k, String.titleize(v) }
|
138
|
+
assert_nil String.titleize(nil)
|
139
|
+
end
|
140
|
+
|
141
|
+
def test_titleize
|
142
|
+
NOMES_TITLEIZE.each {|k,v| assert_equal k, v.titleize }
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_titleize!
|
146
|
+
NOMES_TITLEIZE.each do |k,v|
|
147
|
+
v.titleize!
|
148
|
+
assert_equal k, v
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.dirname(__FILE__) + '/../lib/brstring'
|
3
|
+
|
4
|
+
def tornar_metodos_publicos(clazz)
|
5
|
+
clazz.class_eval do
|
6
|
+
private_instance_methods.each { |instance_method| public instance_method }
|
7
|
+
private_methods.each { |method| public_class_method method }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def p80 text
|
12
|
+
p '*'*80
|
13
|
+
p text
|
14
|
+
yield if block_given?
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: brstring
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "Marcos Tapaj\xC3\xB3s"
|
8
|
+
- Celestino Gomes
|
9
|
+
- Andre Kupkosvki
|
10
|
+
- "Vin\xC3\xADcius Teles"
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
|
15
|
+
date: 2008-08-31 00:00:00 -03:00
|
16
|
+
default_executable:
|
17
|
+
dependencies:
|
18
|
+
- !ruby/object:Gem::Dependency
|
19
|
+
name: activesupport
|
20
|
+
type: :runtime
|
21
|
+
version_requirement:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.4.2
|
27
|
+
version:
|
28
|
+
description: "brstring \xC3\xA9 uma das gems que compoem o Brazilian Rails"
|
29
|
+
email: tapajos@gmail.com
|
30
|
+
executables: []
|
31
|
+
|
32
|
+
extensions: []
|
33
|
+
|
34
|
+
extra_rdoc_files: []
|
35
|
+
|
36
|
+
files:
|
37
|
+
- Rakefile
|
38
|
+
- README
|
39
|
+
- CHANGELOG
|
40
|
+
- MIT-LICENSE
|
41
|
+
- lib/brstring
|
42
|
+
- lib/brstring/string_portuguese.rb
|
43
|
+
- lib/brstring/version.rb
|
44
|
+
- lib/brstring.rb
|
45
|
+
- test/string_portuguese_test.rb
|
46
|
+
- test/test_helper.rb
|
47
|
+
has_rdoc: true
|
48
|
+
homepage: http://www.improveit.com.br/software_livre/brazilian_rails
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: "0"
|
59
|
+
version:
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0"
|
65
|
+
version:
|
66
|
+
requirements:
|
67
|
+
- none
|
68
|
+
rubyforge_project: brstring
|
69
|
+
rubygems_version: 1.2.0
|
70
|
+
signing_key:
|
71
|
+
specification_version: 2
|
72
|
+
summary: "brstring \xC3\xA9 uma das gems que compoem o Brazilian Rails"
|
73
|
+
test_files: []
|
74
|
+
|