tate 0.1.4 → 1.0.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
- SHA1:
3
- metadata.gz: ca3a8b1963d279a5da8db304b694ea89347a783b
4
- data.tar.gz: 170b51e50d18558a30c6948cecfb8b512b6c1460
2
+ SHA256:
3
+ metadata.gz: e4c77e3b0de929008a6999082a0c5b80ce1a8e6cebe54ec95447d0edf9b238e6
4
+ data.tar.gz: d499fcedebaa5777c4ca79a4d925779b00ceec05a1fe713d66c62c938426e733
5
5
  SHA512:
6
- metadata.gz: cac3eedc7abbfce4db70c2e2512f25c7b9bc10c4b1d098afca3dc1d4f5ccfdf6719b80eb222ed8fd1b8b26f19e7d929ca29e6a52848bc494bcb078e51899171a
7
- data.tar.gz: 8332abe1a9944fa6ae6c6a9425280a07fe9049c4c2a652759a95aedaed4f0cd671beb438fbf1384e45051917a1ec654a8b0dd7efdd1585f4437448e228ee0eb4
6
+ metadata.gz: 4378213d51081fc5ba679d3a0a925df0429b0cb0cfb16eea9f945ec4148ff4dfbd5c42df0975938954af4cbafafd0781bddb5aa6d5bc6249098ae5a04324cefc
7
+ data.tar.gz: 30cc9f771bd00549a2e756f26d990749613054e3b0dd1c0492407180c798b5d09214ebc480701dcd2e5f895dfb8636c68f12729398a104f8777876c4a59c1651
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.3.0
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: gem install bundler -v 1.11.2
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
+ [![Build Status](https://img.shields.io/travis/krmbzds/tate.svg)](https://travis-ci.org/krmbzds/tate)
4
+ [![Code Coverage](https://img.shields.io/codeclimate/coverage/krmbzds/tate.svg)](https://codeclimate.com/github/krmbzds/tate/test_coverage)
5
+ [![Maintainability](https://img.shields.io/codeclimate/maintainability/krmbzds/tate.svg)](https://api.codeclimate.com/v1/badges/3283dc64bcae64dff214/maintainability)
6
+ [![Downloaded](https://img.shields.io/gem/dt/tate.svg)](https://rubygems.org/gems/tate)
7
+ [![Gem Version](https://img.shields.io/gem/v/tate.svg)](https://rubygems.org/gems/tate)
3
8
 
4
- [![Travis](https://img.shields.io/travis/krmbzds/tate.svg)](https://travis-ci.org/krmbzds/tate)
5
- [![Code Climate](https://img.shields.io/codeclimate/github/krmbzds/tate.svg)](https://codeclimate.com/github/krmbzds/tate)
6
- [![Gem](https://img.shields.io/gem/dt/tate.svg)](https://rubygems.org/gems/tate)
7
- [![Gem](https://img.shields.io/gem/v/tate.svg)](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 "Le cœur de la crémiére" | tate
18
+ echo 'Le cœur de la crémiére' | tate #=> Le coeur de la cremiere
20
19
  ```
21
20
 
22
- This will output:
21
+ Or some Bulgarian text you can't read:
23
22
 
24
- ```
25
- Le coeur de la cremiere
23
+ ```sh
24
+ echo 'Здравей!' | tate --lang=bg #=> Zdravey!
26
25
  ```
27
26
 
28
- Or you might want to create a purely ASCII version of some file:
27
+ Set language using `lang` option for custom filters, e.g. German:
29
28
 
30
- ```sh
31
- cat customers.csv | tate > customers_tated.csv
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
- If you call `tate` without providing any input, like a standard Unix command it will expect you to provide input using the keyboard. After you are done typing you can use `cmd + D` shortcut to trigger `EOL (End of Line)`. You will see that the text you typed into the terminal is converted to ASCII.
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
- ## Is it any good?
39
+ Language specific punctuation will be converted to closest ASCII equivalent.
38
40
 
39
- Yes.
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
- ```ruby
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 my-new-feature`)
65
- 3. Commit your changes (`git commit -am 'Add some feature'`)
66
- 4. Push to the branch (`git push origin my-new-feature`)
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 **transliterate**.
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
- The MIT License (MIT)
77
- Copyright (c) 2016 Kerem Bozdas
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 "tate"
7
+ require 'tate'
8
+ require 'optionparser'
8
9
 
9
- STDOUT.puts Tate::transliterate(STDIN.read)
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
@@ -0,0 +1,20 @@
1
+ c: "j"
2
+ ç: "ch"
3
+ ə: "e"
4
+ ğ: "gh"
5
+ x: "kh"
6
+ ı: "i"
7
+ j: "zh"
8
+ q: "g"
9
+ ş: "sh"
10
+ ü: "u"
11
+ C: "J"
12
+ Ç: "Ch"
13
+ Ə: "E"
14
+ Ğ: "Gh"
15
+ X: "Kh"
16
+ İ: "I"
17
+ J: "Zh"
18
+ Q: "G"
19
+ Ş: "Sh"
20
+ Ü: "U"
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
@@ -0,0 +1,24 @@
1
+ à: "a"
2
+ á: "a"
3
+ ç: "c"
4
+ é: "e"
5
+ è: "e"
6
+ ë: "e"
7
+ í: "i"
8
+ ï: "i"
9
+ ó: "o"
10
+ ò: "o"
11
+ ú: "u"
12
+ ü: "u"
13
+ À: "A"
14
+ Á: "A"
15
+ Ç: "C"
16
+ É: "E"
17
+ È: "E"
18
+ Ë: "E"
19
+ Í: "I"
20
+ Ï: "I"
21
+ Ó: "O"
22
+ Ò: "O"
23
+ Ú: "U"
24
+ Ü: "U"
data/lib/rules/de.yml ADDED
@@ -0,0 +1,8 @@
1
+ ä: "ae"
2
+ é: "e"
3
+ ü: "ue"
4
+ ö: "oe"
5
+ Ä: "Ae"
6
+ Ü: "Ue"
7
+ Ö: "Oe"
8
+ ß: "ss"
data/lib/rules/es.yml ADDED
@@ -0,0 +1,14 @@
1
+ á: "a"
2
+ é: "e"
3
+ í: "i"
4
+ ó: "o"
5
+ ú: "u"
6
+ ü: "u"
7
+ ñ: "n"
8
+ Á: "A"
9
+ É: "E"
10
+ Í: "I"
11
+ Ó: "O"
12
+ Ú: "U"
13
+ Ü: "U"
14
+ Ñ: "N"
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
@@ -0,0 +1,18 @@
1
+ á: "a"
2
+ é: "e"
3
+ í: "i"
4
+ ó: "o"
5
+ ö: "o"
6
+ ő: "o"
7
+ ú: "u"
8
+ ü: "u"
9
+ ű: "u"
10
+ Á: "A"
11
+ É: "E"
12
+ Í: "I"
13
+ Ó: "O"
14
+ Ö: "O"
15
+ Ő: "O"
16
+ Ú: "U"
17
+ Ü: "U"
18
+ Ű: "U"
data/lib/rules/pl.yml ADDED
@@ -0,0 +1,18 @@
1
+ ą: "a"
2
+ ć: "c"
3
+ ę: "e"
4
+ ł: "l"
5
+ ń: "n"
6
+ ó: "o"
7
+ ś: "s"
8
+ ź: "z"
9
+ ż: "z"
10
+ Ą: "A"
11
+ Ć: "C"
12
+ Ę: "E"
13
+ Ł: "L"
14
+ Ń: "N"
15
+ Ó: "O"
16
+ Ś: "S"
17
+ Ź: "Z"
18
+ Ż: "Z"
data/lib/rules/pt.yml ADDED
@@ -0,0 +1,24 @@
1
+ á: "a"
2
+ à: "a"
3
+ ã: "a"
4
+ â: "a"
5
+ é: "e"
6
+ ê: "e"
7
+ í: "i"
8
+ ó: "o"
9
+ õ: "o"
10
+ ú: "u"
11
+ Á: "A"
12
+ À: "A"
13
+ Ã: "A"
14
+ É: "E"
15
+ Ê: "E"
16
+ Í: "I"
17
+ Ó: "O"
18
+ Õ: "O"
19
+ Ú: "U"
20
+ Æ: "Ae"
21
+ æ: "ae"
22
+ º: "o"
23
+ ª: "a"
24
+ ç: "c"
data/lib/rules/ro.yml ADDED
@@ -0,0 +1,10 @@
1
+ ă: "a"
2
+ â: "a"
3
+ î: "i"
4
+ ș: "s"
5
+ ț: "t"
6
+ Ă: "A"
7
+ Â: "A"
8
+ Î: "I"
9
+ Ș: "S"
10
+ Ț: "T"
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
@@ -1,3 +1,3 @@
1
1
  module Tate
2
- VERSION = "0.1.4"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -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 = "tate"
7
+ spec.name = 'tate'
8
8
  spec.version = Tate::VERSION
9
- spec.authors = ["Kerem Bozdas"]
10
- spec.email = ["krmbzds.github@gmail.com"]
9
+ spec.authors = ['Kerem Bozdas']
10
+ spec.email = ['krmbzds.github@gmail.com']
11
11
 
12
- spec.summary = "Replace accented characters with ASCII"
13
- spec.description = "Replace accented characters with ASCII"
14
- spec.homepage = "https://github.com/krmbzds/tate"
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 = "bin"
18
- spec.executables = ["tate"]
19
- spec.require_paths = ["lib"]
17
+ spec.bindir = 'bin'
18
+ spec.executables = ['tate']
19
+ spec.require_paths = ['lib']
20
20
 
21
- spec.add_runtime_dependency 'activerecord', '~> 4.2', '>= 4.2.5.1'
22
- spec.add_development_dependency "bundler", "~> 1.11"
23
- spec.add_development_dependency "rake", "~> 10.0"
24
- spec.add_development_dependency "rspec", "~> 3.0"
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.1.4
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: 2016-01-27 00:00:00.000000000 Z
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: 4.2.5.1
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: 4.2.5.1
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: '1.11'
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: '1.11'
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: '10.0'
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: '10.0'
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: '3.0'
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: '3.0'
75
- description: Replace accented characters with ASCII
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.5.1
151
+ rubygems_version: 2.7.6
117
152
  signing_key:
118
153
  specification_version: 4
119
- summary: Replace accented characters with ASCII
154
+ summary: Convert accented characters and transliterate non-latin alphabets to ASCII.
120
155
  test_files: []