Skip to content

Commit 829d03a

Browse files
committed
close #3
1 parent d93a5a9 commit 829d03a

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

lib/string/pattern/add_to_ruby.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def validate(string_to_validate, expected_errors: [], not_expected_errors: [], *
3737
def to_camel_case
3838
return self if self !~ /_/ && self !~ /\s/ && self =~ /^[A-Z]+.*/
3939

40-
gsub(/\W/, "_")
40+
gsub(/[^a-zA-Z0-9ññÑáéíóúÁÉÍÓÚüÜ_]/, "_")
4141
.split("_").map(&:capitalize).join
4242
end
4343
end

spec/string/pattern/add_to_ruby_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@
3232
it "responds to to_camel_case" do
3333
expect("ccccc aaa".to_camel_case).to eq "CccccAaa"
3434
end
35+
it 'returns camel case of Spanish characters' do
36+
expect("caña de albóndiga".to_camel_case).to eq "CañaDeAlbóndiga"
37+
end
3538
end
3639

3740
describe "symbol class" do

string_pattern.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |s|
22
s.name = 'string_pattern'
3-
s.version = '2.2.1'
3+
s.version = '2.2.2'
44
s.summary = "Generate easily random strings following a simple pattern or regular expression. '10-20:Xn/x/'.generate #>qBstvc6JN8ra. Also generate words in English or Spanish. Perfect to be used in test data factories."
55
s.description = "Easily generate strings supplying a very simple pattern. '10-20:Xn/x/'.generate #>qBstvc6JN8ra. Generate random strings using a regular expression (Regexp): /[a-z0-9]{2,5}\w+/.gen . Also generate words in English or Spanish. Perfect to be used in test data factories. Also, validate if a text fulfills a specific pattern or even generate a string following a pattern and returning the wrong length, value... for testing your applications."
66
s.authors = ["Mario Ruiz"]

0 commit comments

Comments
 (0)