unicode-confusable 1.2.0 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7c5d87eb8d09b0db6a0467eb43aee2a0f1666841
4
- data.tar.gz: 79c5a68b5d65d5dc2c3f75c31bb214d53585687d
3
+ metadata.gz: 5401e9a2c2540b4fe3941946e92df2f591494e87
4
+ data.tar.gz: b9df7e729200391e5783ebc7cc7f3e306b61e321
5
5
  SHA512:
6
- metadata.gz: b5b39e475e55bc30f617db53e1ad3d41a4bf8c9e88ed690eef3caa061fdec805186bc7a640b7a5d1202f3d8995331db6056ea13bdefb2da464800bdbdc0c30b5
7
- data.tar.gz: ce09d7f44f527fe5509ebd6757b4eb8a1eb74b7f98d95212882c359f12238184030122290848e6542c37d0ee6f25198231370a36e4f9b3c844465861ec836da3
6
+ metadata.gz: 5635c0eaf009994a20bd707750fb96d1b613fe06f051bdaad35e641e96f74508921d24b374a897b027243e9c37164c3877125c765d400ad41cbc7525833fe1d3
7
+ data.tar.gz: 4c6109c63855ee2021af1571e952d0e95ab68db90008ee7eff6e0cbfee74ffb35156f0665f662aef8ade32c32a0361cec27e68f5a00586d8bba81b8d532dcf74
@@ -4,8 +4,8 @@ language: ruby
4
4
  script: bundle exec ruby spec/unicode_confusable_spec.rb
5
5
 
6
6
  rvm:
7
- - 2.4.1
8
- - 2.3.4
7
+ - 2.4.2
8
+ - 2.3.5
9
9
  - 2.2
10
10
  - ruby-head
11
11
  - jruby-head
@@ -1,5 +1,9 @@
1
1
  ## CHANGELOG
2
2
 
3
+ ### 1.3.0
4
+
5
+ * Add Unicode::Confusable.list method which returns all confusables of given character
6
+
3
7
  ### 1.2.0
4
8
 
5
9
  * Unicode 10
@@ -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.2.0".freeze
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.2.0
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-06-17 00:00:00.000000000 Z
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.11
59
+ rubygems_version: 2.6.13
60
60
  signing_key:
61
61
  specification_version: 4
62
62
  summary: Detect characters that look visually similar.