turkish_support 1.0.3 → 1.0.4
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/lib/turkish_support/array_methods.rb +7 -4
- data/lib/turkish_support/version.rb +1 -1
- data/spec/turkish_support_spec.rb +23 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 290cce063477228d7a8032087805c068b467af96
|
4
|
+
data.tar.gz: 5fb69af5c2164fdbc3101da288c0beac801da65c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '018f11e35079fb843da1fa9f955b9f8dac21fa3bffc80b05a23aa9eba75447a09a4fcd2f15613218e272bca91485158084ecdc9b43a0672b975b37705d8f77e3'
|
7
|
+
data.tar.gz: f2c51ae7bf25e8170b71e628b257b880a3db7d6a7a96cc001baed4db9db7ee518a493704907396dfaf250a07f74c80a42dc17b4066e33eca9a29f29a27598ec8
|
@@ -2,10 +2,13 @@ module TurkishSupport
|
|
2
2
|
refine Array do
|
3
3
|
def sort
|
4
4
|
sort_by do |item|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
item.chars.map do |ch|
|
6
|
+
if ALPHABET.include?(ch)
|
7
|
+
# Add 65 to put special chars and numbers in correct order
|
8
|
+
ALPHABET.index(ch) + 65
|
9
|
+
else
|
10
|
+
ch.ord
|
11
|
+
end
|
9
12
|
end
|
10
13
|
end
|
11
14
|
end
|
@@ -568,6 +568,14 @@ module TurkishSupport # rubocop:disable Metrics/ModuleLength
|
|
568
568
|
let(:unsorted_array2) { %w(iki Üç dört ılık İğne iyne Ul) }
|
569
569
|
let(:sorted_array2) { %w(İğne Ul Üç dört ılık iki iyne) }
|
570
570
|
|
571
|
+
let(:unsorted_array3) do
|
572
|
+
['Sıtkı1 Bağdat', 'Sıtkı Bağdat', 'a', '3s', '2 b', 'ab ']
|
573
|
+
end
|
574
|
+
|
575
|
+
let(:sorted_array3) do
|
576
|
+
["2 b", "3s", "Sıtkı Bağdat", "Sıtkı1 Bağdat", "a", "ab "]
|
577
|
+
end
|
578
|
+
|
571
579
|
describe '#sort' do
|
572
580
|
context 'with non-destructive version' do
|
573
581
|
it 'does not change the original value of the array' do
|
@@ -581,13 +589,27 @@ module TurkishSupport # rubocop:disable Metrics/ModuleLength
|
|
581
589
|
it 'sorts array in alphabetical order' do
|
582
590
|
expect(unsorted_array2.sort).to eq(sorted_array2)
|
583
591
|
end
|
592
|
+
|
593
|
+
it 'sorts an array that include special chars, numbers, etc.' do
|
594
|
+
expect(unsorted_array3.sort).to eq(sorted_array3)
|
595
|
+
end
|
584
596
|
end
|
585
597
|
|
586
598
|
context 'with destructive version' do
|
587
|
-
it 'changes the original value of the array' do
|
599
|
+
it 'changes the original value of the array(first sample)' do
|
588
600
|
expect { unsorted_array1.sort! }.to change { unsorted_array1 }
|
589
601
|
expect(unsorted_array1).to eq(sorted_array1)
|
590
602
|
end
|
603
|
+
|
604
|
+
it 'changes the original value of the array(second sample)' do
|
605
|
+
expect { unsorted_array2.sort! }.to change { unsorted_array2 }
|
606
|
+
expect(unsorted_array2).to eq(sorted_array2)
|
607
|
+
end
|
608
|
+
|
609
|
+
it 'changes the original value of the array(third sample)' do
|
610
|
+
expect { unsorted_array3.sort! }.to change { unsorted_array3 }
|
611
|
+
expect(unsorted_array3).to eq(sorted_array3)
|
612
|
+
end
|
591
613
|
end
|
592
614
|
end
|
593
615
|
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: 1.0.
|
4
|
+
version: 1.0.4
|
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:
|
11
|
+
date: 2017-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
version: '0'
|
101
101
|
requirements: []
|
102
102
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.6.
|
103
|
+
rubygems_version: 2.6.13
|
104
104
|
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: Turkish character support for core ruby methods.
|