core_extended 0.0.1 → 0.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/lib/core_extended/string.rb +2 -2
- data/lib/core_extended/version.rb +1 -1
- data/spec/string_spec.rb +12 -4
- metadata +1 -1
data/lib/core_extended/string.rb
CHANGED
@@ -12,7 +12,7 @@ class String
|
|
12
12
|
alias_method :upcase_ignoring_accents!, :upcase!
|
13
13
|
def upcase!
|
14
14
|
ACCENTS_MAPPING.each { |map| tr! map[:downcase], map[:upcase] }
|
15
|
-
upcase_ignoring_accents!
|
15
|
+
upcase_ignoring_accents! || self
|
16
16
|
end
|
17
17
|
|
18
18
|
def upcase
|
@@ -22,7 +22,7 @@ class String
|
|
22
22
|
alias_method :downcase_ignoring_accents!, :downcase!
|
23
23
|
def downcase!
|
24
24
|
ACCENTS_MAPPING.each { |map| tr! map[:upcase], map[:downcase] }
|
25
|
-
downcase_ignoring_accents!
|
25
|
+
downcase_ignoring_accents! || self
|
26
26
|
end
|
27
27
|
|
28
28
|
def downcase
|
data/spec/string_spec.rb
CHANGED
@@ -5,14 +5,18 @@ describe String do
|
|
5
5
|
|
6
6
|
describe 'Upcase' do
|
7
7
|
|
8
|
-
it '
|
9
|
-
'
|
8
|
+
it 'Only accented' do
|
9
|
+
'áÈïÔú'.upcase.must_equal 'ÁÈÏÔÚ'
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'Without accents' do
|
13
13
|
'aEiOu'.upcase.must_equal 'AEIOU'
|
14
14
|
end
|
15
15
|
|
16
|
+
it 'Mixed' do
|
17
|
+
'áEïÔu'.upcase.must_equal 'ÁEÏÔU'
|
18
|
+
end
|
19
|
+
|
16
20
|
it 'Change itself' do
|
17
21
|
string = 'áèiÖU'
|
18
22
|
string.upcase!.must_equal 'ÁÈIÖU'
|
@@ -23,14 +27,18 @@ describe String do
|
|
23
27
|
|
24
28
|
describe 'Downcase' do
|
25
29
|
|
26
|
-
it '
|
27
|
-
'
|
30
|
+
it 'Only accented' do
|
31
|
+
'áÈïÔú'.downcase.must_equal 'áèïôú'
|
28
32
|
end
|
29
33
|
|
30
34
|
it 'Without accents' do
|
31
35
|
'aEiOu'.downcase.must_equal 'aeiou'
|
32
36
|
end
|
33
37
|
|
38
|
+
it 'Mixed' do
|
39
|
+
'áEïÔu'.downcase.must_equal 'áeïôu'
|
40
|
+
end
|
41
|
+
|
34
42
|
it 'Change itself' do
|
35
43
|
string = 'ÁÈIöu'
|
36
44
|
string.downcase!.must_equal 'áèiöu'
|