turkish_support 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -0
- data/lib/turkish_support.rb +12 -9
- data/lib/turkish_support/array/helpers.rb +17 -0
- data/lib/turkish_support/array/sort.rb +13 -0
- data/lib/turkish_support/constants.rb +17 -0
- data/lib/turkish_support/{capitalize.rb → string/capitalize.rb} +1 -1
- data/lib/turkish_support/{casecmp.rb → string/casecmp.rb} +0 -0
- data/lib/turkish_support/{downcase.rb → string/downcase.rb} +0 -0
- data/lib/turkish_support/{helpers.rb → string/helpers.rb} +2 -2
- data/lib/turkish_support/{swapcase.rb → string/swapcase.rb} +0 -0
- data/lib/turkish_support/string/titleize.rb +11 -0
- data/lib/turkish_support/{upcase.rb → string/upcase.rb} +0 -0
- data/lib/turkish_support/version.rb +1 -1
- data/spec/turkish_support_spec.rb +51 -7
- metadata +11 -9
- data/lib/turkish_support/titleize.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bf732fd5ed6e7e26aa61e8cc73a52ec9dcba34b
|
4
|
+
data.tar.gz: a6f21e3ac420c51565ce28c2529f61ad4cf753dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3f0afc9b75f2d2f774e22a799e52b2495ba6e6d4884fd15cc7063d7921ae8c85b7eb0378894d45b494b34fe780841bf076b582ced5a12c79a4aa26e22eb403f
|
7
|
+
data.tar.gz: a8885b4cff7ebdc11d7f51e745d1d257a750d7c2de0848b006e479826eb3a5647a543293dc1081ae74241281341a9213aea86692fedaa709614e88f8fa1f898a
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# TurkishSupport
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/turkish_support.svg)](http://badge.fury.io/rb/turkish_support)
|
4
|
+
[![Build Status](https://travis-ci.org/sbagdat/turkish_support.svg?branch=master)](https://travis-ci.org/sbagdat/turkish_support)
|
4
5
|
|
5
6
|
Turkish character support for some standard Ruby methods. This gem provide support for these methods:
|
6
7
|
* `String#upcase`
|
@@ -12,9 +13,12 @@ Turkish character support for some standard Ruby methods. This gem provide suppo
|
|
12
13
|
* `String#swapcase`
|
13
14
|
* `String#swapcase!`
|
14
15
|
* `String#casecmp`
|
16
|
+
* `Array#sort`
|
17
|
+
* `Array#sort!`
|
15
18
|
|
16
19
|
Also gives you some new methods like:
|
17
20
|
* `String#titleize`
|
21
|
+
* `String#titleize!`
|
18
22
|
|
19
23
|
## Requirements
|
20
24
|
|
@@ -70,6 +74,8 @@ Within the file which you added `using TurkishSupport` line to the top of the sc
|
|
70
74
|
str #=> "ismail"
|
71
75
|
|
72
76
|
"merhaba".capitalize #=> "Merhaba"
|
77
|
+
|
78
|
+
["iki", "üç", "dört", "ılık", "iğne", "iyne"].sort #=> ["dört", "ılık", "iğne", "iki", "iyne", "üç"]
|
73
79
|
```
|
74
80
|
|
75
81
|
__Note:__ If you also want to use original set of the core methods in the same scope, you can use `send` method like this:
|
data/lib/turkish_support.rb
CHANGED
@@ -1,13 +1,16 @@
|
|
1
|
-
require "turkish_support/version"
|
2
1
|
require "turkish_support/constants"
|
3
|
-
require "turkish_support/
|
4
|
-
|
5
|
-
require "turkish_support/
|
6
|
-
require "turkish_support/
|
7
|
-
require "turkish_support/
|
8
|
-
require "turkish_support/
|
9
|
-
require "turkish_support/
|
2
|
+
require "turkish_support/version"
|
3
|
+
|
4
|
+
require "turkish_support/string/helpers"
|
5
|
+
require "turkish_support/string/upcase"
|
6
|
+
require "turkish_support/string/downcase"
|
7
|
+
require "turkish_support/string/capitalize"
|
8
|
+
require "turkish_support/string/titleize"
|
9
|
+
require "turkish_support/string/casecmp"
|
10
|
+
require "turkish_support/string/swapcase"
|
11
|
+
|
12
|
+
require "turkish_support/array/helpers"
|
13
|
+
require "turkish_support/array/sort"
|
10
14
|
|
11
15
|
module TurkishSupport
|
12
16
|
end
|
13
|
-
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module TurkishSupport
|
2
|
+
refine Array do
|
3
|
+
def to_number_array(string)
|
4
|
+
string.split('').map{|c| integer_order(c) }
|
5
|
+
end
|
6
|
+
|
7
|
+
def integer_order(char)
|
8
|
+
if char.match(/[ı]/)
|
9
|
+
NORMALIZED_CHARS[char].ord - 0.5
|
10
|
+
elsif char.match(/[çÇğĞİöÖşŞüÜ]/)
|
11
|
+
NORMALIZED_CHARS[char].ord + 0.5
|
12
|
+
else
|
13
|
+
char.ord
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,4 +1,21 @@
|
|
1
|
+
module TurkishSupport
|
1
2
|
UNSUPPORTED_CHARS = {
|
2
3
|
downcase: 'çğıiöşü',
|
3
4
|
upcase: 'ÇĞIİÖŞÜ'
|
4
5
|
}
|
6
|
+
|
7
|
+
NORMALIZED_CHARS = {
|
8
|
+
'ç' => 'c',
|
9
|
+
'Ç' => 'C',
|
10
|
+
'ğ' => 'g',
|
11
|
+
'Ğ' => 'G',
|
12
|
+
'ı' => 'i',
|
13
|
+
'İ' => 'I',
|
14
|
+
'ö' => 'o',
|
15
|
+
'Ö' => 'O',
|
16
|
+
'ş' => 's',
|
17
|
+
'Ş' => 'S',
|
18
|
+
'ü' => 'u',
|
19
|
+
'Ü' => 'U'
|
20
|
+
}
|
21
|
+
end
|
File without changes
|
File without changes
|
@@ -9,11 +9,11 @@ module TurkishSupport
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def is_unsupported_downcase?
|
12
|
-
UNSUPPORTED_CHARS[:downcase].include?
|
12
|
+
UNSUPPORTED_CHARS[:downcase].include? chr
|
13
13
|
end
|
14
14
|
|
15
15
|
def is_unsupported_upcase?
|
16
|
-
UNSUPPORTED_CHARS[:upcase].include?
|
16
|
+
UNSUPPORTED_CHARS[:upcase].include? chr
|
17
17
|
end
|
18
18
|
|
19
19
|
def is_unsupported?
|
File without changes
|
File without changes
|
@@ -101,15 +101,30 @@ module TurkishSupport
|
|
101
101
|
end
|
102
102
|
|
103
103
|
describe "#titleize" do
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
104
|
+
context "with non-destructive version" do
|
105
|
+
it "does not change the original value of the string" do
|
106
|
+
word = "mERHABA çAMUR iSMETOĞULLARI"
|
107
|
+
expect{ word.titleize }.to_not change{ word }
|
108
|
+
end
|
109
|
+
|
110
|
+
it "upcases first character of all words" do
|
111
|
+
titleized = "merhaba çamur ismet".titleize
|
112
|
+
expect(titleized).to eq("Merhaba Çamur İsmet")
|
113
|
+
end
|
108
114
|
|
109
|
-
|
110
|
-
|
111
|
-
|
115
|
+
it "downcases characters other than first characters of all words" do
|
116
|
+
titleized = "mERHABA çAMUR iSMETOĞULLARI".titleize
|
117
|
+
expect(titleized).to eq("Merhaba Çamur İsmetoğulları")
|
118
|
+
end
|
112
119
|
end
|
120
|
+
|
121
|
+
context "with destructive version" do
|
122
|
+
it "changes the original value of the string with the titleized version" do
|
123
|
+
word = "mERHABA çAMUR iSMETOĞULLARI"
|
124
|
+
expect{ word.titleize! }.to change{ word }
|
125
|
+
expect(word).to eq("Merhaba Çamur İsmetoğulları")
|
126
|
+
end
|
127
|
+
end
|
113
128
|
end
|
114
129
|
|
115
130
|
describe "#swapcase" do
|
@@ -133,6 +148,35 @@ module TurkishSupport
|
|
133
148
|
end
|
134
149
|
end
|
135
150
|
end
|
151
|
+
end
|
152
|
+
|
153
|
+
describe Array do
|
154
|
+
let(:unsorted_array1) { %w(bağcılar bahçelievler şimdi çüNKÜ olmalı üç\ kere düş ılık duy) }
|
155
|
+
let(:sorted_array1) { %w(bağcılar bahçelievler çüNKÜ duy düş ılık olmalı şimdi üç\ kere) }
|
156
|
+
let(:unsorted_array2) { %w(iki üç dört ılık iğne iyne ul) }
|
157
|
+
let(:sorted_array2) { %w(dört ılık iğne iki iyne ul üç) }
|
136
158
|
|
159
|
+
describe "#sort" do
|
160
|
+
context "with non-destructive version" do
|
161
|
+
it "does not change the original value of the array" do
|
162
|
+
expect{ unsorted_array1.sort }.to_not change{ unsorted_array1 }
|
163
|
+
end
|
164
|
+
|
165
|
+
it "sorts array in alphabetical order" do
|
166
|
+
expect(unsorted_array1.sort).to eq(sorted_array1)
|
167
|
+
end
|
168
|
+
|
169
|
+
it "sorts array in alphabetical order" do
|
170
|
+
expect(unsorted_array2.sort).to eq(sorted_array2)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
context "with destructive version" do
|
175
|
+
it "changes the original value of the array" do
|
176
|
+
expect{ unsorted_array1.sort! }.to change{ unsorted_array1 }
|
177
|
+
expect(unsorted_array1).to eq(sorted_array1)
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
137
181
|
end
|
138
182
|
end
|
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.1.
|
4
|
+
version: 0.1.1
|
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-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -68,14 +68,16 @@ files:
|
|
68
68
|
- README.md
|
69
69
|
- Rakefile
|
70
70
|
- lib/turkish_support.rb
|
71
|
-
- lib/turkish_support/
|
72
|
-
- lib/turkish_support/
|
71
|
+
- lib/turkish_support/array/helpers.rb
|
72
|
+
- lib/turkish_support/array/sort.rb
|
73
73
|
- lib/turkish_support/constants.rb
|
74
|
-
- lib/turkish_support/
|
75
|
-
- lib/turkish_support/
|
76
|
-
- lib/turkish_support/
|
77
|
-
- lib/turkish_support/
|
78
|
-
- lib/turkish_support/
|
74
|
+
- lib/turkish_support/string/capitalize.rb
|
75
|
+
- lib/turkish_support/string/casecmp.rb
|
76
|
+
- lib/turkish_support/string/downcase.rb
|
77
|
+
- lib/turkish_support/string/helpers.rb
|
78
|
+
- lib/turkish_support/string/swapcase.rb
|
79
|
+
- lib/turkish_support/string/titleize.rb
|
80
|
+
- lib/turkish_support/string/upcase.rb
|
79
81
|
- lib/turkish_support/version.rb
|
80
82
|
- spec/spec_helper.rb
|
81
83
|
- spec/turkish_support_spec.rb
|