daud_coder 0.0.1 → 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.
- data/bin/parse_daud +0 -0
- data/bin/to_daud +0 -0
- data/lib/daud_coder/daud_decoder.rb +31 -0
- data/lib/daud_coder/daud_encoder.rb +16 -0
- data/lib/daud_coder/encodings.rb +75 -0
- metadata +5 -2
data/bin/parse_daud
CHANGED
File without changes
|
data/bin/to_daud
CHANGED
File without changes
|
@@ -0,0 +1,31 @@
|
|
1
|
+
#
|
2
|
+
# Converts a string with Da'ud notation into a unicode string
|
3
|
+
#
|
4
|
+
require 'daud_coder/encodings'
|
5
|
+
class DaudCoder::DaudDecoder
|
6
|
+
|
7
|
+
def daud_map
|
8
|
+
@@daud_map ||= DaudCoder::Encodings.daud_to_unicode_map
|
9
|
+
end
|
10
|
+
|
11
|
+
def target_encoding
|
12
|
+
@@encoding ||= Encoding.default_internal || Encoding.find("UTF-8")
|
13
|
+
end
|
14
|
+
|
15
|
+
def decode(s)
|
16
|
+
result = ""
|
17
|
+
until s.empty? do
|
18
|
+
m = /\{(..)\}/.match(s)
|
19
|
+
if (m)
|
20
|
+
result << s[0..m.begin(0) - 1] unless m.begin(0) == 0
|
21
|
+
result << (daud_map[m[1]] || m[0])
|
22
|
+
s = s[m.end(0)..-1]
|
23
|
+
else
|
24
|
+
result << s
|
25
|
+
s = ""
|
26
|
+
end
|
27
|
+
end
|
28
|
+
return result
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#
|
2
|
+
# Converts a regular unicode string to Da'ud notation ASCII.
|
3
|
+
#
|
4
|
+
class DaudCoder::DaudEncoder
|
5
|
+
|
6
|
+
def daud_map
|
7
|
+
@@daud_map ||= DaudCoder::Encodings.unicode_to_daud_map
|
8
|
+
end
|
9
|
+
def encode(s)
|
10
|
+
result = ""
|
11
|
+
s.chars do |c|
|
12
|
+
result << (daud_map.has_key?(c) ? "\{#{daud_map[c]}\}" : c)
|
13
|
+
end
|
14
|
+
return result
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
class DaudCoder::Encodings
|
4
|
+
|
5
|
+
PAIRS = [["a'", 'á'],
|
6
|
+
["'a", 'à'],
|
7
|
+
['a^', 'â'],
|
8
|
+
['a"', 'ä'],
|
9
|
+
['ao', 'å'],
|
10
|
+
['a~', 'ã'],
|
11
|
+
['ae', 'æ'],
|
12
|
+
["A'", 'Á'],
|
13
|
+
["'A", 'À'],
|
14
|
+
['A^', 'Â'],
|
15
|
+
['A"', 'Ä'],
|
16
|
+
['Ao', 'Å'],
|
17
|
+
['A~', 'Ã'],
|
18
|
+
['AE', 'Æ'],
|
19
|
+
['c,', 'ç'],
|
20
|
+
['C,', 'Ç'],
|
21
|
+
["e'", 'é'],
|
22
|
+
["'e", 'è'],
|
23
|
+
['e^', 'ê'],
|
24
|
+
['e"', 'ë'],
|
25
|
+
["E'", 'É'],
|
26
|
+
["'E", 'È'],
|
27
|
+
['E^', 'Ê'],
|
28
|
+
['E"', 'Ë'],
|
29
|
+
["i'", 'í'],
|
30
|
+
["'i", 'ì'],
|
31
|
+
['i^', 'î'],
|
32
|
+
['i"', 'ï'],
|
33
|
+
["I'", 'Í'],
|
34
|
+
["'I", 'Ì'],
|
35
|
+
['I^', 'Î'],
|
36
|
+
['I"', 'Ï'],
|
37
|
+
['n~', 'ñ'],
|
38
|
+
['N~', 'Ñ'],
|
39
|
+
["o'", 'ó'],
|
40
|
+
["'o", 'ò'],
|
41
|
+
['o^', 'ô'],
|
42
|
+
['o"', 'ö'],
|
43
|
+
['o/', 'ø'],
|
44
|
+
['o~', 'õ'],
|
45
|
+
["O'", 'Ó'],
|
46
|
+
["'O", 'Ò'],
|
47
|
+
['O^', 'Ô'],
|
48
|
+
['O"', 'Ö'],
|
49
|
+
['O/', 'Ø'],
|
50
|
+
['O~', 'Õ'],
|
51
|
+
['sz', 'ß'],
|
52
|
+
["u'", 'ú'],
|
53
|
+
["'u", 'ù'],
|
54
|
+
['u^', 'û'],
|
55
|
+
['u"', 'ü'],
|
56
|
+
["U'", 'Ú'],
|
57
|
+
["'U", 'Ù'],
|
58
|
+
['U^', 'Û'],
|
59
|
+
['U"', 'Ü'],
|
60
|
+
["y'", 'ý'],
|
61
|
+
['y"', 'ÿ'],
|
62
|
+
["Y'", 'Ý'],
|
63
|
+
['dh', 'ð'],
|
64
|
+
['DH', 'Ð'],
|
65
|
+
['th', 'þ'],
|
66
|
+
['TH', 'Þ']]
|
67
|
+
|
68
|
+
def self.daud_to_unicode_map
|
69
|
+
Hash[PAIRS]
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.unicode_to_daud_map
|
73
|
+
Hash[PAIRS.map {|d, u| [u, d]}]
|
74
|
+
end
|
75
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: daud_coder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-16 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Encodes and decodes between standard text encoders and Da'ud notation.
|
15
15
|
email: elsbeth@pobox.com
|
@@ -20,6 +20,9 @@ extensions: []
|
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
22
22
|
- lib/daud_coder.rb
|
23
|
+
- lib/daud_coder/encodings.rb
|
24
|
+
- lib/daud_coder/daud_encoder.rb
|
25
|
+
- lib/daud_coder/daud_decoder.rb
|
23
26
|
- bin/parse_daud
|
24
27
|
- bin/to_daud
|
25
28
|
homepage: http://github.com/kathyvs/DaudEncoder
|