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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf5b94d930d37d61a0712cf5153278d446977829e4a8f6b10f95d0e237953bb3
4
- data.tar.gz: 46bf4bd9b65029b24979315db8a5e0595665e267d9d739530ad9d77d39b2b2ec
3
+ metadata.gz: e52aee159fcb443687f4d18c2dd77181c0bf4633dc4cdc38a123a8d8522e8865
4
+ data.tar.gz: 6e4c1d6ee4ac28d67eaef74df372dd6fc14bf1bdde81555008a24295ce21363e
5
5
  SHA512:
6
- metadata.gz: 9b200823ace98c49c4e2c7be185771bb9bb9390ba3b6c693786a99b2caef83bbbd399a6df4af45358087016e45c39e4097f0697c4db6aca31950bdb6990f5f70
7
- data.tar.gz: e6d100a4395f0fc6c792aa2a105a7f9b739b34b97677e25693ab46ab152fffa2f345b9ce3ba14811b20ac27ebf8d3b1fa9b9d4246531fd9ab44d02b1455bb030
6
+ metadata.gz: b597463d4655ad862c8ba64c0c9020c543b4a85ea606acefb350f8c03164caa2395a1a06b77963c660fe9fb765f15c447e94272a95b722fc6a84c916f7f77d93
7
+ data.tar.gz: 863aefb578b72b6cee9380c53b13f5ccb275263dd52a846c8afe4647c25448642dca816ce3f762809dffa9e0b9ffb3660a645c569b506025afa491fc294830c8
data/.gitignore CHANGED
@@ -16,3 +16,4 @@ test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
18
  todo.txt
19
+ .idea/*
@@ -0,0 +1,8 @@
1
+ ---
2
+ detectors:
3
+ IrresponsibleModule:
4
+ exclude:
5
+ - TurkishSupport
6
+ UncommunicativeVariableName:
7
+ exclude:
8
+ - TurkishSupport
data/.rspec CHANGED
@@ -1,2 +1,3 @@
1
1
  --format documentation
2
2
  --color
3
+ --require spec_helper
@@ -1,9 +1,14 @@
1
- StringLiterals:
2
- EnforcedStyle: single_quotes
3
- Documentation:
4
- Enabled: false
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
@@ -1,3 +1,3 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.0
3
+ - 2.7.0
@@ -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).
@@ -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
@@ -1,4 +1,5 @@
1
- source 'https://rubygems.org'
1
+ # frozen_string_literal: true
2
2
 
3
- # Specify your gem's dependencies in turkish_support.gemspec
3
+ source 'https://rubygems.org'
4
+ ruby '~> 2.7.0'
4
5
  gemspec
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014-2017 Sıtkı Bağdat
1
+ Copyright (c) 2014-2020 Sıtkı Bağdat
2
2
 
3
3
  MIT License
4
4
 
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
- [![Gem Version](https://badge.fury.io/rb/turkish_support.svg)](http://badge.fury.io/rb/turkish_support)
4
- [![Build Status](https://travis-ci.org/sbagdat/turkish_support.svg?branch=master)](https://travis-ci.org/sbagdat/turkish_support)
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
- * Ruby >= 2.0.0
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
- gem 'turkish_support'
44
+ ```
45
+ gem 'turkish_support'
46
+ ```
49
47
 
50
48
  And then execute:
51
49
 
52
- $ bundle
50
+ ```
51
+ $ bundle
52
+ ```
53
53
 
54
54
  Or install it yourself as:
55
55
 
56
- $ gem install turkish_support
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 where you want to activate it.
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 Test
79
+ class CanSpeakInTurkish
82
80
  using TurkishSupport
83
- def up_me(str)
84
- str.upcase
81
+
82
+ def split_me_up(string, sep)
83
+ string.split(sep)
85
84
  end
86
85
  end
87
86
 
88
- Test.new.up_me('içel') # => "İÇEL"
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 SampleModel < ActiveRecord::Base
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, you must add `using TurkishSupport` line to the class or module.
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
- 'ağapaşaağa'.gsub(/[a-h]+/, 'bey')
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
- 1. Fork it ( http://github.com/sbagdat/turkish_support/fork )
302
- 2. Create your feature branch (`git checkout -b my-new-feature`)
303
- 3. Commit your changes (`git commit -am 'Add some feature'`)
304
- 4. Push to the branch (`git push origin my-new-feature`)
305
- 5. Create new Pull Request
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
@@ -1,6 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
8
+ task :cops do
9
+ sh 'rubocop'
10
+ puts '-' * 50
11
+ sh 'reek'
12
+ end
13
+
6
14
  task default: :spec
@@ -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