turkish_support 1.0.2 → 1.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9448e0e7b47a86bd29759babace95bf4a5cabd57
4
- data.tar.gz: 34fcb378e3fcd1a0a6e6b9dfacb82c73950f0e9b
3
+ metadata.gz: f32fd6d6257f27898afd35c8d22ce950311a02fa
4
+ data.tar.gz: a01d88e348deaf13f0a195c9ae96a3354dc803da
5
5
  SHA512:
6
- metadata.gz: 040f7aa4a46f01837517ac03ceaa0321eb4157ff6a8f8f97f02e1c9dc32b6edf5979b8e6b3478aa25de27e8cf0f760b237aa269794bbcf614e1980df0e3f0dfa
7
- data.tar.gz: af8204a64ca2bbf161520ddbeda179b144cd10d3233d53f565f66ba7c72e990d57ea86066d73b148d3468a33df9004e2bec154c884ed112dac911a76449e5b7d
6
+ metadata.gz: a1c2449108b61d8d3ba128bec8c1ebc87ca117325f39ad5b4745b746990567bc0f41d975deea1a3879b6b102f350664a0ffe8f89540b3e67c42cd44947101fb3
7
+ data.tar.gz: 4c37ee949de4244d45d0d10fa041691c5e3fee00a7f2936068acb2d34f976e28ba6fae4e291631ca0bedaeb63ec524295240987c27923c1611adca6feca78063
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 Sıtkı Bağdat
1
+ Copyright (c) 2014-2016 Sıtkı Bağdat
2
2
 
3
3
  MIT License
4
4
 
@@ -4,20 +4,17 @@ module TurkishSupportHelpers
4
4
  upper: 'ABCÇDEFGĞHIİJKLMNOÖPQRSŞTUÜVWXYZ',
5
5
  tr_lower: 'çğıiöşü',
6
6
  tr_upper: 'ÇĞIİÖŞÜ'
7
- }
7
+ }.freeze
8
8
 
9
9
  ALPHABET = ALPHA[:upper] + ALPHA[:lower]
10
10
 
11
11
  META_CHARS = {
12
12
  '\w' => '[\p{Latin}\d_]',
13
13
  '\W' => '[^\p{Latin}\d_]'
14
- }
14
+ }.freeze
15
15
 
16
16
  # Regexp required methods
17
- RE_RE_METHS = %i(
18
- match
19
- scan
20
- )
17
+ RE_RE_METHS = %i(match scan).freeze
21
18
 
22
19
  # Regexp optional methods
23
20
  RE_OP_METHS = %i(
@@ -35,7 +32,7 @@ module TurkishSupportHelpers
35
32
  sub!
36
33
  gsub
37
34
  gsub!
38
- )
35
+ ).freeze
39
36
 
40
37
  CASE_RELATED_METHS = %i(
41
38
  downcase
@@ -44,11 +41,11 @@ module TurkishSupportHelpers
44
41
  upcase!
45
42
  capitalize
46
43
  capitalize!
47
- )
44
+ ).freeze
48
45
 
