hierogloss 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 013868a650a3464e07c17bcca8f37bcba3e52974
4
- data.tar.gz: a02e8d67a85df5dcfedc9ae87447bf6604ed3587
3
+ metadata.gz: a5918c9d05821627262648470a2724043857a5a5
4
+ data.tar.gz: 22fabb89f839ddc8573645df993b639fa9006919
5
5
  SHA512:
6
- metadata.gz: 9a362073542fa41bad251c4f0d38e9310b051fc617615036f9448d68e55a6855e0dd27e2e9c6d2489d7f0987245c07453775083c395817d23e8498d863b5801d
7
- data.tar.gz: e17841bf61cb0b4b77680c498a6f93169a670246604b593b84b6b26a1ed3ec61b2edf5da8ca1aca437ebc7919cc138d088a8b0c892fa744b1ae23ed8ed36f52b
6
+ metadata.gz: ea4c5397bd99efae7e459555564fa4c31fb0c05c0f2dec7107fd193cae9430db28962743ef9ceeae20609f43b05214b21025e17764eb364ade718e900e8cf90c
7
+ data.tar.gz: 1471f3c7e4a6e9683d6610b4732a768c56736bbf5d3e05a71c4f385fe5a8824482656c27da22b268e3bbd555e17efab9be6308a6296de3ebacaf8697149378ec
@@ -6,6 +6,18 @@ module Hierogloss
6
6
  DATA_DIR = File.join(File.dirname(__FILE__), '..', '..', 'data')
7
7
  MDC_MAPPING_PATH = File.join(DATA_DIR, "Unicode-MdC-Mapping-v1.utf8")
8
8
 
9
+ # Pattern identifying Gardiner codes (as opposed to phonetic ones.
10
+ GARDINER_REGEX = /\A[A-Z][0-9]+[A-Za-z]?([-:*\\].*)?\z/
11
+
12
+ # Convert variant signs to something that should work in JSesh.
13
+ def self.fix_gardiner(code)
14
+ if code =~ GARDINER_REGEX
15
+ code.upcase.sub(/\\R/, '\r')
16
+ else
17
+ code
18
+ end
19
+ end
20
+
9
21
  SIGN_TO_GARDINER = {}
10
22
  MDC_TO_SIGN = {}
11
23
  SIGN_TO_MDC = {}
@@ -15,11 +27,12 @@ module Hierogloss
15
27
  l.chomp!
16
28
  sign, hex, codes, remarks = l.split(/\t/, 4)
17
29
  for code in codes.split(/ /)
30
+ code = fix_gardiner(code)
18
31
  MDC_TO_SIGN[code] = sign
19
32
  # Unliterals.
20
33
  SIGN_TO_MDC[sign] = code if code.length == 1
21
34
  # Gardiner codes, and composite signs starting with Gardiner codes.
22
- next unless code =~ /\A[A-Z][0-9]+([-:*].*)?\z/
35
+ next unless code =~ GARDINER_REGEX
23
36
  SIGN_TO_GARDINER[sign] = code
24
37
  SIGN_TO_MDC[sign] ||= code
25
38
  end
@@ -1,3 +1,3 @@
1
1
  module Hierogloss
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -40,4 +40,13 @@ class TestDictionary < Minitest::Test
40
40
  assert_equal("A1", Hierogloss::Dictionary.sign_to_gardiner("𓀀"))
41
41
  assert_equal("D4", Hierogloss::Dictionary.sign_to_gardiner("𓁹"))
42
42
  end
43
+
44
+ def test_should_convert_variant_signs_to_gardiner
45
+ # These signs aren't in the Unicode table.
46
+ assert_equal("E8A", Hierogloss::Dictionary.sign_to_gardiner("𓃚"))
47
+ assert_equal("N33A", Hierogloss::Dictionary.sign_to_gardiner("𓈓"))
48
+ assert_equal("N35A", Hierogloss::Dictionary.sign_to_gardiner("𓈗"))
49
+ assert_equal("P1A", Hierogloss::Dictionary.sign_to_gardiner("𓊜"))
50
+ assert_equal("Y1\\r1", Hierogloss::Dictionary.sign_to_gardiner("𓏜"))
51
+ end
43
52
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hierogloss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Kidd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-25 00:00:00.000000000 Z
11
+ date: 2014-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown