turkish_support 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +51 -0
- data/Rakefile +6 -0
- data/lib/turkish_support.rb +42 -0
- data/lib/turkish_support/version.rb +3 -0
- data/spec/spec_helper.rb +3 -0
- data/spec/turkish_support_spec.rb +97 -0
- data/turkish_support.gemspec +25 -0
- metadata +103 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 40ad8f5d403b52ed781cecd0c82a31affb500c7f
|
4
|
+
data.tar.gz: 185772d61857b0e9273f5828d9685c904f1c3c1e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3b46397b5cce71b37ba11a830f2cef022d723c1e898bc148090695b83c3fd1290e57a08515a1e22756d160e6d4e8b4bfdf6ac33dbf89edeaa1dfd6c18ca2fd05
|
7
|
+
data.tar.gz: 62cd6b1146984403134cb4cf0cdf1dd6edc2762b1e215379fe2260e8e8df2d905ee34dd7937d908bc7c5a3c77a1e02b640e4cab35d2afc4f6a67b0a4461e608f
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Sıtkı Bağdat
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# TurkishSupport
|
2
|
+
|
3
|
+
A gem for Turkish character support for `String#upcase`, `String#downcase`, `String#capitalize` methods and their destructive versions like `String#upcase!`. In other words; this gem is a lighter version of the UnicodeUtils gem.
|
4
|
+
|
5
|
+
## Requirements
|
6
|
+
TurkishSupport uses refinements instead of monkey patching. So, you need to install at least v2.0.0 of Ruby.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
gem 'turkish_support'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install turkish_support
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
After installing the gem, you want to add a line before using Turkish supported version of the methods.
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
using TurkishSupport
|
28
|
+
```
|
29
|
+
|
30
|
+
Now you can use your shiny new methods like below:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
str = 'Bağcılar'
|
34
|
+
str.upcase #=> "BAĞCILAR"
|
35
|
+
str #=> "Bağcılar"
|
36
|
+
|
37
|
+
str = "İSMAİL"
|
38
|
+
str.downcase! #=> "ismail"
|
39
|
+
str #=> "ismail"
|
40
|
+
|
41
|
+
"merhaba".capitalize #=> "Merhaba"
|
42
|
+
```
|
43
|
+
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
1. Fork it ( http://github.com/sbagdat/turkish_support/fork )
|
48
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
50
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
51
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require "turkish_support/version"
|
2
|
+
|
3
|
+
module TurkishSupport
|
4
|
+
UNSUPPORTED_CHARS = {
|
5
|
+
downcase: 'çğıiöşü',
|
6
|
+
upcase: 'ÇĞIİÖŞÜ'
|
7
|
+
}
|
8
|
+
|
9
|
+
refine String do
|
10
|
+
def change_chars_for_upcase
|
11
|
+
tr UNSUPPORTED_CHARS[:downcase], UNSUPPORTED_CHARS[:upcase]
|
12
|
+
end
|
13
|
+
|
14
|
+
def change_chars_for_downcase
|
15
|
+
tr UNSUPPORTED_CHARS[:upcase], UNSUPPORTED_CHARS[:downcase]
|
16
|
+
end
|
17
|
+
|
18
|
+
def upcase
|
19
|
+
change_chars_for_upcase.send(:upcase)
|
20
|
+
end
|
21
|
+
|
22
|
+
def upcase!
|
23
|
+
replace(upcase)
|
24
|
+
end
|
25
|
+
|
26
|
+
def downcase
|
27
|
+
change_chars_for_downcase.send(:downcase)
|
28
|
+
end
|
29
|
+
|
30
|
+
def downcase!
|
31
|
+
replace(downcase)
|
32
|
+
end
|
33
|
+
|
34
|
+
def capitalize
|
35
|
+
[self[0].change_chars_for_upcase.send(:upcase), self[1..-1]].join
|
36
|
+
end
|
37
|
+
|
38
|
+
def capitalize!
|
39
|
+
replace(capitalize)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include TurkishSupport
|
4
|
+
using TurkishSupport
|
5
|
+
|
6
|
+
describe TurkishSupport do
|
7
|
+
it 'should have a version number' do
|
8
|
+
TurkishSupport::VERSION.should_not be_nil
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#upcase" do
|
12
|
+
context "with non-destructive version" do
|
13
|
+
it "does not change the original value of the string" do
|
14
|
+
turkish_alphabet = "abcçdefgğhıijklmnoöprsştuüvyz"
|
15
|
+
expect{ turkish_alphabet.upcase }.to_not change{ turkish_alphabet }
|
16
|
+
end
|
17
|
+
|
18
|
+
it "upcases all of Turkish characters" do
|
19
|
+
turkish_alphabet = "abcçdefgğhıijklmnoöprsştuüvyz"
|
20
|
+
upcased_string = turkish_alphabet.upcase
|
21
|
+
expect(upcased_string).to eq("ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "upcases English characters except i as I" do
|
25
|
+
english_alphabet = "abcdefghijklmnopqrstuvwxyz"
|
26
|
+
upcased_string = english_alphabet.upcase
|
27
|
+
expect(upcased_string).to eq("ABCDEFGHİJKLMNOPQRSTUVWXYZ")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "with destructive version" do
|
32
|
+
it "changes the original value of the string with the upcased version" do
|
33
|
+
turkish_alphabet = "abcçdefgğhıijklmnoöprsştuüvyz"
|
34
|
+
expect{ turkish_alphabet.upcase! }.to change{ turkish_alphabet }
|
35
|
+
expect(turkish_alphabet).to eq("ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "#downcase" do
|
41
|
+
context "with non-destructive version" do
|
42
|
+
it "does not change the original value of the string" do
|
43
|
+
turkish_alphabet = "ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ"
|
44
|
+
expect{ turkish_alphabet.downcase }.to_not change{ turkish_alphabet }
|
45
|
+
end
|
46
|
+
|
47
|
+
it "downcases all of Turkish characters" do
|
48
|
+
turkish_alphabet = "ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ"
|
49
|
+
downcased_string = turkish_alphabet.downcase
|
50
|
+
expect(downcased_string).to eq("abcçdefgğhıijklmnoöprsştuüvyz")
|
51
|
+
end
|
52
|
+
|
53
|
+
it "downcases English characters except I as ı" do
|
54
|
+
english_alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
55
|
+
downcased_string = english_alphabet.downcase
|
56
|
+
expect(downcased_string).to eq("abcdefghıjklmnopqrstuvwxyz")
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "with destructive version" do
|
61
|
+
it "changes the original value of the string with the downcased version" do
|
62
|
+
turkish_alphabet = "ABCÇDEFGĞHIİJKLMNOÖPRSŞTUÜVYZ"
|
63
|
+
expect{ turkish_alphabet.downcase! }.to change{ turkish_alphabet }
|
64
|
+
expect(turkish_alphabet).to eq("abcçdefgğhıijklmnoöprsştuüvyz")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "#capitalize" do
|
70
|
+
context "with non-destructive version" do
|
71
|
+
it "does not change the original value of the string" do
|
72
|
+
turkish_word = "çamur"
|
73
|
+
expect{ turkish_word.capitalize }.to_not change{ turkish_word }
|
74
|
+
end
|
75
|
+
|
76
|
+
it "capitalizes the first character of a string that starts with an unsupported Turkish character" do
|
77
|
+
turkish_words = %w[çamur ıhlamur insan ördek şahika ümraniye]
|
78
|
+
capitalized_words = turkish_words.map{ |w| w.capitalize }
|
79
|
+
expect(capitalized_words).to eq(%w[Çamur Ihlamur İnsan Ördek Şahika Ümraniye])
|
80
|
+
end
|
81
|
+
|
82
|
+
it "capitalizes the first character of an English string" do
|
83
|
+
english_word = "spy"
|
84
|
+
capitalized_string = english_word.capitalize
|
85
|
+
expect(capitalized_string).to eq("Spy")
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context "with destructive version" do
|
90
|
+
it "changes the original value of the string with the capitalized version" do
|
91
|
+
turkish_word = 'çamur'
|
92
|
+
expect{ turkish_word.capitalize! }.to change{ turkish_word }
|
93
|
+
expect(turkish_word).to eq('Çamur')
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'turkish_support/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "turkish_support"
|
8
|
+
spec.version = TurkishSupport::VERSION
|
9
|
+
spec.authors = ["Sıtkı Bağdat"]
|
10
|
+
spec.email = ["sbagdat@gmail.com"]
|
11
|
+
spec.summary = %q{Turkish characters support for upcase, downcase, etc.}
|
12
|
+
spec.description = %q{A gem for Turkish character support for String#upcase, String#downcase, String#capitalize methods and their destructive versions like String#upcase!. In other words; this gem is a lighter version of the UnicodeUtils gem. }
|
13
|
+
spec.homepage = "https://github.com/sbagdat/turkish_support"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.required_ruby_version = ">= 2.0.0"
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: turkish_support
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sıtkı Bağdat
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: 'A gem for Turkish character support for String#upcase, String#downcase,
|
56
|
+
String#capitalize methods and their destructive versions like String#upcase!. In
|
57
|
+
other words; this gem is a lighter version of the UnicodeUtils gem. '
|
58
|
+
email:
|
59
|
+
- sbagdat@gmail.com
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- ".rspec"
|
66
|
+
- ".travis.yml"
|
67
|
+
- Gemfile
|
68
|
+
- LICENSE.txt
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- lib/turkish_support.rb
|
72
|
+
- lib/turkish_support/version.rb
|
73
|
+
- spec/spec_helper.rb
|
74
|
+
- spec/turkish_support_spec.rb
|
75
|
+
- turkish_support.gemspec
|
76
|
+
homepage: https://github.com/sbagdat/turkish_support
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 2.0.0
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
requirements: []
|
95
|
+
rubyforge_project:
|
96
|
+
rubygems_version: 2.2.2
|
97
|
+
signing_key:
|
98
|
+
specification_version: 4
|
99
|
+
summary: Turkish characters support for upcase, downcase, etc.
|
100
|
+
test_files:
|
101
|
+
- spec/spec_helper.rb
|
102
|
+
- spec/turkish_support_spec.rb
|
103
|
+
has_rdoc:
|