49
46
  RANGE_REGEXP = /\[[^\]]*?([#{ALPHABET}]-[#{ALPHABET}])[^\[]*?\]/
50
47
 
51
- CONJUCTIONS = %w(ve ile veya)
48
+ CONJUCTIONS = %w(ve ile veya).freeze
52
49
 
53
- SPECIAL_CHARS = %q{("'}
50
+ SPECIAL_CHARS = %q{("'}.freeze
54
51
  end
@@ -1,7 +1,8 @@
1
1
  module TurkishSupportHelpers
2
2
  def translate_regexp(pattern) # rubocop:disable Metrics/AbcSize
3
3
  Regexp.new(pattern) unless pattern.is_a? Regexp
4
- re, options = pattern.source, pattern.options
4
+ re = pattern.source
5
+ options = pattern.options
5
6
 
6
7
  while re.match(RANGE_REGEXP)
7
8
  re.scan(RANGE_REGEXP).flatten.compact.each do |matching|
@@ -25,7 +26,7 @@ module TurkishSupportHelpers
25
26
  def prepare_for(meth, string)
26
27
  valid_meths = %i(upcase downcase capitalize)
27
28
  unless valid_meths.include?(meth) && string.is_a?(String)
28
- fail ArgumentError, 'Invalid arguments for method `prepare_for`!'
29
+ raise ArgumentError, 'Invalid arguments for method `prepare_for`!'
29
30
  end
30
31
 
31
32
  method("prepare_for_#{meth}").call(string)
@@ -74,7 +75,7 @@ module TurkishSupportHelpers
74
75
  elsif upper.include?(first) && upper.include?(last)
75
76
  upcase_range(first, last, casefold)
76
77
  else
77
- fail ArgumentError, 'Invalid regexp range arguments!'
78
+ raise ArgumentError, 'Invalid regexp range arguments!'
78
79
  end
79
80
  end
80
81
 
@@ -21,13 +21,13 @@ module TurkishSupport
21
21
  end
22
22
  end
23
23
 
24
- def titleize(conjuctions = true)
24
+ def titleize(conjuctions = true) # rubocop:disable Metrics/AbcSize
25
25
  split.map do |word|
26
26
  word.downcase!
27
27
  if conjuction?(word) && !conjuctions
28
28
  word
29
29
  elsif start_with_a_special_char?(word)
30
- word.size > 1 ? word.chr + word[1..-1].capitalize : word.chr
30
+ word.size > 1 ? word[0] + word[1..-1].capitalize : word.chr
31
31
  else
32
32
  word.capitalize
33
33
  end
@@ -1,3 +1,3 @@
1
1
  module TurkishSupport
2
- VERSION = '1.0.2'
2
+ VERSION = '1.0.3'.freeze
3
3
  end
@@ -71,24 +71,24 @@ describe 'TurkishSupportHelpers' do
71
71
  context 'returns false' do
72
72
  it 'for non-Turkish specific lower case characters' do
73
73
  expect(downcased_alphabet
74
- .delete(tr_specific_lower)
75
- .chars
76
- .any? { |ch| tr_lower?(ch) }
77
- ).to eq(false)
74
+ .delete(tr_specific_lower)
75
+ .chars
76
+ .any? { |ch| tr_lower?(ch) }
77
+ ).to eq(false)
78
78
  end
79
79
 
80
80
  it 'for any upper case characters' do
81
81
  expect(upcased_alphabet
82
- .chars
83
- .any? { |ch| tr_lower?(ch) }
84
- ).to eq(false)
82
+ .chars
83
+ .any? { |ch| tr_lower?(ch) }
84
+ ).to eq(false)
85
85
  end
86
86
 
87
87
  it 'for non-letter characters' do
88
88
  expect("\"é1!2'3^+4.,-_"
89
- .chars
90
- .any? { |ch| tr_lower?(ch) }
91
- ).to eq(false)
89
+ .chars
90
+ .any? { |ch| tr_lower?(ch) }
91
+ ).to eq(false)
92
92
  end
93
93
  end
94
94
  end
@@ -96,32 +96,32 @@ describe 'TurkishSupportHelpers' do
96
96
  describe '#tr_upper?' do
97
97
  it 'returns true for any Turkish specific upper case character' do
98
98
  expect(tr_specific_upper
99
- .chars
100
- .all? { |ch| tr_upper?(ch) }
101
- ).to eq(true)
99
+ .chars
100
+ .all? { |ch| tr_upper?(ch) }
101
+ ).to eq(true)
102
102
  end
103
103
 
104
104
  context 'returns false' do
105
105
  it 'for non-Turkish specific upper case characters' do
106
106
  expect(upcased_alphabet
107
- .delete(tr_specific_upper)
108
- .chars
109
- .any? { |ch| tr_upper?(ch) }
110
- ).to eq(false)
107
+ .delete(tr_specific_upper)
108
+ .chars
109
+ .any? { |ch| tr_upper?(ch) }
110
+ ).to eq(false)
111
111
  end
112
112
 
113
113
  it 'for any lower case characters' do
114
114
  expect(downcased_alphabet
115
- .chars
116
- .any? { |ch| tr_upper?(ch) }
117
- ).to eq(false)
115
+ .chars
116
+ .any? { |ch| tr_upper?(ch) }
117
+ ).to eq(false)
118
118
  end
