turkish_support 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.
- checksums.yaml +4 -4
- data/README.md +5 -0
- data/lib/turkish_support.rb +7 -40
- data/lib/turkish_support/capitalize.rb +11 -0
- data/lib/turkish_support/casecmp.rb +7 -0
- data/lib/turkish_support/constants.rb +4 -0
- data/lib/turkish_support/downcase.rb +11 -0
- data/lib/turkish_support/helpers.rb +11 -0
- data/lib/turkish_support/titleize.rb +7 -0
- data/lib/turkish_support/upcase.rb +11 -0
- data/lib/turkish_support/version.rb +1 -1
- data/spec/spec_helper.rb +0 -1
- data/spec/turkish_support_spec.rb +85 -67
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 05f59d2e23f979fa67a13e40f3598ba4ae25b506
|
4
|
+
data.tar.gz: 8ed7a3d8e73838c1ae6cace4f44be2713e11ceda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28cd46ba32f30d61acbca5fd689603ea41310bd15d1df62dfb9ad81b60bc8b6089186620a032ac710485a97d2d36f6972e307aaea423feaeb51edf3d6496e26c
|
7
|
+
data.tar.gz: f755fb7dfec1191963a7ed822ccb95aff7c3cfc377a7644fd54b3074ee2fbc25a9383313652bd43853049b74e5e9231ab2d5693f0be546a68ffd588953868c0c
|
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# TurkishSupport
|
2
2
|
|
3
|
+
[](http://badge.fury.io/rb/turkish_support)
|
4
|
+
|
5
|
+
|
3
6
|
A gem for Turkish character support for `String#upcase`, `String#downcase`, `String#capitalize` methods and their destructive versions like `String#upcase!`. In other words; this gem is a lighter version of the UnicodeUtils gem.
|
4
7
|
|
5
8
|
## Requirements
|
@@ -27,6 +30,8 @@ After installing the gem, you want to add a line before using Turkish supported
|
|
27
30
|
using TurkishSupport
|
28
31
|
```
|
29
32
|
|
33
|
+
If you want to see a simple [gist](https://gist.github.com/sbagdat/9964521) that shows how should you use it.
|
34
|
+
|
30
35
|
Now you can use your shiny new methods like below:
|
31
36
|
|
32
37
|
```ruby
|
data/lib/turkish_support.rb
CHANGED
@@ -1,42 +1,9 @@
|
|
1
1
|
require "turkish_support/version"
|
2
|
+
require "turkish_support/constants"
|
3
|
+
require "turkish_support/helpers"
|
4
|
+
require "turkish_support/upcase"
|
5
|
+
require "turkish_support/downcase"
|
6
|
+
require "turkish_support/capitalize"
|
7
|
+
require "turkish_support/titleize"
|
8
|
+
require "turkish_support/casecmp"
|
2
9
|
|
3
|
-
module TurkishSupport
|
4
|
-
UNSUPPORTED_CHARS = {
|
5
|
-
downcase: 'çğıiöşü',
|
6
|
-
upcase: 'ÇĞIİÖŞÜ'
|
7
|
-
}
|
8
|
-
|
9
|
-
refine String do
|
10
|
-
def change_chars_for_upcase
|
11
|
-
tr UNSUPPORTED_CHARS[:downcase], UNSUPPORTED_CHARS[:upcase]
|
12
|
-
end
|
13
|
-
|
14
|
-
def change_chars_for_downcase
|
15
|
-
tr UNSUPPORTED_CHARS[:upcase], UNSUPPORTED_CHARS[:downcase]
|
16
|
-
end
|
17
|
-
|
18
|
-
def upcase
|
19
|
-
change_chars_for_upcase.send(:upcase)
|
20
|
-
end
|
21
|
-
|
22
|
-
def upcase!
|
23
|
-
replace(upcase)
|
24
|
-
end
|
25
|
-
|
26
|
-
def downcase
|
27
|
-
change_chars_for_downcase.send(:downcase)
|
28
|
-
end
|
29
|
-
|
30
|
-
def downcase!
|
31
|
-
replace(downcase)
|
32
|
-
end
|
33
|
-
|
34
|
-
def capitalize
|
35
|
-
[self[0].change_chars_for_upcase.send(:upcase), self[1..-1]].join
|
36
|
-
end
|
37
|
-
|
38
|
-
def capitalize!
|
39
|
-
replace(capitalize)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,97 +1,115 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
using TurkishSupport
|
3
|
+
module TurkishSupport
|
5
4
|
|
6
|
-
describe
|
7
|
-
|
8
|
-
|
5
|
+
describe VERSION do
|
6
|
+
it 'should have a version number' do
|
7
|
+
TurkishSupport::VERSION.should_not be_nil
|
8
|
+
end
|
9
9
|
end
|
10
10
|
|
11
|
-
describe
|
12
|
-
|
13
|
-
it "does not change the original value of the string" do
|
14
|
-
turkish_alphabet = "abcçdefgğhıijklmnoöprsştuüvyz"
|
15
|
-
expect{ turkish_alphabet.upcase }.to_not change{ turkish_alphabet }
|
16
|
-
end
|
11
|
+
describe String do
|
12
|
+
using TurkishSupport
|
17
13
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
14
|
+
let(:downcased_turkish_alphabet) { "abcçdefgğhıijklmnoöprsştuüvyz" }
|
15
|
+
let(:upcased_turkish_alphabet) { "ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ" }
|
16
|
+
let(:downcased_english_alphabet) { [*'a'..'z'].join }
|
17
|
+
let(:upcased_english_alphabet) { [*'A'..'Z'].join }
|
18
|
+
let(:turkish_words) { %w(çamur ıhlamur insan ördek şahika ümraniye) }
|
19
|
+
|
20
|
+
describe "#upcase" do
|
21
|
+
context "with non-destructive version" do
|
22
|
+
it "does not change the original value of the string" do
|
23
|
+
expect{ downcased_turkish_alphabet.upcase }.to_not change{ downcased_turkish_alphabet }
|
24
|
+
end
|
25
|
+
|
26
|
+
it "upcases all of Turkish characters" do
|
27
|
+
upcased_string = downcased_turkish_alphabet.upcase
|
28
|
+
expect(upcased_string).to eq( upcased_turkish_alphabet )
|
29
|
+
end
|
23
30
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
31
|
+
it "upcases English characters except i as I" do
|
32
|
+
upcased_string = downcased_english_alphabet.upcase
|
33
|
+
expect(upcased_string).to eq( upcased_english_alphabet.tr('I', 'İ'))
|
34
|
+
end
|
28
35
|
end
|
29
|
-
end
|
30
36
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
37
|
+
context "with destructive version" do
|
38
|
+
it "changes the original value of the string with the upcased version" do
|
39
|
+
expect{ downcased_turkish_alphabet.upcase! }.to change{ downcased_turkish_alphabet }
|
40
|
+
expect( downcased_turkish_alphabet).to eq( upcased_turkish_alphabet )
|
41
|
+
end
|
36
42
|
end
|
37
43
|
end
|
38
|
-
end
|
39
44
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
end
|
45
|
+
describe "#downcase" do
|
46
|
+
context "with non-destructive version" do
|
47
|
+
it "does not change the original value of the string" do
|
48
|
+
expect{ upcased_turkish_alphabet.downcase }.to_not change{ upcased_turkish_alphabet }
|
49
|
+
end
|
46
50
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
51
|
+
it "downcases all of Turkish characters" do
|
52
|
+
downcased_string = upcased_turkish_alphabet.downcase
|
53
|
+
expect(downcased_string).to eq( downcased_turkish_alphabet )
|
54
|
+
end
|
52
55
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
56
|
+
it "downcases English characters except I as ı" do
|
57
|
+
downcased_string = upcased_english_alphabet.downcase
|
58
|
+
expect(downcased_string).to eq( downcased_english_alphabet.tr('i', 'ı'))
|
59
|
+
end
|
57
60
|
end
|
58
|
-
end
|
59
61
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
62
|
+
context "with destructive version" do
|
63
|
+
it "changes the original value of the string with the downcased version" do
|
64
|
+
expect{ upcased_turkish_alphabet.downcase! }.to change{ upcased_turkish_alphabet }
|
65
|
+
expect( upcased_turkish_alphabet).to eq(downcased_turkish_alphabet)
|
66
|
+
end
|
65
67
|
end
|
66
68
|
end
|
67
|
-
end
|
68
69
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
70
|
+
describe "#capitalize" do
|
71
|
+
context "with non-destructive version" do
|
72
|
+
it "does not change the original value of the string" do
|
73
|
+
turkish_word = turkish_words.sample
|
74
|
+
expect{ turkish_word.capitalize }.to_not change{ turkish_word }
|
75
|
+
end
|
76
|
+
|
77
|
+
it "capitalizes the first character of a string that starts with an unsupported Turkish character" do
|
78
|
+
capitalized_words = turkish_words.map{ |w| w.capitalize }
|
79
|
+
expect(capitalized_words).to eq(%w[Çamur Ihlamur İnsan Ördek Şahika Ümraniye])
|
80
|
+
end
|
81
|
+
|
82
|
+
it "capitalizes the first character of an English string" do
|
83
|
+
english_word = "spy"
|
84
|
+
capitalized_string = english_word.capitalize
|
85
|
+
expect(capitalized_string).to eq("Spy")
|
86
|
+
end
|
74
87
|
end
|
75
88
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
89
|
+
context "with destructive version" do
|
90
|
+
it "changes the original value of the string with the capitalized version" do
|
91
|
+
turkish_word = 'çamur'
|
92
|
+
expect{ turkish_word.capitalize! }.to change{ turkish_word }
|
93
|
+
expect(turkish_word).to eq('Çamur')
|
94
|
+
end
|
80
95
|
end
|
96
|
+
end
|
81
97
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
expect(
|
98
|
+
describe "#casecmp" do
|
99
|
+
it "compares Turkish characters correctly" do
|
100
|
+
result = downcased_turkish_alphabet.casecmp(upcased_turkish_alphabet)
|
101
|
+
expect(result).to be_zero
|
86
102
|
end
|
87
103
|
end
|
88
104
|
|
89
|
-
|
90
|
-
it "
|
91
|
-
|
92
|
-
expect
|
93
|
-
expect(turkish_word).to eq('Çamur')
|
105
|
+
describe "#titleize" do
|
106
|
+
it "capitalizes first character of all words" do
|
107
|
+
titleized = "merhaba çamur ismet".titleize
|
108
|
+
expect(titleized).to eq("Merhaba Çamur İsmet")
|
94
109
|
end
|
95
110
|
end
|
96
111
|
end
|
97
112
|
end
|
113
|
+
|
114
|
+
|
115
|
+
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: turkish_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sıtkı Bağdat
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -69,6 +69,13 @@ files:
|
|
69
69
|
- README.md
|
70
70
|
- Rakefile
|
71
71
|
- lib/turkish_support.rb
|
72
|
+
- lib/turkish_support/capitalize.rb
|
73
|
+
- lib/turkish_support/casecmp.rb
|
74
|
+
- lib/turkish_support/constants.rb
|
75
|
+
- lib/turkish_support/downcase.rb
|
76
|
+
- lib/turkish_support/helpers.rb
|
77
|
+
- lib/turkish_support/titleize.rb
|
78
|
+
- lib/turkish_support/upcase.rb
|
72
79
|
- lib/turkish_support/version.rb
|
73
80
|
- spec/spec_helper.rb
|
74
81
|
- spec/turkish_support_spec.rb
|