turkish_support 0.2.2 → 0.2.3

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: 9fca0c909e2f017060fdc3fa3a79c5aca0fc425e
4
- data.tar.gz: 1f41fea0a325f42eeb75e951ea30612700739a6e
3
+ metadata.gz: 93987885fea718401aa9d3446cb2fde4b6f48f58
4
+ data.tar.gz: 7baca2da2b11b8e254e7b0a472bf487db47d4e75
5
5
  SHA512:
6
- metadata.gz: 9389a8ce7eaa989bae045a89bdbf91d8bb941e1b2b94c4b004288e2834529ba226f90393b0eeb9c0d2321a083f7dc980f5d59e6a47538460ba4404cbdf670ee9
7
- data.tar.gz: 9d58c5361ceeabeb089c41958b843bfd9839f2205dea7935a1c15480d2f7ef1cb4a97b3ab06aae59b7efffbb2b9d160c184f4d055dde0aff62eb7d5ff0ca6a46
6
+ metadata.gz: 650a0fd7c4ff78a619cdd303fe0e9d364442fd0010a3225aadbcbb0831115d9f7179646fdb72a6d1820d06c5a73da1096987ea71a71af3895fa3873913a76518
7
+ data.tar.gz: 5ad930572e3b5acd91d49a9f64b35e118fca0468c92d6b18677ca7ebf9808e04a29b804a7af0eafe9b57c2a593dc4295459fc12dbe6219a972f478a132e00bff
data/README.md CHANGED
@@ -143,10 +143,16 @@ __Array#sort__ and __Array#sort!__
143
143
 
144
144
  __String#titleize__ and __String#titleize!__
145
145
 
146
- These methods are not core methods of ruby, but they are accepted as useful in most situation.
146
+ These methods are not core methods of ruby, but they are accepted as useful in most situations.
147
147
 
148
148
  ```ruby
149
- 'türkÇE desteĞİ'.titleize #=> "Türkçe Desteği"
149
+ 'türkÇE desteĞİ'.titleize #=> "Türkçe Desteği"
150
+
151
+ # Parenthesis, quotes, etc. support
152
+ "rUBY roCkS... (really! 'tRUSt' ME)".titleize #=> "Ruby Rocks... (Really! 'Trust' Me)"
153
+
154
+ # If you don't want to capitalize conjuctions, simply pass a false value as a parameter
155
+ "kerem VE aslı VeYa leyla İlE mecnun".titleize(false) #=> "Kerem ve Aslı veya Leyla ile Mecnun"
150
156
  ```
151
157
 
152
158
  __Important Note:__ If you also want to use original set of the core methods in the same scope, you can use `send` method like this:
@@ -15,4 +15,6 @@ module TurkishSupport
15
15
  'a-z' => DOWNCASED_ALPHABET,
16
16
  'A-Z' => UPCASED_ALPHABET
17
17
  }
18
+
19
+ CONJUCTIONS = %w(ve ile veya)
18
20
  end
@@ -1,11 +1,14 @@
1
1
  module TurkishSupport
2
2
  refine String do
3
- def titleize
3
+ def titleize(conjuctions=true)
4
4
  words.map do |w|
5
- if w.start_with? '('
6
- w[0] + w[1..-1].downcase.capitalize
5
+ w.downcase!
6
+ if CONJUCTIONS.include?(w) && !conjuctions
7
+ w
8
+ elsif w =~ /^[\("']/
9
+ w[0] + w[1..-1].capitalize
7
10
  else
8
- w.downcase.capitalize
11
+ w.capitalize
9
12
  end
10
13
  end.join(' ')
11
14
  end
@@ -1,3 +1,3 @@
1
1
  module TurkishSupport
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -127,9 +127,14 @@ module TurkishSupport
127
127
  expect(titleized).to eq("Merhaba Çamur İsmetoğulları")
128
128
  end
129
129
 
130
- it "support strings that include paranthesis" do
131
- titleized = "rUBY roCkS (really!)".titleize
132
- expect(titleized).to eq("Ruby Rocks (Really!)")
130
+ it "support strings that include paranthesis, quotes, etc." do
131
+ titleized = "rUBY roCkS... (really! 'tRUSt' ME)".titleize
132
+ expect(titleized).to eq("Ruby Rocks... (Really! 'Trust' Me)")
133
+ end
134
+
135
+ it "doesn't capitalize conjuctions when false passed" do
136
+ titleized = "kerem VE aslı VeYa leyla İlE mecnun".titleize(false)
137
+ expect(titleized).to eq("Kerem ve Aslı veya Leyla ile Mecnun")
133
138
  end
134
139
  end
135
140
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turkish_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sıtkı Bağdat