119
119
 
120
120
  it 'for non-letter characters' do
121
121
  expect("\"é1!2'3^+4.,-_"
122
- .chars
123
- .any? { |ch| tr_upper?(ch) }
124
- ).to eq(false)
122
+ .chars
123
+ .any? { |ch| tr_upper?(ch) }
124
+ ).to eq(false)
125
125
  end
126
126
  end
127
127
  end
@@ -129,24 +129,24 @@ describe 'TurkishSupportHelpers' do
129
129
  describe '#tr_char?' do
130
130
  it 'returns true for any Turkish specific character' do
131
131
  expect(tr_all
132
- .chars
133
- .all? { |ch| tr_char?(ch) }
134
- ).to eq(true)
132
+ .chars
133
+ .all? { |ch| tr_char?(ch) }
134
+ ).to eq(true)
135
135
  end
136
136
 
137
137
  context 'returns false' do
138
138
  it 'for non-Turkish specific characters' do
139
139
  expect(alphabet.delete(tr_all)
140
- .chars
141
- .any? { |ch| tr_char?(ch) }
142
- ).to eq(false)
140
+ .chars
141
+ .any? { |ch| tr_char?(ch) }
142
+ ).to eq(false)
143
143
  end
144
144
 
145
145
  it 'for non-letter characters' do
146
146
  expect("\"é1!2'3^+4.,-_"
147
- .chars
148
- .any? { |ch| tr_char?(ch) }
149
- ).to eq(false)
147
+ .chars
148
+ .any? { |ch| tr_char?(ch) }
149
+ ).to eq(false)
150
150
  end
151
151
  end
152
152
  end
@@ -154,14 +154,14 @@ describe 'TurkishSupportHelpers' do
154
154
  describe '#conjuction?' do
155
155
  it 'returns true for any conjuction' do
156
156
  expect(conjuctions
157
- .all? { |c| conjuction?(c) }
158
- ).to eq(true)
157
+ .all? { |c| conjuction?(c) }
158
+ ).to eq(true)
159
159
  end
160
160
 
161
161
  it 'returns false for any word contains conjuction' do
162
162
  expect(%w(veda aile veyahut)
163
- .any? { |c| conjuction?(c) }
164
- ).to eq(false)
163
+ .any? { |c| conjuction?(c) }
164
+ ).to eq(false)
165
165
  end
166
166
  end
167
167
 
@@ -169,37 +169,35 @@ describe 'TurkishSupportHelpers' do
169
169
  it 'returns true for all words starts with a special char' do
170
170
  special_words = turkish_words.map { |w| special_chars.sample + w }
171
171
  expect(special_words
172
- .all? { |word| start_with_a_special_char?(word) }
173
- ).to eq(true)
172
+ .all? { |word| start_with_a_special_char?(word) }
173
+ ).to eq(true)
174
174
  end
175
175
 
176
176
  it 'returns false any words not starts with a special char' do
177
177
  expect(turkish_words
178
- .any? { |word| start_with_a_special_char?(word) }
179
- ).to eq(false)
178
+ .any? { |word| start_with_a_special_char?(word) }
179
+ ).to eq(false)
180
180
  end
181
181
  end
182
182
 
183
183
  describe '#translate_range' do
184
184
  it 'translates a complete lower-case range correctly' do
185
- expect(translate_range('a-z'))
186
- .to eq(downcased_alphabet)
185
+ expect(translate_range('a-z')).to eq(downcased_alphabet)
187
186
  end
188
187
 
189
188
  it 'translates a complete upper-case range correctly' do
