unicode-confusable 1.14.0 → 1.14.1

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
  SHA256:
3
- metadata.gz: 9a846fb512f666162000fa09e91c189ca180a5da30687bfddfc326bcb30160f3
4
- data.tar.gz: 4aab539e7de61de215b86077222cb684442b9d17db296a60d10a4611cff0cce0
3
+ metadata.gz: b6bc7e62b19cb936a3bc164d08264194866173ddacaff98354b3c2fc35705229
4
+ data.tar.gz: f5e4951ecc316d29c7c56a3355a330f9f7c9200efeb1aa6f04ee23ec96a75a15
5
5
  SHA512:
6
- metadata.gz: 1d4987cf434226234b1e15df90484e809850e822ab528fdeb01677979e6c2b0e2e4dc82466f27cf1426d8bfcacff226ed11f5bdf45176b3b21477a5505b4f18e
7
- data.tar.gz: f92279a9e7ceb667e0211eb77b16cc174500a16fadbda01d1ce770379df806fdc7dae3553ed6d8e43bfdd7ed799ca3303260972f578a6dfb3124cbb0d37b933c
6
+ metadata.gz: ce84aa52f44f53b94c062663ab53fbbdf7429ca00c43b32098d097996b558ecf21ac999ff9872be4b02c074285d0002f4f91193124a3b8176d19e52dfbf9b104
7
+ data.tar.gz: 79604e8f5dfae6d5e5a1abe1bc9757071e32ee5ff51b2e6d29df0e241e5867d831d976f67f9679656c15e47576ac54b2b47e617f5d6f9102b1e3e737efb73c4c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## CHANGELOG
2
2
 
3
+ ### 1.14.1
4
+
5
+ - Use regex to remove default ignorable codepoints, speeds up confusable check,
6
+ closes #2
7
+
3
8
  ### 1.14.0
4
9
 
5
10
  - Unicode 18.0
data/Gemfile.lock CHANGED
@@ -2,39 +2,29 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  unicode-confusable (1.14.0)
5
+ charcutter (>= 0.1.0, < 2.0)
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
10
+ charcutter (0.1.0)
9
11
  drb (2.2.3)
10
- erb (6.0.7)
11
- io-console (0.9.4)
12
- irb (1.18.0)
13
- pp (>= 0.6.0)
14
- prism (>= 1.3.0)
15
- rdoc (>= 4.0.0)
16
- reline (>= 0.4.2)
17
- logger (1.7.0)
12
+ io-console (0.6.0)
13
+ irb (1.8.1)
14
+ rdoc
15
+ reline (>= 0.3.8)
18
16
  minitest (6.0.6)
19
17
  drb (~> 2.0)
20
18
  prism (~> 1.5)
21
- pp (0.6.4)
22
- prettyprint
23
- prettyprint (0.2.0)
24
19
  prism (1.9.0)
25
- rake (13.4.2)
26
- rbs (4.2.0)
27
- logger
28
- prism (>= 1.6.0)
29
- tsort
30
- rdoc (8.0.0)
31
- erb
32
- prism (>= 1.6.0)
33
- rbs (>= 4.0.0)
34
- tsort
35
- reline (0.7.0)
20
+ psych (5.1.0)
21
+ stringio
22
+ rake (13.0.6)
23
+ rdoc (6.5.0)
24
+ psych (>= 4.0.0)
25
+ reline (0.3.8)
36
26
  io-console (~> 0.5)
37
- tsort (0.2.0)
27
+ stringio (3.0.8)
38
28
 
39
29
  PLATFORMS
40
30
  ruby
@@ -46,4 +36,4 @@ DEPENDENCIES
46
36
  unicode-confusable!
47
37
 
48
38
  BUNDLED WITH
49
- 4.1.0.beta1
39
+ 2.5.17
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Unicode
4
4
  module Confusable
5
- VERSION = "1.14.0"
5
+ VERSION = "1.14.1"
6
6
  UNICODE_VERSION = "18.0.0"
7
7
  DATA_DIRECTORY = File.expand_path(File.dirname(__FILE__) + "/../../../data/").freeze
8
8
  INDEX_FILENAME = (DATA_DIRECTORY + "/confusable.marshal.gz").freeze
@@ -1,11 +1,10 @@
1
1
  require_relative "confusable/constants"
2
2
 
3
3
  require 'unicode_normalize/normalize'
4
+ require 'charcutter'
4
5
 
5
6
  module Unicode
6
7
  module Confusable
7
- autoload :IGNORABLE, File.expand_path('confusable/ignorable', __dir__)
8
-
9
8
  def self.confusable?(string1, string2)
10
9
  skeleton(string1) == skeleton(string2)
11
10
  end
@@ -13,10 +12,10 @@ module Unicode
13
12
  def self.skeleton(string)
14
13
  require_relative 'confusable/index' unless defined? ::Unicode::Confusable::INDEX
15
14
  UnicodeNormalize.normalize(
16
- UnicodeNormalize.normalize(string, :nfd).each_codepoint.map{ |codepoint|
17
- unless IGNORABLE.include?(codepoint)
18
- INDEX[:CONFUSABLE][codepoint] || codepoint
19
- end
15
+ Charcutter[
16
+ UnicodeNormalize.normalize(string, :nfd)
17
+ ].deny(:ignorable).each_codepoint.map{ |codepoint|
18
+ INDEX[:CONFUSABLE][codepoint] || codepoint
20
19
  }.flatten.compact.pack("U*"), :nfd
21
20
  )
22
21
  end
@@ -0,0 +1,7 @@
1
+ require 'benchmark'
2
+ require 'unicode/confusable'
3
+
4
+ test_str = "some long string" * 1000
5
+ Benchmark.bm do |x|
6
+ x.report("skeleton") { 500.times { Unicode::Confusable.skeleton(test_str) } }
7
+ end
@@ -18,4 +18,5 @@ Gem::Specification.new do |gem|
18
18
  gem.metadata = { "rubygems_mfa_required" => "true" }
19
19
 
20
20
  gem.required_ruby_version = ">= 2.2"
21
+ gem.add_dependency "charcutter", ">= 0.1.0", "< 2.0"
21
22
  end
metadata CHANGED
@@ -1,14 +1,34 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unicode-confusable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.0
4
+ version: 1.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Lelis
8
8
  bindir: bin
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
- dependencies: []
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: charcutter
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 0.1.0
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: '2.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: 0.1.0
29
+ - - "<"
30
+ - !ruby/object:Gem::Version
31
+ version: '2.0'
12
32
  description: "[Unicode 18.0.0] Compares two strings if they are visually confusable
13
33
  as described in Unicode® Technical Standard #39: Both strings get transformed into
14
34
  a skeleton format before comparing them. The skeleton is generated by normalizing
@@ -33,6 +53,7 @@ files:
33
53
  - lib/unicode/confusable/ignorable.rb
34
54
  - lib/unicode/confusable/index.rb
35
55
  - lib/unicode/confusable/string_ext.rb
56
+ - scripts/benchmark.rb
36
57
  - sig/unicode-confusable.rbs
37
58
  - spec/unicode_confusable_spec.rb
38
59
  - unicode-confusable.gemspec
@@ -55,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
76
  - !ruby/object:Gem::Version
56
77
  version: '0'
57
78
  requirements: []
58
- rubygems_version: 4.0.20
79
+ rubygems_version: 4.0.10
59
80
  specification_version: 4
60
81
  summary: Detect characters that look visually similar.
61
82
  test_files: []