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 +4 -4
- data/README.md +8 -2
- data/lib/turkish_support/constants.rb +2 -0
- data/lib/turkish_support/string/titleize.rb +7 -4
- data/lib/turkish_support/version.rb +1 -1
- data/spec/turkish_support_spec.rb +8 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93987885fea718401aa9d3446cb2fde4b6f48f58
|
4
|
+
data.tar.gz: 7baca2da2b11b8e254e7b0a472bf487db47d4e75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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:
|
@@ -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
|
-
|
6
|
-
|
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.
|
11
|
+
w.capitalize
|
9
12
|
end
|
10
13
|
end.join(' ')
|
11
14
|
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
|
|