190
- expect(translate_range('A-Z'))
191
- .to eq(upcased_alphabet)
189
+ expect(translate_range('A-Z')).to eq(upcased_alphabet)
192
190
  end
193
191
 
194
192
  it 'raises an error if any arguments not a letter' do
195
193
  invalid_arguments = %w(1-Z A-9 1-9 a-])
196
194
  expect(invalid_arguments
197
- .all? do |arg|
198
- expect { translate_range(arg) }
199
- .to raise_error ArgumentError,
200
- 'Invalid regexp range arguments!'
201
- end
202
- ).to eq(true)
195
+ .all? do |arg|
196
+ expect { translate_range(arg) }
197
+ .to raise_error ArgumentError,
198
+ 'Invalid regexp range arguments!'
199
+ end
200
+ ).to eq(true)
203
201
  end
204
202
 
205
203
  it 'raises an error if arguments are not in same case' do
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
  using TurkishSupport
3
3
 
4
- module TurkishSupport
4
+ module TurkishSupport # rubocop:disable Metrics/ModuleLength
5
5
  describe VERSION do
6
6
  it 'should have a version number' do
7
7
  expect(TurkishSupport::VERSION).to_not eq(nil)
@@ -29,18 +29,17 @@ module TurkishSupport
29
29
 
30
30
  it 'is able to capture Turkish characters' do
31
31
  expect(turkish_words
32
- .all? { |w| w[/\w+/] == w }
33
- ).to eq(true)
32
+ .all? { |w| w[/\w+/] == w }
33
+ ).to eq(true)
34
34
 
35
35
  expect(turkish_words
36
- .all? { |w| w[/[a-z]+/] == w }
37
- ).to eq(true)
36
+ .all? { |w| w[/[a-z]+/] == w }
37
+ ).to eq(true)
38
38
 
39
- expect(
40
- turkish_words
41
- .map(&:upcase)
42
- .all? { |w| w[/[a-z]+/i] == w }
43
- ).to eq(true)
39
+ expect(turkish_words
40
+ .map(&:upcase)
41
+ .all? { |w| w[/[a-z]+/i] == w }
42
+ ).to eq(true)
44
43
  end
45
44
  end
46
45
 
@@ -67,53 +66,50 @@ module TurkishSupport
67
66
 
68
67
  it 'is able to capture Turkish characters' do
69
68
  expect(turkish_words
70
- .all? { |w| w.index(/\w+/).zero? }
71
- ).to eq(true)
69
+ .all? { |w| w.index(/\w+/).zero? }
70
+ ).to eq(true)
72
71
 
73
72
  expect(turkish_words
74
- .all? { |w| w.index(/[a-z]+/).zero? }
75
- ).to eq(true)
73
+ .all? { |w| w.index(/[a-z]+/).zero? }
74
+ ).to eq(true)
76
75
 
77
76
  expect(turkish_words
78
- .map(&:upcase)
79
- .all? { |w| w.index(/[a-z]+/i).zero? }
80
- ).to eq(true)
77
+ .map(&:upcase)
78
+ .all? { |w| w.index(/[a-z]+/i).zero? }
79
+ ).to eq(true)
81
80
  end
82
81
 
83
82
  it 'begins to search from the right position' do
84
- expect('şç-!+*/-ğüı'.index(/\w+/, 2))
85
- .to eq(8)
83
+ expect('şç-!+*/-ğüı'.index(/\w+/, 2)).to eq(8)
86
84
  end
87
85
  end
88
86
 
89
87
  describe '#rindex' do
90
88
  it 'does not change the original value of the string' do
91
89
  word = turkish_words.sample
92
- expect { word.rindex(/\w+/) }
93
- .to_not change { word }
90
+ expect { word.rindex(/\w+/) }.to_not change { word }
94
91
  end
95
92
 
96
93
  it 'is able to capture Turkish characters' do
