turkish_support 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f32fd6d6257f27898afd35c8d22ce950311a02fa
4
- data.tar.gz: a01d88e348deaf13f0a195c9ae96a3354dc803da
3
+ metadata.gz: 290cce063477228d7a8032087805c068b467af96
4
+ data.tar.gz: 5fb69af5c2164fdbc3101da288c0beac801da65c
5
5
  SHA512:
6
- metadata.gz: a1c2449108b61d8d3ba128bec8c1ebc87ca117325f39ad5b4745b746990567bc0f41d975deea1a3879b6b102f350664a0ffe8f89540b3e67c42cd44947101fb3
7
- data.tar.gz: 4c37ee949de4244d45d0d10fa041691c5e3fee00a7f2936068acb2d34f976e28ba6fae4e291631ca0bedaeb63ec524295240987c27923c1611adca6feca78063
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
- if item.is_a?(String)
6
- item.chars.map { |ch| ALPHABET.index(ch) }
7
- else
8
- super
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
@@ -1,3 +1,3 @@
1
1
  module TurkishSupport
2
- VERSION = '1.0.3'.freeze
2
+ VERSION = '1.0.4'.freeze
3
3
  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.3
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: 2016-11-20 00:00:00.000000000 Z
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.8
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.