unicode-confusable 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/CHANGELOG.md +4 -0
- data/lib/unicode/confusable.rb +10 -0
- data/lib/unicode/confusable/constants.rb +1 -1
- data/spec/unicode_confusable_spec.rb +12 -0
- 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: 5401e9a2c2540b4fe3941946e92df2f591494e87
|
4
|
+
data.tar.gz: b9df7e729200391e5783ebc7cc7f3e306b61e321
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5635c0eaf009994a20bd707750fb96d1b613fe06f051bdaad35e641e96f74508921d24b374a897b027243e9c37164c3877125c765d400ad41cbc7525833fe1d3
|
7
|
+
data.tar.gz: 4c6109c63855ee2021af1571e952d0e95ab68db90008ee7eff6e0cbfee74ffb35156f0665f662aef8ade32c32a0361cec27e68f5a00586d8bba81b8d532dcf74
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/lib/unicode/confusable.rb
CHANGED
@@ -16,6 +16,16 @@ module Unicode
|
|
16
16
|
}.flatten.pack("U*"), :nfd
|
17
17
|
)
|
18
18
|
end
|
19
|
+
|
20
|
+
def self.list(char, partial_mapping_allowed = true)
|
21
|
+
require_relative 'confusable/index' unless defined? ::Unicode::Confusable::INDEX
|
22
|
+
codepoint = char.codepoints.first or raise ArgumentError, "no data given to Unicode::Confusable.list"
|
23
|
+
if partial_mapping_allowed
|
24
|
+
INDEX.select{ |k,v| v == codepoint || v.is_a?(Array) && v.include?(codepoint) }.keys.map{ |codepoint| [codepoint].pack("U*") }
|
25
|
+
else
|
26
|
+
INDEX.select{ |k,v| v == codepoint }.keys.map{ |codepoint| [codepoint].pack("U") }
|
27
|
+
end
|
28
|
+
end
|
19
29
|
end
|
20
30
|
end
|
21
31
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Unicode
|
2
2
|
module Confusable
|
3
|
-
VERSION = "1.
|
3
|
+
VERSION = "1.3.0".freeze
|
4
4
|
UNICODE_VERSION = "10.0.0".freeze
|
5
5
|
DATA_DIRECTORY = File.expand_path(File.dirname(__FILE__) + '/../../../data/').freeze
|
6
6
|
INDEX_FILENAME = (DATA_DIRECTORY + '/confusable.marshal.gz').freeze
|
@@ -13,5 +13,17 @@ describe Unicode::Confusable do
|
|
13
13
|
assert_equal false, Unicode::Confusable.confusable?("a", "b")
|
14
14
|
assert_equal false, Unicode::Confusable.confusable?("⁇", "?")
|
15
15
|
end
|
16
|
+
|
17
|
+
describe ".list(char)" do
|
18
|
+
it "will return list of confusables for a character, also confusables where given character is part of" do
|
19
|
+
assert_equal ["⒪", "ꜵ", "℅", "ᴔ", "ꭁ", "ꭂ", "ﷲ", "№", "ం", "ಂ", "ം", "ං", "०", "੦", "૦", "௦", "౦", "೦", "൦", "๐", "໐", "၀", "٥", "۵", "o", "ℴ", "𝐨", "𝑜", "𝒐", "𝓸", "𝔬", "𝕠", "𝖔", "𝗈", "𝗼", "𝘰", "𝙤", "𝚘", "ᴏ", "ᴑ", "ꬽ", "ο", "𝛐", "𝜊", "𝝄", "𝝾", "𝞸", "σ", "𝛔", "𝜎", "𝝈", "𝞂", "𝞼", "ⲟ", "о", "ჿ", "օ", "ס", "ه", "𞸤", "𞹤", "𞺄", "ﻫ", "ﻬ", "ﻪ", "ﻩ", "ھ", "ﮬ", "ﮭ", "ﮫ", "ﮪ", "ہ", "ﮨ", "ﮩ", "ﮧ", "ﮦ", "ە", "ഠ", "ဝ", "𐓪", "𑣈", "𑣗", "𐐬", "ۿ", "ø", "ꬾ", "ɵ", "ꝋ", "ө", "ѳ", "ꮎ", "ꮻ", "ꭴ", "ﳙ", "ơ", "œ", "ɶ", "∞", "ꝏ", "ꚙ", "ﳗ", "ﱑ", "ﳘ", "ﱒ", "ﶓ", "ﶔ", "ﱓ", "ﱔ", "ൟ", "တ", "ꭣ", "ﲠ", "ﳢ", "ﲥ", "ﳤ", "ﷻ", "ﴱ", "ﳨ", "ﴲ", "ﳪ", "ﷺ", "ﷷ", "ﳍ", "ﳖ", "ﳯ", "ﳞ", "ﳱ", "ﳦ", "ﲛ", "ﳠ", "ﯭ", "ﯬ"] , Unicode::Confusable.list("o")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe ".list(char, false)" do
|
24
|
+
it "will return list of confusables for a character, only direct confusables" do
|
25
|
+
assert_equal ["ం", "ಂ", "ം", "ං", "०", "੦", "૦", "௦", "౦", "೦", "൦", "๐", "໐", "၀", "٥", "۵", "o", "ℴ", "𝐨", "𝑜", "𝒐", "𝓸", "𝔬", "𝕠", "𝖔", "𝗈", "𝗼", "𝘰", "𝙤", "𝚘", "ᴏ", "ᴑ", "ꬽ", "ο", "𝛐", "𝜊", "𝝄", "𝝾", "𝞸", "σ", "𝛔", "𝜎", "𝝈", "𝞂", "𝞼", "ⲟ", "о", "ჿ", "օ", "ס", "ه", "𞸤", "𞹤", "𞺄", "ﻫ", "ﻬ", "ﻪ", "ﻩ", "ھ", "ﮬ", "ﮭ", "ﮫ", "ﮪ", "ہ", "ﮨ", "ﮩ", "ﮧ", "ﮦ", "ە", "ഠ", "ဝ", "𐓪", "𑣈", "𑣗", "𐐬"] , Unicode::Confusable.list("o", false)
|
26
|
+
end
|
27
|
+
end
|
16
28
|
end
|
17
29
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unicode-confusable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.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: 2017-
|
11
|
+
date: 2017-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: "[Unicode 10.0.0] Compares two strings if they are visually confusable
|
14
14
|
as described in Unicode® Technical Standard #39: Both strings get transformed into
|
@@ -56,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
56
|
version: '0'
|
57
57
|
requirements: []
|
58
58
|
rubyforge_project:
|
59
|
-
rubygems_version: 2.6.
|
59
|
+
rubygems_version: 2.6.13
|
60
60
|
signing_key:
|
61
61
|
specification_version: 4
|
62
62
|
summary: Detect characters that look visually similar.
|