97
94
  expect(turkish_words
98
- .map(&:reverse)
99
- .all? { |w| w.rindex(/\w+/) == w.size - 1 }
100
- ).to eq(true)
95
+ .map(&:reverse)
96
+ .all? { |w| w.rindex(/\w+/) == w.size - 1 }
97
+ ).to eq(true)
101
98
 
102
99
  expect(turkish_words
103
- .map(&:reverse)
104
- .all? { |w| w.rindex(/[a-z]+/) == w.size - 1 }
105
- ).to eq(true)
100
+ .map(&:reverse)
101
+ .all? { |w| w.rindex(/[a-z]+/) == w.size - 1 }
102
+ ).to eq(true)
106
103
 
107
104
  expect(turkish_words
108
- .map(&:upcase)
109
- .map(&:reverse)
110
- .all? { |w| w.rindex(/[a-z]+/i) == w.size - 1 }
111
- ).to eq(true)
105
+ .map(&:upcase)
106
+ .map(&:reverse)
107
+ .all? { |w| w.rindex(/[a-z]+/i) == w.size - 1 }
108
+ ).to eq(true)
112
109
  end
113
110
 
114
111
  it 'finishes the searching to the right position' do
115
- expect('şç-!+*/-ğüı'.rindex(/\w+/, 7))
116
- .to eq(1)
112
+ expect('şç-!+*/-ğüı'.rindex(/\w+/, 7)).to eq(1)
117
113
  end
118
114
  end
119
115
 
@@ -123,13 +119,11 @@ module TurkishSupport
123
119
  let(:two_words) { "#{word1} #{word2}" }
124
120
 
125
121
  it 'does not change the original value of the string' do
126
- expect { two_words.partition(/\W+/) }
127
- .to_not change { two_words }
122
+ expect { two_words.partition(/\W+/) }.to_not change { two_words }
128
123
  end
129
124
 
130
125
  it 'is able to capture Turkish characters' do
131
- expect(two_words.partition(/\W+/)
132
- ).to eq([word1, ' ', word2])
126
+ expect(two_words.partition(/\W+/)).to eq([word1, ' ', word2])
133
127
  end
134
128
  end
135
129
 
@@ -140,8 +134,7 @@ module TurkishSupport
140
134
  let(:three_words) { "#{word1} #{word2} #{word3}" }
141
135
 
142
136
  it 'does not change the original value of the string' do
143
- expect { three_words.rpartition(/\W+/) }
144
- .to_not change { three_words }
137
+ expect { three_words.rpartition(/\W+/) }.to_not change { three_words }
145
138
  end
146
139
 
147
140
  it 'is able to capture Turkish characters' do
@@ -154,24 +147,22 @@ module TurkishSupport
154
147
  context 'with non-destructive version' do
155
148
  it 'does not change the original value of the string' do
156
149
  sentence = turkish_words * ' '
157
-
158
- expect { sentence.slice(/\w+/) }
159
- .to_not change { sentence }
150
+ expect { sentence.slice(/\w+/) }.to_not change { sentence }
160
151
  end
161
152
 
162
153
  it 'is able to capture Turkish characters' do
163
154
  expect(turkish_words
164
- .all? { |w| w.slice(/\w+/) == w }
165
- ).to eq(true)
155
+ .all? { |w| w.slice(/\w+/) == w }
156
+ ).to eq(true)
166
157
 
167
158
  expect(turkish_words
168
- .all? { |w| w.slice(/[a-z]+/) == w }
169
- ).to eq(true)
159
+ .all? { |w| w.slice(/[a-z]+/) == w }
160
+ ).to eq(true)
170
161
 
171
162
  expect(turkish_words
172
- .map(&:upcase)
173
- .all? { |w| w.slice(/[a-z]+/i) == w }
174
- ).to eq(true)
163
+ .map(&:upcase)
164
+ .all? { |w| w.slice(/[a-z]+/i) == w }
165
+ ).to eq(true)
175
166
  end
176
167
  end
177
168
 
@@ -179,10 +170,8 @@ module TurkishSupport
179
170
  it 'changes the original value of the string' do
