tate 0.1.4 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.ruby-version +1 -1
- data/.travis.yml +17 -1
- data/README.md +105 -27
- data/bin/tate +28 -2
- data/lib/rules/az.yml +20 -0
- data/lib/rules/bg.yml +60 -0
- data/lib/rules/ca.yml +24 -0
- data/lib/rules/de.yml +8 -0
- data/lib/rules/es.yml +14 -0
- data/lib/rules/fr.yml +32 -0
- data/lib/rules/glyphs.yml +56 -0
- data/lib/rules/hu.yml +18 -0
- data/lib/rules/pl.yml +18 -0
- data/lib/rules/pt.yml +24 -0
- data/lib/rules/ro.yml +10 -0
- data/lib/rules/vi.yml +134 -0
- data/lib/tate.rb +18 -1
- data/lib/tate/version.rb +1 -1
- data/transliterate.gemspec +15 -13
- metadata +60 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e4c77e3b0de929008a6999082a0c5b80ce1a8e6cebe54ec95447d0edf9b238e6
|
4
|
+
data.tar.gz: d499fcedebaa5777c4ca79a4d925779b00ceec05a1fe713d66c62c938426e733
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4378213d51081fc5ba679d3a0a925df0429b0cb0cfb16eea9f945ec4148ff4dfbd5c42df0975938954af4cbafafd0781bddb5aa6d5bc6249098ae5a04324cefc
|
7
|
+
data.tar.gz: 30cc9f771bd00549a2e756f26d990749613054e3b0dd1c0492407180c798b5d09214ebc480701dcd2e5f895dfb8636c68f12729398a104f8777876c4a59c1651
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.5.1
|
data/.travis.yml
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
+
- ruby-head
|
4
|
+
- 2.5.1
|
3
5
|
- 2.2.3
|
4
6
|
- 2.3.0
|
5
|
-
before_install:
|
7
|
+
before_install:
|
8
|
+
- gem update --system
|
9
|
+
- gem --version
|
10
|
+
- gem install bundler
|
11
|
+
before_script:
|
12
|
+
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
13
|
+
- chmod +x ./cc-test-reporter
|
14
|
+
- "./cc-test-reporter before-build"
|
15
|
+
script:
|
16
|
+
- bundle exec rspec
|
17
|
+
after_script:
|
18
|
+
- "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
|
19
|
+
env:
|
20
|
+
global:
|
21
|
+
- CC_TEST_REPORTER_ID=8ec95d64844683a9ce73f086a637d7bb2c7ae00a0042c4efa75ee34637a0fd58
|
data/README.md
CHANGED
@@ -1,48 +1,55 @@
|
|
1
|
-
# Tate
|
1
|
+
# Tate ✍️
|
2
2
|
|
3
|
+
[](https://travis-ci.org/krmbzds/tate)
|
4
|
+
[](https://codeclimate.com/github/krmbzds/tate/test_coverage)
|
5
|
+
[](https://api.codeclimate.com/v1/badges/3283dc64bcae64dff214/maintainability)
|
6
|
+
[](https://rubygems.org/gems/tate)
|
7
|
+
[](https://rubygems.org/gems/tate)
|
3
8
|
|
4
|
-
|
5
|
-
[](https://codeclimate.com/github/krmbzds/tate)
|
6
|
-
[](https://rubygems.org/gems/tate)
|
7
|
-
[](https://rubygems.org/gems/tate)
|
9
|
+
**Tate** converts accented characters and transliterates non-latin scripts to their closest ASCII equivalent.
|
8
10
|
|
9
|
-
|
10
|
-
**tate** helps you convert accented characters to ASCII.
|
11
|
-
|
12
|
-
**tate** is a productivity tool, it behaves like a standard Unix application and can be chained with other Unix commands. It only reads from standard input and writes to standard output.
|
11
|
+
**Tate** is a productivity tool, it behaves like a standard Unix application and can be chained with other Unix commands. It reads from standard input and writes to standard output. You can use it either as a [commandline utility](#commandline) or a [library](#library).
|
13
12
|
|
14
13
|
## Examples
|
15
14
|
|
16
15
|
Let's say you have a French sentence with a lot of weird characters and you want to convert it into ASCII in the most representative way. You can use:
|
17
16
|
|
18
17
|
```sh
|
19
|
-
echo
|
18
|
+
echo 'Le cœur de la crémiére' | tate #=> Le coeur de la cremiere
|
20
19
|
```
|
21
20
|
|
22
|
-
|
21
|
+
Or some Bulgarian text you can't read:
|
23
22
|
|
24
|
-
```
|
25
|
-
|
23
|
+
```sh
|
24
|
+
echo 'Здравей!' | tate --lang=bg #=> Zdravey!
|
26
25
|
```
|
27
26
|
|
28
|
-
|
27
|
+
Set language using `lang` option for custom filters, e.g. German:
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
<pre>
|
30
|
+
echo 'Von gro<b>ß</b>en Bl<b>ö</b>cken haut man gro<b>ß</b>e St<b>ü</b>cke.' | tate --lang=de
|
31
|
+
</pre>
|
33
32
|
|
34
|
-
|
33
|
+
Letters ö, ü and ß will be transliterated based on German transliteration rules:
|
35
34
|
|
35
|
+
<pre>
|
36
|
+
Von gro<b>ss</b>en Bl<b>oe</b>cken haut man grosse St<b>ue</b>cke.
|
37
|
+
</pre>
|
36
38
|
|
37
|
-
|
39
|
+
Language specific punctuation will be converted to closest ASCII equivalent.
|
38
40
|
|
39
|
-
|
41
|
+
For example, in Catalan, notice how the quotes (cometes franceses) and the interpunct (punt volat) are transliterated:
|
42
|
+
|
43
|
+
```
|
44
|
+
«Dóna amor que seràs feliç!». Això, il·lús company geniüt, ja és un lluït rètol blavís d’onze kWh.
|
45
|
+
"Dona amor que seras felic!". Aixo, il-lus company geniut, ja es un lluit retol blavis d'onze kWh.
|
46
|
+
```
|
40
47
|
|
41
48
|
## Installation
|
42
49
|
|
43
50
|
Add this line to your application's Gemfile:
|
44
51
|
|
45
|
-
```
|
52
|
+
```rb
|
46
53
|
gem 'tate'
|
47
54
|
```
|
48
55
|
|
@@ -58,20 +65,91 @@ Or install it yourself as:
|
|
58
65
|
$ gem install tate
|
59
66
|
```
|
60
67
|
|
68
|
+
## Usage
|
69
|
+
|
70
|
+
<h3 id="library">
|
71
|
+
Ruby Library
|
72
|
+
</h3>
|
73
|
+
|
74
|
+
```rb
|
75
|
+
require 'tate'
|
76
|
+
Tate::transliterate('Zəfər', language='az') #=> Zefer
|
77
|
+
```
|
78
|
+
|
79
|
+
<h3 id="commandline">
|
80
|
+
Commandline Utility
|
81
|
+
</h3>
|
82
|
+
|
83
|
+
```
|
84
|
+
Usage: tate [options]
|
85
|
+
-l, --lang=[LANGUAGE] Set language for custom filters
|
86
|
+
-h, --help Show this message
|
87
|
+
-v, --version Show version
|
88
|
+
```
|
89
|
+
|
90
|
+
#### Interactive Mode
|
91
|
+
|
92
|
+
If you call `tate` without providing any arguments, it will expect you to provide input using standard input (keyboard). After you are done typing you can use `cmd + D` to trigger `EOL (End of Line)` and the result will printed in the next line.
|
93
|
+
|
94
|
+
#### Standard Streams
|
95
|
+
|
96
|
+
You can pipe the output of another command into tate.
|
97
|
+
|
98
|
+
```sh
|
99
|
+
curl gov.bg/bg | tate --lang=bg > index.html
|
100
|
+
```
|
101
|
+
|
102
|
+
## Language Support
|
103
|
+
|
104
|
+
There are custom filters for:
|
105
|
+
|
106
|
+
```
|
107
|
+
Azeri, Bulgarian, Catalan, French, German, Hungarian, Polish, Romanian, Spanish, and Vietnamese.
|
108
|
+
```
|
109
|
+
|
110
|
+
The following languages are known to work (w/o custom filters):
|
111
|
+
|
112
|
+
```
|
113
|
+
Croatian, Czech, Danish, Esperanto, Estonian, Finnish, Icelandic, Latvian, Lithuania, Norwegian, Portuguese, Scottish, Slovak, Slovenian, Swedish, Turkish, and Welsh.
|
114
|
+
```
|
115
|
+
|
116
|
+
What's next?
|
117
|
+
|
118
|
+
```
|
119
|
+
Russian, Irish, Arabic, and Yoruba.
|
120
|
+
```
|
121
|
+
|
122
|
+
## Is it any good?
|
123
|
+
|
124
|
+
Yes.
|
125
|
+
|
61
126
|
## Contributing
|
62
127
|
|
63
128
|
1. Fork it (https://github.com/krmbzds/tate/fork)
|
64
|
-
2. Create your feature branch (`git checkout -b
|
65
|
-
3. Commit your changes (`git commit -am 'Add
|
66
|
-
4. Push to the branch (`git push origin
|
129
|
+
2. Create your feature branch (`git checkout -b add-irish-support`)
|
130
|
+
3. Commit your changes (`git commit -am 'Add Irish language support'`)
|
131
|
+
4. Push to the branch (`git push origin add-irish-support`)
|
67
132
|
5. Create a new Pull Request
|
68
133
|
|
134
|
+
### Custom Filters
|
135
|
+
|
136
|
+
You can add custom language filters under `lib/rules` directory.
|
137
|
+
|
138
|
+
### Donations
|
139
|
+
|
140
|
+
You can donate me at [Librepay](https://liberapay.com/krmbzds/donate). Thanks! ☕️
|
141
|
+
|
69
142
|
## Trivia
|
70
143
|
|
71
|
-
**tate** is short for **
|
144
|
+
**tate** is short for **t**ransliter**ate**.
|
145
|
+
|
72
146
|
Nobody has time to type transliterate in the terminal.
|
73
147
|
|
74
148
|
## License
|
75
149
|
|
76
|
-
|
77
|
-
|
150
|
+
Copyright © 2018 [Kerem Bozdas][Personal Webpage]
|
151
|
+
|
152
|
+
This project is available under the terms of the [MIT License][License].
|
153
|
+
|
154
|
+
[Personal Webpage]: http://kerembozdas.com
|
155
|
+
[License]: http://kerem.mit-license.org
|
data/bin/tate
CHANGED
@@ -4,6 +4,32 @@
|
|
4
4
|
lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
|
5
5
|
$LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
|
6
6
|
|
7
|
-
require
|
7
|
+
require 'tate'
|
8
|
+
require 'optionparser'
|
8
9
|
|
9
|
-
|
10
|
+
options = {}
|
11
|
+
|
12
|
+
option_parser = OptionParser.new do |opts|
|
13
|
+
opts.banner = 'Usage: tate [options]'
|
14
|
+
opts.on("-l[LANGUAGE]", "--lang=[LANGUAGE]", String, 'Set language for custom filters') do |language|
|
15
|
+
options[:language] = language
|
16
|
+
end
|
17
|
+
opts.on('-h', '--help', 'Show this message') do
|
18
|
+
options[:help] = true
|
19
|
+
end
|
20
|
+
opts.on('-v', '--version', 'Show version') do
|
21
|
+
options[:version] = Tate::VERSION
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
option_parser.parse!
|
26
|
+
|
27
|
+
if options[:language]
|
28
|
+
STDOUT.puts(Tate::transliterate(STDIN.read, language=options[:language]))
|
29
|
+
elsif options[:version]
|
30
|
+
STDOUT.puts(options[:version])
|
31
|
+
elsif options.empty?
|
32
|
+
STDOUT.puts(Tate::transliterate(STDIN.read))
|
33
|
+
else
|
34
|
+
STDOUT.puts(option_parser.help)
|
35
|
+
end
|
data/lib/rules/az.yml
ADDED
data/lib/rules/bg.yml
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
а: "a"
|
2
|
+
А: "A"
|
3
|
+
б: "b"
|
4
|
+
Б: "B"
|
5
|
+
в: "v"
|
6
|
+
В: "V"
|
7
|
+
г: "g"
|
8
|
+
Г: "G"
|
9
|
+
д: "d"
|
10
|
+
Д: "D"
|
11
|
+
е: "e"
|
12
|
+
Е: "E"
|
13
|
+
ж: "zh"
|
14
|
+
Ж: "Zh"
|
15
|
+
з: "z"
|
16
|
+
З: "Z"
|
17
|
+
и: "i"
|
18
|
+
И: "I"
|
19
|
+
й: "y"
|
20
|
+
Й: "Y"
|
21
|
+
к: "k"
|
22
|
+
К: "K"
|
23
|
+
л: "l"
|
24
|
+
Л: "L"
|
25
|
+
м: "m"
|
26
|
+
М: "M"
|
27
|
+
н: "n"
|
28
|
+
Н: "N"
|
29
|
+
о: "o"
|
30
|
+
О: "O"
|
31
|
+
п: "p"
|
32
|
+
П: "P"
|
33
|
+
р: "r"
|
34
|
+
Р: "R"
|
35
|
+
с: "s"
|
36
|
+
С: "S"
|
37
|
+
т: "t"
|
38
|
+
Т: "T"
|
39
|
+
у: "u"
|
40
|
+
У: "U"
|
41
|
+
ф: "f"
|
42
|
+
Ф: "F"
|
43
|
+
х: "h"
|
44
|
+
Х: "H"
|
45
|
+
ц: "ts"
|
46
|
+
Ц: "Ts"
|
47
|
+
ч: "ch"
|
48
|
+
Ч: "Ch"
|
49
|
+
ш: "sh"
|
50
|
+
Ш: "Sh"
|
51
|
+
щ: "sht"
|
52
|
+
Щ: "Sht"
|
53
|
+
ъ: "a"
|
54
|
+
Ъ: "A"
|
55
|
+
ь: "y"
|
56
|
+
Ь: "Y"
|
57
|
+
ю: "yu"
|
58
|
+
Ю: "Yu"
|
59
|
+
я: "ya"
|
60
|
+
Я: "Ya"
|
data/lib/rules/ca.yml
ADDED
data/lib/rules/de.yml
ADDED
data/lib/rules/es.yml
ADDED
data/lib/rules/fr.yml
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
à: "a"
|
2
|
+
â: "a"
|
3
|
+
æ: "ae"
|
4
|
+
ç: "c"
|
5
|
+
é: "e"
|
6
|
+
è: "e"
|
7
|
+
ê: "e"
|
8
|
+
ë: "e"
|
9
|
+
î: "i"
|
10
|
+
ï: "i"
|
11
|
+
ô: "o"
|
12
|
+
œ: "oe"
|
13
|
+
ù: "u"
|
14
|
+
û: "u"
|
15
|
+
ü: "u"
|
16
|
+
ÿ: "y"
|
17
|
+
À: "A"
|
18
|
+
Â: "A"
|
19
|
+
Æ: "Ae"
|
20
|
+
Ç: "C"
|
21
|
+
É: "E"
|
22
|
+
È: "E"
|
23
|
+
Ê: "E"
|
24
|
+
Ë: "E"
|
25
|
+
Î: "I"
|
26
|
+
Ï: "I"
|
27
|
+
Ô: "O"
|
28
|
+
Œ: "Oe"
|
29
|
+
Ù: "U"
|
30
|
+
Û: "U"
|
31
|
+
Ü: "U"
|
32
|
+
Ÿ: "Y"
|
@@ -0,0 +1,56 @@
|
|
1
|
+
¡: "!"
|
2
|
+
¢: " cent(s)"
|
3
|
+
£: "GBP "
|
4
|
+
¥: "CNY "
|
5
|
+
¨: '"'
|
6
|
+
©: "(c)"
|
7
|
+
«: '"'
|
8
|
+
®: "(R)"
|
9
|
+
°: " degree(s)"
|
10
|
+
±: "+-"
|
11
|
+
²: "^2"
|
12
|
+
³: "^3"
|
13
|
+
´: "'"
|
14
|
+
µ: "nM"
|
15
|
+
·: "-"
|
16
|
+
»: '"'
|
17
|
+
¼: "1/4"
|
18
|
+
½: "1/2"
|
19
|
+
¾: "3/4"
|
20
|
+
¿: "?"
|
21
|
+
×: "*"
|
22
|
+
ˆ: "^"
|
23
|
+
˜: "~"
|
24
|
+
–: "-"
|
25
|
+
—: "-"
|
26
|
+
‘: "'"
|
27
|
+
’: "'"
|
28
|
+
‚: ","
|
29
|
+
“: '"'
|
30
|
+
”: '"'
|
31
|
+
„: '"'
|
32
|
+
•: "-"
|
33
|
+
…: "..."
|
34
|
+
′: "'"
|
35
|
+
″: '"'
|
36
|
+
‹: "<"
|
37
|
+
›: ">"
|
38
|
+
⁄: "/"
|
39
|
+
€: "EUR"
|
40
|
+
™: "(TM)"
|
41
|
+
←: "<-"
|
42
|
+
→: "->"
|
43
|
+
↔: "<->"
|
44
|
+
⇐: "<="
|
45
|
+
⇒: "=>"
|
46
|
+
⇔: "<=>"
|
47
|
+
−: "-"
|
48
|
+
∗: "*"
|
49
|
+
∴: "therefore"
|
50
|
+
∼: "~"
|
51
|
+
≠: "=/="
|
52
|
+
≤: "<="
|
53
|
+
≥: "=>"
|
54
|
+
⋅: "-"
|
55
|
+
〈: "<"
|
56
|
+
〉: ">"
|
data/lib/rules/hu.yml
ADDED
data/lib/rules/pl.yml
ADDED
data/lib/rules/pt.yml
ADDED
data/lib/rules/ro.yml
ADDED
data/lib/rules/vi.yml
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
à: "a"
|
2
|
+
á: "a"
|
3
|
+
ạ: "a"
|
4
|
+
ả: "a"
|
5
|
+
ã: "a"
|
6
|
+
â: "a"
|
7
|
+
ầ: "a"
|
8
|
+
ấ: "a"
|
9
|
+
ậ: "a"
|
10
|
+
ẩ: "a"
|
11
|
+
ẫ: "a"
|
12
|
+
ă: "a"
|
13
|
+
ằ: "a"
|
14
|
+
ắ: "a"
|
15
|
+
ặ: "a"
|
16
|
+
ẳ: "a"
|
17
|
+
ẵ: "a"
|
18
|
+
À: "A"
|
19
|
+
Á: "A"
|
20
|
+
Ạ: "A"
|
21
|
+
Ả: "A"
|
22
|
+
Ã: "A"
|
23
|
+
Â: "A"
|
24
|
+
Ầ: "A"
|
25
|
+
Ấ: "A"
|
26
|
+
Ậ: "A"
|
27
|
+
Ẩ: "A"
|
28
|
+
Ẫ: "A"
|
29
|
+
Ă: "A"
|
30
|
+
Ằ: "A"
|
31
|
+
Ắ: "A"
|
32
|
+
Ặ: "A"
|
33
|
+
Ẳ: "A"
|
34
|
+
Ẵ: "A"
|
35
|
+
ì: "i"
|
36
|
+
í: "i"
|
37
|
+
ị: "i"
|
38
|
+
ỉ: "i"
|
39
|
+
ĩ: "i"
|
40
|
+
Ì: "I"
|
41
|
+
Í: "I"
|
42
|
+
Ị: "I"
|
43
|
+
Ỉ: "I"
|
44
|
+
Ĩ: "I"
|
45
|
+
ù: "u"
|
46
|
+
ú: "u"
|
47
|
+
ụ: "u"
|
48
|
+
ủ: "u"
|
49
|
+
ũ: "u"
|
50
|
+
ư: "u"
|
51
|
+
ừ: "u"
|
52
|
+
ứ: "u"
|
53
|
+
ự: "u"
|
54
|
+
ử: "u"
|
55
|
+
ữ: "u"
|
56
|
+
Ù: "U"
|
57
|
+
Ú: "U"
|
58
|
+
Ụ: "U"
|
59
|
+
Ủ: "U"
|
60
|
+
Ũ: "U"
|
61
|
+
Ư: "U"
|
62
|
+
Ừ: "U"
|
63
|
+
Ứ: "U"
|
64
|
+
Ự: "U"
|
65
|
+
Ử: "U"
|
66
|
+
Ữ: "U"
|
67
|
+
è: "e"
|
68
|
+
é: "e"
|
69
|
+
ẹ: "e"
|
70
|
+
ẻ: "e"
|
71
|
+
ẽ: "e"
|
72
|
+
ê: "e"
|
73
|
+
ề: "e"
|
74
|
+
ế: "e"
|
75
|
+
ệ: "e"
|
76
|
+
ể: "e"
|
77
|
+
ễ: "e"
|
78
|
+
È: "E"
|
79
|
+
É: "E"
|
80
|
+
Ẹ: "E"
|
81
|
+
Ẻ: "E"
|
82
|
+
Ẽ: "E"
|
83
|
+
Ê: "E"
|
84
|
+
Ề: "E"
|
85
|
+
Ế: "E"
|
86
|
+
Ệ: "E"
|
87
|
+
Ể: "E"
|
88
|
+
Ễ: "E"
|
89
|
+
ò: "o"
|
90
|
+
ó: "o"
|
91
|
+
ọ: "o"
|
92
|
+
ỏ: "o"
|
93
|
+
õ: "o"
|
94
|
+
ô: "o"
|
95
|
+
ồ: "o"
|
96
|
+
ố: "o"
|
97
|
+
ộ: "o"
|
98
|
+
ổ: "o"
|
99
|
+
ỗ: "o"
|
100
|
+
ơ: "o"
|
101
|
+
ờ: "o"
|
102
|
+
ớ: "o"
|
103
|
+
ợ: "o"
|
104
|
+
ở: "o"
|
105
|
+
ỡ: "o"
|
106
|
+
Ò: "O"
|
107
|
+
Ó: "O"
|
108
|
+
Ọ: "O"
|
109
|
+
Ỏ: "O"
|
110
|
+
Õ: "O"
|
111
|
+
Ô: "O"
|
112
|
+
Ồ: "O"
|
113
|
+
Ố: "O"
|
114
|
+
Ộ: "O"
|
115
|
+
Ổ: "O"
|
116
|
+
Ỗ: "O"
|
117
|
+
Ơ: "O"
|
118
|
+
Ờ: "O"
|
119
|
+
Ớ: "O"
|
120
|
+
Ợ: "O"
|
121
|
+
Ở: "O"
|
122
|
+
Ỡ: "O"
|
123
|
+
ỳ: "y"
|
124
|
+
ý: "y"
|
125
|
+
ỵ: "y"
|
126
|
+
ỷ: "y"
|
127
|
+
ỹ: "y"
|
128
|
+
Ỳ: "Y"
|
129
|
+
Ý: "Y"
|
130
|
+
Ỵ: "Y"
|
131
|
+
Ỷ: "Y"
|
132
|
+
Ỹ: "Y"
|
133
|
+
đ: "d"
|
134
|
+
Đ: "D"
|
data/lib/tate.rb
CHANGED
@@ -1,12 +1,29 @@
|
|
1
|
+
lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
|
2
|
+
$LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
|
3
|
+
|
1
4
|
require "tate/version"
|
2
5
|
|
3
6
|
require 'active_support/core_ext/string/multibyte'
|
4
7
|
require 'active_support/i18n'
|
8
|
+
require 'yaml'
|
5
9
|
|
6
10
|
module Tate
|
7
|
-
def self.transliterate(string, replacement = "?".freeze)
|
11
|
+
def self.transliterate(string, language = nil, replacement = "?".freeze)
|
12
|
+
string = language_filter(string, language)
|
8
13
|
I18n.transliterate(ActiveSupport::Multibyte::Unicode.normalize(
|
9
14
|
ActiveSupport::Multibyte::Unicode.tidy_bytes(string), :c),
|
10
15
|
:replacement => replacement)
|
11
16
|
end
|
17
|
+
|
18
|
+
def self.language_filter(string, language)
|
19
|
+
glyph_rules = load_rules('glyphs')
|
20
|
+
language_rules = load_rules(language)
|
21
|
+
conversion_map = glyph_rules.merge(language_rules)
|
22
|
+
re = Regexp.new(conversion_map.keys.map { |x| Regexp.escape(x) }.join('|'))
|
23
|
+
string.gsub(re, conversion_map)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.load_rules(language)
|
27
|
+
YAML.load_file("lib/rules/#{language}.yml") rescue {}
|
28
|
+
end
|
12
29
|
end
|
data/lib/tate/version.rb
CHANGED
data/transliterate.gemspec
CHANGED
@@ -4,22 +4,24 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'tate/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'tate'
|
8
8
|
spec.version = Tate::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Kerem Bozdas']
|
10
|
+
spec.email = ['krmbzds.github@gmail.com']
|
11
11
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
12
|
+
spec.summary = 'Convert accented characters and transliterate non-latin alphabets to ASCII.'
|
13
|
+
spec.description = 'Convert accented characters and transliterate non-latin alphabets to ASCII.'
|
14
|
+
spec.homepage = 'https://github.com/krmbzds/tate'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
-
spec.bindir =
|
18
|
-
spec.executables = [
|
19
|
-
spec.require_paths = [
|
17
|
+
spec.bindir = 'bin'
|
18
|
+
spec.executables = ['tate']
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_runtime_dependency 'activerecord'
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
21
|
+
spec.add_runtime_dependency 'activerecord'
|
22
|
+
spec.add_development_dependency 'bundler'
|
23
|
+
spec.add_development_dependency 'rake'
|
24
|
+
spec.add_development_dependency 'rspec'
|
25
|
+
spec.add_development_dependency 'simplecov'
|
26
|
+
spec.add_development_dependency 'simplecov-console'
|
25
27
|
end
|
metadata
CHANGED
@@ -1,78 +1,101 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kerem Bozdas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '4.2'
|
20
17
|
- - ">="
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
19
|
+
version: '0'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '4.2'
|
30
24
|
- - ">="
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
26
|
+
version: '0'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: bundler
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
36
30
|
requirements:
|
37
|
-
- - "
|
31
|
+
- - ">="
|
38
32
|
- !ruby/object:Gem::Version
|
39
|
-
version: '
|
33
|
+
version: '0'
|
40
34
|
type: :development
|
41
35
|
prerelease: false
|
42
36
|
version_requirements: !ruby/object:Gem::Requirement
|
43
37
|
requirements:
|
44
|
-
- - "
|
38
|
+
- - ">="
|
45
39
|
- !ruby/object:Gem::Version
|
46
|
-
version: '
|
40
|
+
version: '0'
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: rake
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
50
44
|
requirements:
|
51
|
-
- - "
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: '
|
47
|
+
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
51
|
requirements:
|
58
|
-
- - "
|
52
|
+
- - ">="
|
59
53
|
- !ruby/object:Gem::Version
|
60
|
-
version: '
|
54
|
+
version: '0'
|
61
55
|
- !ruby/object:Gem::Dependency
|
62
56
|
name: rspec
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
64
58
|
requirements:
|
65
|
-
- - "
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
66
74
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
75
|
+
version: '0'
|
68
76
|
type: :development
|
69
77
|
prerelease: false
|
70
78
|
version_requirements: !ruby/object:Gem::Requirement
|
71
79
|
requirements:
|
72
|
-
- - "
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov-console
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
73
95
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
75
|
-
description:
|
96
|
+
version: '0'
|
97
|
+
description: Convert accented characters and transliterate non-latin alphabets to
|
98
|
+
ASCII.
|
76
99
|
email:
|
77
100
|
- krmbzds.github@gmail.com
|
78
101
|
executables:
|
@@ -91,6 +114,18 @@ files:
|
|
91
114
|
- bin/console
|
92
115
|
- bin/setup
|
93
116
|
- bin/tate
|
117
|
+
- lib/rules/az.yml
|
118
|
+
- lib/rules/bg.yml
|
119
|
+
- lib/rules/ca.yml
|
120
|
+
- lib/rules/de.yml
|
121
|
+
- lib/rules/es.yml
|
122
|
+
- lib/rules/fr.yml
|
123
|
+
- lib/rules/glyphs.yml
|
124
|
+
- lib/rules/hu.yml
|
125
|
+
- lib/rules/pl.yml
|
126
|
+
- lib/rules/pt.yml
|
127
|
+
- lib/rules/ro.yml
|
128
|
+
- lib/rules/vi.yml
|
94
129
|
- lib/tate.rb
|
95
130
|
- lib/tate/version.rb
|
96
131
|
- transliterate.gemspec
|
@@ -113,8 +148,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
148
|
version: '0'
|
114
149
|
requirements: []
|
115
150
|
rubyforge_project:
|
116
|
-
rubygems_version: 2.
|
151
|
+
rubygems_version: 2.7.6
|
117
152
|
signing_key:
|
118
153
|
specification_version: 4
|
119
|
-
summary:
|
154
|
+
summary: Convert accented characters and transliterate non-latin alphabets to ASCII.
|
120
155
|
test_files: []
|