turkish_support 1.1.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.reek.yml +8 -0
- data/.rspec +1 -0
- data/.rubocop.yml +10 -5
- data/.travis.yml +1 -1
- data/CHANGELOG.md +6 -0
- data/CODE_OF_CONDUCT.md +46 -0
- data/Gemfile +3 -2
- data/LICENSE.txt +1 -1
- data/README.md +52 -73
- data/Rakefile +8 -0
- data/lib/turkish_support.rb +32 -2
- data/lib/turkish_support/array_methods.rb +6 -9
- data/lib/turkish_support/constants.rb +27 -53
- data/lib/turkish_support/string_methods.rb +32 -54
- data/lib/turkish_support/version.rb +3 -1
- data/spec/array_spec.rb +74 -0
- data/spec/spec_helper.rb +3 -1
- data/spec/string_spec.rb +467 -0
- data/spec/turkish_support_spec.rb +3 -665
- data/turkish_support.gemspec +12 -5
- metadata +77 -18
- data/lib/turkish_support/helpers.rb +0 -113
- data/spec/helpers_spec.rb +0 -262
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e52aee159fcb443687f4d18c2dd77181c0bf4633dc4cdc38a123a8d8522e8865
|
4
|
+
data.tar.gz: 6e4c1d6ee4ac28d67eaef74df372dd6fc14bf1bdde81555008a24295ce21363e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b597463d4655ad862c8ba64c0c9020c543b4a85ea606acefb350f8c03164caa2395a1a06b77963c660fe9fb765f15c447e94272a95b722fc6a84c916f7f77d93
|
7
|
+
data.tar.gz: 863aefb578b72b6cee9380c53b13f5ccb275263dd52a846c8afe4647c25448642dca816ce3f762809dffa9e0b9ffb3660a645c569b506025afa491fc294830c8
|
data/.gitignore
CHANGED
data/.reek.yml
ADDED
data/.rspec
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,9 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
DotPosition:
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.7
|
3
|
+
NewCops: enable
|
4
|
+
Layout/DotPosition:
|
6
5
|
EnforcedStyle: leading
|
7
6
|
Enabled: true
|
8
7
|
Metrics/BlockLength:
|
9
8
|
ExcludedMethods: ['describe', 'context']
|
9
|
+
Style/Documentation:
|
10
|
+
Enabled: false
|
11
|
+
Style/StringLiterals:
|
12
|
+
EnforcedStyle: single_quotes
|
13
|
+
Style/AsciiComments:
|
14
|
+
Enabled: false
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
# Changelog
|
2
|
+
## [Version 2.1.0](https://github.com/sbagdat/turkish_support/releases/tag/v2.1.0) (2020-11-25)
|
3
|
+
### Changed
|
4
|
+
- Helpers module extracted into two seperate gems (turkish_ranges, turkish_regexps). [`a2a6261`](https://github.com/sbagdat/turkish_support/commit/a2a6261)
|
5
|
+
- Too much refactoring. [`a2a6261`](https://github.com/sbagdat/turkish_support/commit/a2a6261)
|
6
|
+
- Decided to keep a changelog file (this file).
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
## Our Standards
|
8
|
+
|
9
|
+
Examples of behavior that contributes to creating a positive environment include:
|
10
|
+
|
11
|
+
* Using welcoming and inclusive language
|
12
|
+
* Being respectful of differing viewpoints and experiences
|
13
|
+
* Gracefully accepting constructive criticism
|
14
|
+
* Focusing on what is best for the community
|
15
|
+
* Showing empathy towards other community members
|
16
|
+
|
17
|
+
Examples of unacceptable behavior by participants include:
|
18
|
+
|
19
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
20
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
21
|
+
* Public or private harassment
|
22
|
+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
23
|
+
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
24
|
+
|
25
|
+
## Our Responsibilities
|
26
|
+
|
27
|
+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
28
|
+
|
29
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
|
30
|
+
|
31
|
+
## Scope
|
32
|
+
|
33
|
+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
|
34
|
+
|
35
|
+
## Enforcement
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at sbagdat@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
38
|
+
|
39
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
40
|
+
|
41
|
+
## Attribution
|
42
|
+
|
43
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
|
44
|
+
|
45
|
+
[homepage]: http://contributor-covenant.org
|
46
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,26 +1,24 @@
|
|
1
|
-
# TurkishSupport
|
1
|
+
# TurkishSupport [![Gem Version](https://badge.fury.io/rb/turkish_support.svg)](https://badge.fury.io/rb/turkish_support) [![Build Status](https://travis-ci.org/sbagdat/turkish_support.svg?branch=master)](https://travis-ci.org/sbagdat/turkish_support) [![Code Climate](https://codeclimate.com/github/sbagdat/turkish_support/badges/gpa.svg)](https://codeclimate.com/github/sbagdat/turkish_support)
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
Turkish character support for core ruby methods. This gem provides support nearly all `String` methods, such as `String#upcase`, `String#downcase`, `String#match`, `String#gsub`. It also provides support for `Array#sort`and some bonus methods like `String#titleize`.
|
3
|
+
Turkish character support for core ruby methods. This gem provides support nearly all `String` methods,
|
4
|
+
such as `String#split`, `String#match`, `String#gsub`. It also provides support for `Array#sort`and some
|
5
|
+
bonus methods like `String#titleize`.
|
7
6
|
|
8
7
|
## Requirements
|
9
|
-
|
10
|
-
*
|
11
|
-
* Rails >= 4.0.0
|
12
|
-
|
13
|
-
__Notice:__ TurkishSupport uses __refinements__ instead of monkey patching.
|
8
|
+
* Ruby >= 2.7.0
|
9
|
+
* Rails >= 6.0.0
|
14
10
|
|
15
11
|
* [Installation](#installation)
|
16
12
|
* [Usage](#usage)
|
17
13
|
* [Using with ruby](#using-with-ruby)
|
18
14
|
* [Using with ruby on rails](#using-with-ruby-on-rails)
|
19
|
-
* [Using Core Methods](#using-core-methods)
|
20
15
|
* [String Methods](#string-methods)
|
21
16
|
* [#<=>](#-spaceship)
|
17
|
+
* [#>](#----comparisons)
|
18
|
+
* [#>=](#----comparisons)
|
19
|
+
* [#<](#----comparisons)
|
20
|
+
* [#<=](#----comparisons)
|
22
21
|
* [#[] and #[]=](#-and-)
|
23
|
-
* [#=~](#-equal-tilda)
|
24
22
|
* [capitalize](#capitalize-and-capitalize)
|
25
23
|
* [casecmp](#casecmp)
|
26
24
|
* [downcase](#downcase-and-downcase)
|
@@ -40,20 +38,24 @@ __Notice:__ TurkishSupport uses __refinements__ instead of monkey patching.
|
|
40
38
|
* [Array Methods](#array-methods)
|
41
39
|
* [sort](#sort-and-sort)
|
42
40
|
|
43
|
-
|
44
41
|
## Installation
|
45
|
-
|
46
42
|
Add this line to your application's Gemfile:
|
47
43
|
|
48
|
-
|
44
|
+
```
|
45
|
+
gem 'turkish_support'
|
46
|
+
```
|
49
47
|
|
50
48
|
And then execute:
|
51
49
|
|
52
|
-
|
50
|
+
```
|
51
|
+
$ bundle
|
52
|
+
```
|
53
53
|
|
54
54
|
Or install it yourself as:
|
55
55
|
|
56
|
-
|
56
|
+
```
|
57
|
+
$ gem install turkish_support
|
58
|
+
```
|
57
59
|
|
58
60
|
## Usage
|
59
61
|
|
@@ -67,25 +69,23 @@ After the installation of the gem, you should follow these steps.
|
|
67
69
|
require 'turkish_support'
|
68
70
|
```
|
69
71
|
|
70
|
-
* Add `using TurkishSupport` line to
|
71
|
-
|
72
|
-
```ruby
|
73
|
-
using TurkishSupport
|
74
|
-
```
|
72
|
+
* Add `using TurkishSupport` line to a class or a module.
|
75
73
|
|
76
74
|
Example usage inside a class:
|
77
75
|
|
78
76
|
```ruby
|
79
77
|
require 'turkish_support'
|
80
78
|
|
81
|
-
class
|
79
|
+
class CanSpeakInTurkish
|
82
80
|
using TurkishSupport
|
83
|
-
|
84
|
-
|
81
|
+
|
82
|
+
def split_me_up(string, sep)
|
83
|
+
string.split(sep)
|
85
84
|
end
|
86
85
|
end
|
87
86
|
|
88
|
-
|
87
|
+
CanSpeakInTurkish.new.split_me_up('çar çarı çarşı', 'ç')
|
88
|
+
# ['ar', 'arı', 'arşı']
|
89
89
|
```
|
90
90
|
|
91
91
|
### Using with ruby on rails
|
@@ -97,30 +97,22 @@ __Note:__ You don't need to require, because it is already required by the rails
|
|
97
97
|
```ruby
|
98
98
|
using TurkishSupport
|
99
99
|
|
100
|
-
class
|
101
|
-
|
100
|
+
class TopModel < ApplicationRecord
|
101
|
+
# your code goes here
|
102
102
|
end
|
103
103
|
```
|
104
104
|
|
105
|
-
* If you want to use TurkishSupport with a custom class or a module that is not inherited from any rails tie,
|
105
|
+
* If you want to use TurkishSupport with a custom class or a module that is not inherited from any rails tie,
|
106
|
+
you must add `using TurkishSupport` line to the class or module.
|
106
107
|
|
107
108
|
```ruby
|
108
109
|
class CustomClass
|
109
110
|
using TurkishSupport
|
110
111
|
|
111
|
-
|
112
|
+
# your code goes here
|
112
113
|
end
|
113
114
|
```
|
114
115
|
|
115
|
-
### Using Core Methods
|
116
|
-
|
117
|
-
If you want to use original set of the core methods in the same scope, you can use `Object#public_send`:
|
118
|
-
|
119
|
-
```ruby
|
120
|
-
str = 'Bağcılar'
|
121
|
-
str.public_send(:upcase) # => "BAğCıLAR"
|
122
|
-
```
|
123
|
-
|
124
116
|
## String Methods
|
125
117
|
|
126
118
|
### <=> (spaceship)
|
@@ -131,22 +123,21 @@ If you want to use original set of the core methods in the same scope, you can u
|
|
131
123
|
'c' <=> 'ca' # => -1
|
132
124
|
```
|
133
125
|
|
126
|
+
### <, <=, >, >= (comparisons)
|
127
|
+
```ruby
|
128
|
+
'd' > 'ç' # => true
|
129
|
+
'aha' >= 'ağa' # => true
|
130
|
+
'd' < 'ç' # => false
|
131
|
+
'ağa' <= 'aha' # => true
|
132
|
+
```
|
134
133
|
|
135
134
|
### [] and []=
|
136
|
-
|
137
135
|
```ruby
|
138
136
|
'Türkiye Cumhuriyeti'[/\w+/] # => "Türkiye"
|
139
137
|
'Çetin'[/[a-ğ]+/i] # => "Çe"
|
140
138
|
```
|
141
139
|
|
142
|
-
### =~ (equal-tilda)
|
143
|
-
|
144
|
-
```ruby
|
145
|
-
'Bağlarbaşı Çarşı Kalabalık' =~ (/[s-ü]+/i) # => 8
|
146
|
-
```
|
147
|
-
|
148
140
|
### capitalize and capitalize!
|
149
|
-
|
150
141
|
```ruby
|
151
142
|
str = 'türkÇE desteĞİ'
|
152
143
|
|
@@ -155,13 +146,11 @@ If you want to use original set of the core methods in the same scope, you can u
|
|
155
146
|
```
|
156
147
|
|
157
148
|
### casecmp
|
158
|
-
|
159
149
|
```ruby
|
160
150
|
'sıtKI'.casecmp('SITkı') # => 0
|
161
151
|
```
|
162
152
|
|
163
153
|
### downcase and downcase!
|
164
|
-
|
165
154
|
```ruby
|
166
155
|
str = 'İSMAİL'
|
167
156
|
|
@@ -170,20 +159,17 @@ If you want to use original set of the core methods in the same scope, you can u
|
|
170
159
|
```
|
171
160
|
|
172
161
|
### gsub and gsub!
|
173
|
-
|
174
162
|
```ruby
|
175
|
-
'
|
163
|
+
'ağa paşa ağa'.gsub(/\b[a-h]+\b/, 'bey') # => "bey paşa bey"
|
176
164
|
```
|
177
165
|
|
178
166
|
### index
|
179
|
-
|
180
167
|
```ruby
|
181
168
|
'?ç-!+*/-ğüı'.index(/\w+/) # => 1
|
182
169
|
'?ç-!+*/-ğüı'.index(/[a-z]+/, 2) # => 8
|
183
170
|
```
|
184
171
|
|
185
172
|
### match
|
186
|
-
|
187
173
|
```ruby
|
188
174
|
'Aşağı'.match(/\w+/)
|
189
175
|
# => #<MatchData "Aşağı">
|
@@ -202,26 +188,22 @@ If you want to use original set of the core methods in the same scope, you can u
|
|
202
188
|
```
|
203
189
|
|
204
190
|
### partition
|
205
|
-
|
206
191
|
```ruby
|
207
192
|
'Bağlarbaşı Çarşı'.partition(/\W+/) # => ["Bağlarbaşı", " ", "Çarşı"]
|
208
193
|
```
|
209
194
|
|
210
195
|
### rpartition
|
211
|
-
|
212
196
|
```ruby
|
213
197
|
'Bağlarbaşı Çarşı Kalabalık'.rpartition(/\W+/)
|
214
198
|
# => ["Bağlarbaşı Çarşı", " ", "Kalabalık"]
|
215
199
|
```
|
216
200
|
|
217
201
|
### rindex
|
218
|
-
|
219
202
|
```ruby
|
220
203
|
'şç-!+*/-ğüı'.rindex(/\w+/, 7) # => 1
|
221
204
|
```
|
222
205
|
|
223
206
|
### scan
|
224
|
-
|
225
207
|
```ruby
|
226
208
|
'Bağlarbaşı Çarşı Kalabalık'.scan(/[a-z]+/i)
|
227
209
|
# => ["Bağlarbaşı", "Çarşı", "Kalabalık"]
|
@@ -229,13 +211,11 @@ If you want to use original set of the core methods in the same scope, you can u
|
|
229
211
|
|
230
212
|
|
231
213
|
### slice and slice!
|
232
|
-
|
233
214
|
```ruby
|
234
215
|
'Duayen'.slice(/[^h-ö]+/) # => "Duaye"
|
235
216
|
```
|
236
217
|
|
237
218
|
### split
|
238
|
-
|
239
219
|
```ruby
|
240
220
|
'Bağlarbaşı Çarşı Kalabalık'.split(/\W+/)
|
241
221
|
# => ["Bağlarbaşı", "Çarşı", "Kalabalık"]
|
@@ -245,22 +225,18 @@ If you want to use original set of the core methods in the same scope, you can u
|
|
245
225
|
```
|
246
226
|
|
247
227
|
### sub and sub!
|
248
|
-
|
249
228
|
```ruby
|
250
229
|
'ağapaşaağa'.sub(/[a-h]+/, 'bey') # => "beypaşaağa"
|
251
230
|
```
|
252
231
|
|
253
232
|
### swapcase and swapcase!
|
254
|
-
|
255
233
|
```ruby
|
256
234
|
'TuğÇE'.swapcase # => "tUĞçe"
|
257
235
|
'TuğÇE'.swapcase! # => "tUĞçe"
|
258
236
|
```
|
259
237
|
|
260
238
|
### titleize and titleize!
|
261
|
-
|
262
239
|
*These methods are not core methods of ruby, but they are accepted as useful in most situations.*
|
263
|
-
|
264
240
|
```ruby
|
265
241
|
'türkÇE desteĞİ'.titleize # => "Türkçe Desteği"
|
266
242
|
'türkÇE desteĞİ'.titleize! # => "Türkçe Desteği"
|
@@ -268,11 +244,6 @@ If you want to use original set of the core methods in the same scope, you can u
|
|
268
244
|
# Parenthesis, quotes, etc. support
|
269
245
|
"rUBY roCkS... (really! 'tRUSt' ME)".titleize
|
270
246
|
# => "Ruby Rocks... (Really! 'Trust' Me)"
|
271
|
-
|
272
|
-
# If you don't want to capitalize conjuctions,
|
273
|
-
# simply pass a false value as parameter
|
274
|
-
"kerem VE aslı VeYa leyla İlE mecnun".titleize(false)
|
275
|
-
# => "Kerem ve Aslı veya Leyla ile Mecnun"
|
276
247
|
```
|
277
248
|
|
278
249
|
### upcase and upcase!
|
@@ -296,10 +267,18 @@ If you want to use original set of the core methods in the same scope, you can u
|
|
296
267
|
# => ["dört", "ılık", "iğne", "iki", "iyne", "üç"]
|
297
268
|
```
|
298
269
|
|
270
|
+
## Development
|
271
|
+
|
272
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
273
|
+
|
299
274
|
## Contributing
|
300
275
|
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
276
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/sbagdat/turkish_support. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/sbagdat/turkish_suppport/blob/master/CODE_OF_CONDUCT.md).
|
277
|
+
|
278
|
+
## License
|
279
|
+
|
280
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
281
|
+
|
282
|
+
## Code of Conduct
|
283
|
+
|
284
|
+
Everyone interacting in the TurkishSupport project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct]
|
data/Rakefile
CHANGED
data/lib/turkish_support.rb
CHANGED
@@ -1,9 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'turkish_ranges'
|
4
|
+
require 'turkish_regexps'
|
5
|
+
|
1
6
|
require 'turkish_support/version'
|
2
7
|
require 'turkish_support/constants'
|
3
|
-
require 'turkish_support/helpers'
|
4
|
-
|
5
8
|
require 'turkish_support/string_methods'
|
6
9
|
require 'turkish_support/array_methods'
|
7
10
|
|
11
|
+
# The TurkishSupport module responsible for making some String and Array
|
12
|
+
# methods compatible with Turkish language by using Ruby language's refinements
|
13
|
+
# feature.
|
14
|
+
#
|
15
|
+
# You can check refinements at
|
16
|
+
# https://docs.ruby-lang.org/en/master/doc/syntax/refinements_rdoc.html
|
17
|
+
#
|
18
|
+
# === Refined Methods
|
19
|
+
# * String#<=>
|
20
|
+
# * String#[]
|
21
|
+
# * String#[]=
|
22
|
+
# * String#capitalize
|
23
|
+
# * String#casecmp
|
24
|
+
# * String#downcase
|
25
|
+
# * String#gsub
|
26
|
+
# * String#index
|
27
|
+
# * String#match
|
28
|
+
# * String#partition
|
29
|
+
# * String#rpartition
|
30
|
+
# * String#rindex
|
31
|
+
# * String#scan
|
32
|
+
# * String#slice
|
33
|
+
# * String#split
|
34
|
+
# * String#sub
|
35
|
+
# * String#swapcase
|
36
|
+
# * String#titleize
|
37
|
+
# * String#upcase
|
8
38
|
module TurkishSupport
|
9
39
|
end
|