180
171
  sentence = turkish_words * ' '
181
172
 
182
- expect { sentence.slice!(/\w+/) }
183
- .to change { sentence }
184
- expect(sentence)
185
- .to eq(' ' + turkish_words[1..-1] * ' ')
173
+ expect { sentence.slice!(/\w+/) }.to change { sentence }
174
+ expect(sentence).to eq(' ' + turkish_words[1..-1] * ' ')
186
175
  end
187
176
  end
188
177
  end
@@ -190,29 +179,29 @@ module TurkishSupport
190
179
  describe '#split' do
191
180
  it 'is able to capture Turkish characters' do
192
181
  expect(turkish_words
193
- .join(' ')
194
- .split(/\w+/)
195
- .join
196
- .strip
197
- .empty?
198
- ).to eq(true)
182
+ .join(' ')
183
+ .split(/\w+/)
184
+ .join
185
+ .strip
186
+ .empty?
187
+ ).to eq(true)
199
188
 
200
189
  expect(turkish_words
201
- .join(' ')
202
- .split(/[a-z]+/)
203
- .join
204
- .strip
205
- .empty?
206
- ).to eq(true)
190
+ .join(' ')
191
+ .split(/[a-z]+/)
192
+ .join
193
+ .strip
194
+ .empty?
195
+ ).to eq(true)
207
196
 
208
197
  expect(turkish_words
209
- .join(' ')
210
- .upcase
211
- .split(/[a-z]+/i)
212
- .join
213
- .strip
214
- .empty?
215
- ).to eq(true)
198
+ .join(' ')
199
+ .upcase
200
+ .split(/[a-z]+/i)
201
+ .join
202
+ .strip
203
+ .empty?
204
+ ).to eq(true)
216
205
  end
217
206
  end
218
207
 
@@ -226,15 +215,13 @@ module TurkishSupport
226
215
  it 'upcases all of Turkish characters' do
227
216
  upcased_string = downcased_turkish_alphabet.upcase
228
217
 
229
- expect(upcased_string)
230
- .to eq(upcased_turkish_alphabet)
218
+ expect(upcased_string).to eq(upcased_turkish_alphabet)
231
219
  end
232
220
 
233
221
  it 'upcases English characters except i as I' do
234
222
  upcased_string = downcased_english_alphabet.upcase
235
223
 
236
- expect(upcased_string)
237
- .to eq(upcased_english_alphabet.tr('I', 'İ'))
224
+ expect(upcased_string).to eq(upcased_english_alphabet.tr('I', 'İ'))
238
225
  end
239
226
  end
240
227
 
@@ -243,8 +230,7 @@ module TurkishSupport
243
230
  expect { downcased_turkish_alphabet.upcase! }
244
231
  .to change { downcased_turkish_alphabet }
245
232
 
246
- expect(downcased_turkish_alphabet)
247
- .to eq(upcased_turkish_alphabet)
233
+ expect(downcased_turkish_alphabet).to eq(upcased_turkish_alphabet)
248
234
  end
249
235
  end
250
236
  end
@@ -285,8 +271,7 @@ module TurkishSupport
285
271
  it 'does not change the original value of the string' do
286
272
  turkish_word = turkish_words.sample
287
273
 
288
- expect { turkish_word.capitalize }
289
- .to_not change { turkish_word }
274
+ expect { turkish_word.capitalize }.to_not change { turkish_word }
290
275
  end
291
276
 
292
277
  it 'capitalizes the leading first Turkish character' do
@@ -445,43 +430,37 @@ module TurkishSupport
445
430
  end
446
431
 
447
432
  it "doesn't match Turkish characters when regex include '\\W'" do
448
- expect('Aşağı Ayrancı'
449
- .match(/\W+/)
450
- .to_s
451
- ).to eq(' ')
433
+ expect('Aşağı Ayrancı'.match(/\W+/).to_s).to eq(' ')
452
434
  end
453
435
  end
454
436
 
455
437
  describe '#scan' do
