turkish_support 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/turkish_support/array/sort.rb +6 -6
- data/lib/turkish_support/constants.rb +8 -18
- data/lib/turkish_support/destructives.rb +17 -0
- data/lib/turkish_support/string/capitalize.rb +0 -4
- data/lib/turkish_support/string/destructives.rb +17 -0
- data/lib/turkish_support/string/downcase.rb +0 -4
- data/lib/turkish_support/string/helpers.rb +11 -8
- data/lib/turkish_support/string/swapcase.rb +2 -6
- data/lib/turkish_support/string/titleize.rb +1 -5
- data/lib/turkish_support/string/upcase.rb +0 -4
- data/lib/turkish_support/version.rb +1 -1
- data/lib/turkish_support.rb +2 -1
- metadata +3 -2
- data/lib/turkish_support/array/helpers.rb +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cfd15f4f58e479f52c15d1a7b2e780534929305f
|
4
|
+
data.tar.gz: 6f88ae7c91ec474ab49864d1d8de5bc60549b9ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 047dfa3fc477b0aea9c1429d64d5623a886189e2e900bf51622a367a9dcc7249a967838c12082f64a93f81c69c454eae69c812a51097d58ea5ca9f0cac0dff71
|
7
|
+
data.tar.gz: ba18883f0898f891a4aa80ad13ecf7c764755fa2603a3e38efa46d91721d5ed086015394a93a5889e3e472bcc172c67ddc635b643b7d0560b8019a05082aaff8
|
@@ -1,13 +1,13 @@
|
|
1
1
|
module TurkishSupport
|
2
2
|
refine Array do
|
3
3
|
def sort
|
4
|
-
|
5
|
-
|
4
|
+
sort_by do |item|
|
5
|
+
if item.is_a?(String)
|
6
|
+
item.chars.map { |ch| ORDERED_CHARS.index(ch) }
|
7
|
+
else
|
8
|
+
super
|
9
|
+
end
|
6
10
|
end
|
7
11
|
end
|
8
|
-
|
9
|
-
def sort!
|
10
|
-
replace(sort)
|
11
|
-
end
|
12
12
|
end
|
13
13
|
end
|
@@ -1,21 +1,11 @@
|
|
1
1
|
module TurkishSupport
|
2
|
-
|
3
|
-
|
4
|
-
upcase: 'ÇĞIİÖŞÜ'
|
5
|
-
}
|
2
|
+
DOWNCASED_ALPHABET = 'abcçdefgğhıijklmnoöprsştuüvyz'
|
3
|
+
UPCASED_ALPHABET = 'ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ'
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
'İ' => 'I',
|
14
|
-
'ö' => 'o',
|
15
|
-
'Ö' => 'O',
|
16
|
-
'ş' => 's',
|
17
|
-
'Ş' => 'S',
|
18
|
-
'ü' => 'u',
|
19
|
-
'Ü' => 'U'
|
20
|
-
}
|
5
|
+
UNSUPPORTED_DOWNCASE_CHARS = 'çğıiöşü'
|
6
|
+
UNSUPPORTED_UPCASE_CHARS = 'ÇĞIİÖŞÜ'
|
7
|
+
ORDERED_CHARS = 'AaBbCcÇçDdEeFfGgĞğHhIıİiJjKkLlMmNnOoÖöPpQqRrSsŞşTtUuÜüVvWwXxYyZz'
|
8
|
+
|
9
|
+
DESTRUCTIVE_STRING_METHODS = %i(capitalize downcase swapcase titleize upcase)
|
10
|
+
DESTRUCTIVE_ARRAY_METHODS = %i(sort)
|
21
11
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module TurkishSupport
|
2
|
+
refine String do
|
3
|
+
DESTRUCTIVE_STRING_METHODS.each do |method_name|
|
4
|
+
define_method "#{method_name}!" do
|
5
|
+
send(:replace, eval("#{method_name}"))
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
refine Array do
|
11
|
+
DESTRUCTIVE_ARRAY_METHODS.each do |method_name|
|
12
|
+
define_method "#{method_name}!" do
|
13
|
+
send(:replace, eval("#{method_name}"))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module TurkishSupport
|
2
|
+
refine String do
|
3
|
+
DESTRUCTIVE_STRING_METHODS.each do |method_name|
|
4
|
+
define_method "#{method_name}!" do
|
5
|
+
send(:replace, eval("#{method_name}"))
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
refine Array do
|
11
|
+
DESTRUCTIVE_ARRAY_METHODS.each do |method_name|
|
12
|
+
define_method "#{method_name}!" do
|
13
|
+
send(:replace, eval("#{method_name}"))
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,23 +1,26 @@
|
|
1
1
|
module TurkishSupport
|
2
2
|
refine String do
|
3
|
+
|
3
4
|
def change_chars_for_upcase
|
4
|
-
|
5
|
+
tr UNSUPPORTED_DOWNCASE_CHARS, UNSUPPORTED_UPCASE_CHARS
|
5
6
|
end
|
6
7
|
|
7
8
|
def change_chars_for_downcase
|
8
|
-
tr
|
9
|
+
tr UNSUPPORTED_UPCASE_CHARS, UNSUPPORTED_DOWNCASE_CHARS
|
9
10
|
end
|
10
11
|
|
11
|
-
def
|
12
|
-
|
12
|
+
def unsupported_downcase?
|
13
|
+
UNSUPPORTED_DOWNCASE_CHARS.include? chr
|
13
14
|
end
|
14
15
|
|
15
|
-
def
|
16
|
-
|
16
|
+
def unsupported_upcase?
|
17
|
+
UNSUPPORTED_UPCASE_CHARS.include? chr
|
17
18
|
end
|
18
19
|
|
19
|
-
def
|
20
|
-
|
20
|
+
def unsupported?
|
21
|
+
unsupported_upcase? or unsupported_downcase?
|
21
22
|
end
|
23
|
+
|
24
|
+
alias_method :words, :split
|
22
25
|
end
|
23
26
|
end
|
@@ -2,16 +2,12 @@ module TurkishSupport
|
|
2
2
|
refine String do
|
3
3
|
def swapcase
|
4
4
|
chars.map do |ch|
|
5
|
-
if ch.
|
6
|
-
ch.
|
5
|
+
if ch.unsupported?
|
6
|
+
ch.unsupported_downcase? ? ch.upcase : ch.downcase
|
7
7
|
else
|
8
8
|
ch.send(:swapcase)
|
9
9
|
end
|
10
10
|
end.join
|
11
11
|
end
|
12
|
-
|
13
|
-
def swapcase!
|
14
|
-
replace(swapcase)
|
15
|
-
end
|
16
12
|
end
|
17
13
|
end
|
data/lib/turkish_support.rb
CHANGED
@@ -9,8 +9,9 @@ require "turkish_support/string/titleize"
|
|
9
9
|
require "turkish_support/string/casecmp"
|
10
10
|
require "turkish_support/string/swapcase"
|
11
11
|
|
12
|
-
require "turkish_support/array/helpers"
|
13
12
|
require "turkish_support/array/sort"
|
14
13
|
|
14
|
+
require "turkish_support/destructives"
|
15
|
+
|
15
16
|
module TurkishSupport
|
16
17
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sıtkı Bağdat
|
@@ -68,11 +68,12 @@ files:
|
|
68
68
|
- README.md
|
69
69
|
- Rakefile
|
70
70
|
- lib/turkish_support.rb
|
71
|
-
- lib/turkish_support/array/helpers.rb
|
72
71
|
- lib/turkish_support/array/sort.rb
|
73
72
|
- lib/turkish_support/constants.rb
|
73
|
+
- lib/turkish_support/destructives.rb
|
74
74
|
- lib/turkish_support/string/capitalize.rb
|
75
75
|
- lib/turkish_support/string/casecmp.rb
|
76
|
+
- lib/turkish_support/string/destructives.rb
|
76
77
|
- lib/turkish_support/string/downcase.rb
|
77
78
|
- lib/turkish_support/string/helpers.rb
|
78
79
|
- lib/turkish_support/string/swapcase.rb
|
@@ -1,17 +0,0 @@
|
|
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
|