unicode-name 1.3.0 β 1.4.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 +4 -4
- data/.travis.yml +3 -4
- data/CHANGELOG.md +4 -0
- data/MIT-LICENSE.txt +1 -1
- data/README.md +3 -6
- data/data/name.marshal.gz +0 -0
- data/lib/unicode/name.rb +18 -2
- data/lib/unicode/name/constants.rb +1 -1
- data/spec/unicode_name_spec.rb +8 -7
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 990485823ed1ab3282dcd13d6fd065499f5dcf46
|
4
|
+
data.tar.gz: 890802e0e5d2bdc61960dc79eb8cff5c9c353174
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0b5c9abefc9f0b6f521a54c86ef0334e815645328aa07af46f20a20db4529ebdd3d06e104f7720e96b24fd085df36f9f5ea70d2a6be8c04d295e7bb592dd088
|
7
|
+
data.tar.gz: 6adcb039b952fafd091cccf69b9b0e648085130695934e310ffe6cf4417249aa0942a0607b5ead164d39341b3cdacc5b073abaa89cb00f7d446ab3462e3b14dd
|
data/.travis.yml
CHANGED
@@ -4,13 +4,13 @@ language: ruby
|
|
4
4
|
script: bundle exec ruby spec/unicode_name_spec.rb
|
5
5
|
|
6
6
|
rvm:
|
7
|
-
- 2.
|
7
|
+
- 2.4.0
|
8
|
+
- 2.3.3
|
8
9
|
- 2.2
|
9
10
|
- 2.1
|
10
11
|
- ruby-head
|
11
|
-
- rbx-2
|
12
12
|
- jruby-head
|
13
|
-
- jruby-9.
|
13
|
+
- jruby-9.1.7.0
|
14
14
|
|
15
15
|
cache:
|
16
16
|
- bundler
|
@@ -18,4 +18,3 @@ cache:
|
|
18
18
|
matrix:
|
19
19
|
allow_failures:
|
20
20
|
- rvm: jruby-head
|
21
|
-
- rvm: rbx-2
|
data/CHANGELOG.md
CHANGED
data/MIT-LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,7 @@ Return Unicode codepoint names, aliases, and labels.
|
|
4
4
|
|
5
5
|
Unicode version: **9.0.0**
|
6
6
|
|
7
|
-
Supported Rubies: **2.3**, **2.2**, **2.1**
|
7
|
+
Supported Rubies: **2.4**, **2.3**, **2.2**, **2.1**
|
8
8
|
|
9
9
|
## Usage
|
10
10
|
|
@@ -15,6 +15,7 @@ require "unicode/name"
|
|
15
15
|
Unicode::Name.of "A" # => "LATIN CAPITAL LETTER A"
|
16
16
|
Unicode::Name.of "π‘" # => "AERIAL TRAMWAY"
|
17
17
|
Unicode::Name.of "δΈ" # => "CJK UNIFIED IDEOGRAPH-4E01"
|
18
|
+
Unicode::Name.of "ν" # => "HANGUL SYLLABLE HAN"
|
18
19
|
|
19
20
|
# Aliases, by type
|
20
21
|
Unicode::Name.aliases "\t" # => {:control=>["CHARACTER TABULATION", "HORIZONTAL TABULATION"],
|
@@ -38,11 +39,7 @@ Unicode::Name.readable("\u{FFFFD}") # => "<private-use-FFFFD>"
|
|
38
39
|
|
39
40
|
See [unicode-x](https://github.com/janlelis/unicode-x) for more Unicode related micro libraries.
|
40
41
|
|
41
|
-
## Todo
|
42
|
-
|
43
|
-
* Hangul syllable names
|
44
|
-
|
45
42
|
## MIT License
|
46
43
|
|
47
|
-
- Copyright (C) 2016 Jan Lelis <http://janlelis.com>. Released under the MIT license.
|
44
|
+
- Copyright (C) 2016-2017 Jan Lelis <http://janlelis.com>. Released under the MIT license.
|
48
45
|
- Unicode data: http://www.unicode.org/copyright.html#Exhibit1
|
data/data/name.marshal.gz
CHANGED
Binary file
|
data/lib/unicode/name.rb
CHANGED
@@ -2,6 +2,11 @@ require_relative "name/constants"
|
|
2
2
|
|
3
3
|
module Unicode
|
4
4
|
module Name
|
5
|
+
HANGUL_START = 44032
|
6
|
+
HANGUL_END = 55203
|
7
|
+
HANGUL_MEDIAL_MAX = 588
|
8
|
+
HANGUL_FINAL_MAX = 28
|
9
|
+
|
5
10
|
# Don't overwrite Module.name
|
6
11
|
def self.unicode_name(char)
|
7
12
|
codepoint = char.unpack("U")[0]
|
@@ -10,8 +15,8 @@ module Unicode
|
|
10
15
|
res
|
11
16
|
elsif INDEX[:CJK].any?{ |cjk_range| codepoint >= cjk_range[0] && codepoint <= cjk_range[1] }
|
12
17
|
"CJK UNIFIED IDEOGRAPH-%.4X" % codepoint
|
13
|
-
elsif codepoint >=
|
14
|
-
"HANGUL SYLLABLE
|
18
|
+
elsif codepoint >= HANGUL_START && codepoint <= HANGUL_END
|
19
|
+
"HANGUL SYLLABLE %s" % hangul_decomposition(codepoint)
|
15
20
|
else
|
16
21
|
nil
|
17
22
|
end
|
@@ -64,6 +69,17 @@ module Unicode
|
|
64
69
|
as[:abbreviation] && as[:abbreviation][0] ) ||
|
65
70
|
label(char)
|
66
71
|
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
# See https://en.wikipedia.org/wiki/Korean_language_and_computers#Hangul_Syllables_Area
|
76
|
+
def self.hangul_decomposition(codepoint)
|
77
|
+
base = codepoint - HANGUL_START
|
78
|
+
final = base % HANGUL_FINAL_MAX
|
79
|
+
medial = (base - final) % HANGUL_MEDIAL_MAX
|
80
|
+
initial = base / HANGUL_MEDIAL_MAX
|
81
|
+
"#{INDEX[:JAMO][:INITIAL][initial]}#{INDEX[:JAMO][:MEDIAL][medial]}#{INDEX[:JAMO][:FINAL][final]}"
|
82
|
+
end
|
67
83
|
end
|
68
84
|
end
|
69
85
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Unicode
|
2
2
|
module Name
|
3
|
-
VERSION = "1.
|
3
|
+
VERSION = "1.4.0".freeze
|
4
4
|
UNICODE_VERSION = "9.0.0".freeze
|
5
5
|
DATA_DIRECTORY = File.expand_path(File.dirname(__FILE__) + '/../../../data/').freeze
|
6
6
|
INDEX_FILENAME = (DATA_DIRECTORY + '/name.marshal.gz').freeze
|
data/spec/unicode_name_spec.rb
CHANGED
@@ -13,13 +13,14 @@ describe Unicode::Name do
|
|
13
13
|
assert_equal "CJK UNIFIED IDEOGRAPH-4E01", Unicode::Name.of("δΈ")
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
it "works for Hangul Syllables" do
|
17
|
+
assert_equal "HANGUL SYLLABLE HAN", Unicode::Name.of("ν")
|
18
|
+
assert_equal "HANGUL SYLLABLE GAG", Unicode::Name.of("κ°")
|
19
|
+
end
|
19
20
|
|
20
21
|
it "will return nil for characters without name" do
|
21
|
-
|
22
|
-
|
22
|
+
assert_nil Unicode::Name.of("\u{10c50}")
|
23
|
+
assert_nil Unicode::Name.of("\0")
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
@@ -35,7 +36,7 @@ describe Unicode::Name do
|
|
35
36
|
|
36
37
|
describe ".aliases" do
|
37
38
|
it "will return nil if no alias available" do
|
38
|
-
|
39
|
+
assert_nil Unicode::Name.aliases("A")
|
39
40
|
end
|
40
41
|
|
41
42
|
it "will always return a Hash" do
|
@@ -50,7 +51,7 @@ describe Unicode::Name do
|
|
50
51
|
|
51
52
|
describe ".label" do
|
52
53
|
it "will return nil for usual (graphic) characters" do
|
53
|
-
|
54
|
+
assert_nil Unicode::Name.label("A")
|
54
55
|
end
|
55
56
|
|
56
57
|
it "will return <control-hhhh> for control characters" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unicode-name
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Lelis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unicode-types
|
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
66
|
version: '0'
|
67
67
|
requirements: []
|
68
68
|
rubyforge_project:
|
69
|
-
rubygems_version: 2.
|
69
|
+
rubygems_version: 2.6.8
|
70
70
|
signing_key:
|
71
71
|
specification_version: 4
|
72
72
|
summary: Returns name/aliases/label of a Unicode codepoint
|