456
438
  it "matches Turkish characters when regex include '\\w'" do
457
- expect(turkish_words
458
- .join(' ')
459
- .scan(/\w+/)
460
- ).to eq(turkish_words)
439
+ expect(turkish_words.join(' ').scan(/\w+/)).to eq(turkish_words)
461
440
  end
462
441
 
463
442
  it 'matches Turkish characters when regex include lowercase range' do
464
443
  expect(turkish_words
465
- .join(' ')
466
- .scan(/^[a-z\s]+$/)
467
- ).to eq([turkish_words.join(' ')])
444
+ .join(' ')
445
+ .scan(/^[a-z\s]+$/)
446
+ ).to eq([turkish_words.join(' ')])
468
447
  end
469
448
 
470
449
  it 'matches Turkish characters when regex include uppercase range' do
471
450
  expect(turkish_words
472
- .join(' ')
473
- .upcase
474
- .scan(/^[A-Z\s]+$/)
475
- ).to eq([turkish_words.join(' ').upcase])
451
+ .join(' ')
452
+ .upcase
453
+ .scan(/^[A-Z\s]+$/)
454
+ ).to eq([turkish_words.join(' ').upcase])
476
455
  end
477
456
 
478
457
  it "matches Turkish characters when regex include '\\w'" do
479
458
  expect(turkish_words
480
- .join(' ')
481
- .scan(/\W+/)
482
- .map(&:strip)
483
- .all?(&:empty?)
484
- ).to eq(true)
459
+ .join(' ')
460
+ .scan(/\W+/)
461
+ .map(&:strip)
462
+ .all?(&:empty?)
463
+ ).to eq(true)
485
464
  end
486
465
  end
487
466
 
@@ -490,30 +469,30 @@ module TurkishSupport
490
469
 
491
470
  it "matches Turkish characters when regex include '\\w'" do
492
471
  expect(tr_chars
493
- .split(//)
494
- .all? { |ch| (ch =~ /\w/).zero? }
495
- ).to eq(true)
472
+ .split(//)
473
+ .all? { |ch| (ch =~ /\w/).zero? }
474
+ ).to eq(true)
496
475
  end
497
476
 
498
477
  it 'matches Turkish characters when regex include lowercase range' do
499
478
  expect(ALPHA[:tr_lower]
500
- .split(//)
501
- .all? { |ch| (ch =~ /[a-z]/).zero? }
502
- ).to eq(true)
479
+ .split(//)
480
+ .all? { |ch| (ch =~ /[a-z]/).zero? }
481
+ ).to eq(true)
503
482
  end
504
483
 
505
484
  it 'matches Turkish characters when regex include uppercase range' do
506
485
  expect(ALPHA[:tr_upper]
507
- .split(//)
508
- .all? { |ch| (ch =~ /[A-Z]/).zero? }
509
- ).to eq(true)
486
+ .split(//)
487
+ .all? { |ch| (ch =~ /[A-Z]/).zero? }
488
+ ).to eq(true)
510
489
  end
511
490
 
512
491
  it "doesn't match Turkish characters when regex include '\\W'" do
513
492
  expect(tr_chars
514
- .split(//)
515
- .all? { |ch| (ch =~ /\W/).nil? }
516
- ).to eq(true)
493
+ .split(//)
494
+ .all? { |ch| (ch =~ /\W/).nil? }
495
+ ).to eq(true)
517
496
  end
518
497
  end
519
498
 
@@ -522,19 +501,16 @@ module TurkishSupport
522
501
  it 'does not affect the object' do
523
502
  word = 'ağapaşa ağa'
524
503
 
525
- expect { word.sub(/\w+/, 'bey') }
526
- .to_not change { word }
504
+ expect { word.sub(/\w+/, 'bey') }.to_not change { word }
527
505
  end
528
506
 
529
507
  it 'matches Turkish characters, and replaces them' do
530
- expect('ağapaşa ağa'.sub(/\w+/, 'bey'))
531
- .to eq('bey ağa')
508
+ expect('ağapaşa ağa'.sub(/\w+/, 'bey')).to eq('bey ağa')
532
509
 
533
510
  expect('ağapaşa ağa şapka'.sub(/\W+/, 'bey'))
534
511
  .to eq('ağapaşabeyağa şapka')
535
512
 
536
- expect('ağapaşaağa'.sub(/[a-h]+/, 'bey'))
537
- .to eq('beypaşaağa')
513
+ expect('ağapaşaağa'.sub(/[a-h]+/, 'bey')).to eq('beypaşaağa')
538
514
  end
539
515
  end
540
516
 
@@ -555,19 +531,16 @@ module TurkishSupport
555
531
  it 'does not affect the object' do
556
532
  word = 'ağapaşa ağa'
557
533
 
558
- expect { word.gsub(/\w+/, 'bey') }
559
- .to_not change { word }
534
+ expect { word.gsub(/\w+/, 'bey') }.to_not change { word }
560
535
  end
561
536
 
562
537
  it 'matches Turkish characters, and replaces them' do
563
- expect('ağapaşa ağa'.gsub(/\w+/, 'bey'))
564
- .to eq('bey bey')
538
+ expect('ağapaşa ağa'.gsub(/\w+/, 'bey')).to eq('bey bey')
565
539
 
566
540
  expect('ağapaşa ağa şapka'.gsub(/\W+/, 'bey'))
567
541
  .to eq('ağapaşabeyağabeyşapka')
568
542
 
569
- expect('ağapaşaağa'.gsub(/[a-h]+/, 'bey'))
570
- .to eq('beypbeyşbey')
543
+ expect('ağapaşaağa'.gsub(/[a-h]+/, 'bey')).to eq('beypbeyşbey')
571
544
  end
572
545
  end
573
546
 
@@ -598,27 +571,22 @@ module TurkishSupport
598
571
  describe '#sort' do
599
572
  context 'with non-destructive version' do
600
573
  it 'does not change the original value of the array' do
601
- expect { unsorted_array1.sort }
602
- .to_not change { unsorted_array1 }
574
+ expect { unsorted_array1.sort }.to_not change { unsorted_array1 }
603
575
  end
604
576
 
605
577
  it 'sorts array in alphabetical order' do
606
- expect(unsorted_array1.sort)
607
- .to eq(sorted_array1)
578
+ expect(unsorted_array1.sort).to eq(sorted_array1)
608
579
  end
609
580
 
610
581
  it 'sorts array in alphabetical order' do
611
- expect(unsorted_array2.sort)
612
- .to eq(sorted_array2)
582
+ expect(unsorted_array2.sort).to eq(sorted_array2)
613
583
  end
614
584
  end
615
585
 
616
586
  context 'with destructive version' do
617
587
  it 'changes the original value of the array' do
618
- expect { unsorted_array1.sort! }
619
- .to change { unsorted_array1 }
620
- expect(unsorted_array1)
621
- .to eq(sorted_array1)
588
+ expect { unsorted_array1.sort! }.to change { unsorted_array1 }
589
+ expect(unsorted_array1).to eq(sorted_array1)
622
590
  end
623
591
  end
624
592
  end
@@ -1,4 +1,3 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path('../lib', __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'turkish_support/version'
@@ -15,8 +14,8 @@ Gem::Specification.new do |spec|
15
14
  spec.license = 'MIT'
16
15
 
17
16
  spec.files = `git ls-files -z`.split("\x0")
18
- spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
19
- spec.test_files = spec.files.grep(/^(test|spec|features)\//)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
19
  spec.require_paths = ['lib']
21
20
 
22
21
  spec.required_ruby_version = '>= 2.0.0'
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.2
4
+ version: 1.0.3
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: 2015-10-13 00:00:00.000000000 Z
11
+ date: 2016-11-20 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.4.6
103
+ rubygems_version: 2.6.8
104
104
  signing_key:
105
105
  specification_version: 4
106
106
  summary: Turkish character support for core ruby methods.