tanuki_emoji 0.3.0 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c67213658b22404d9912d1a6704748c1106602013ea3263e819dff1c05ee4dc8
4
- data.tar.gz: 205335429c995e7fc884867b50caed6beb2f1bec90c9a4fa3bf31afdc364aa64
3
+ metadata.gz: f515e18873314d0d4fc8d490645c7c60c13c842016f8efa9a7bc559fc5c00ae9
4
+ data.tar.gz: ff2e0ad3a8991e2091c56051ae9a0005cb079ae2a2052915302668119b56a303
5
5
  SHA512:
6
- metadata.gz: a32137a26584a98e2e59954829e769cfdacb126986debc443118477cae7c5bd16cde127a75cb606c9674e31545102df12792ac58ff25bab479d49676553be297
7
- data.tar.gz: 4fc240c5cd68e53f5721063f74f32b4bd2e4f60840882fb55dc31cb23163615f0096d4616bed8c730ac198322d87a5328c9b6cf7b0ab7e1e2b95fb0cdad43207
6
+ metadata.gz: f45be46c767ccb611da4908fe0f474c1ef2f2a83802dead03256a99fb4f5b5a25eefe812dd51f6602536ed9dca74e5757ee16d0498737b9247c846642e4cbc3c
7
+ data.tar.gz: cccefbe3827f60f3e1b764068647e464f0a4ff1ff93d12d83225396017a33fcffd2dc6e7106dfa45708cc576d8596d4f5cf198b0026438a7360f82319a322e40
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7
1
+ 2.7.4
data/CHANGELOG.md CHANGED
@@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.4.0] - 2021-09-07
10
+ ### Added
11
+ - Index can return the `alpha_code_pattern` and `codepoints_pattern` to be used as text extraction sources
12
+
13
+ ### Fixed
14
+ - Fixed `registered sign`, `copyright sign` and `trade mark sign` codepoints from gemojione index
15
+
9
16
  ## [0.3.0] - 2021-08-26
10
17
  ### Modified
11
18
  - Characters can be compared and will be considered equal when all of its attributes matches
@@ -34,3 +41,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
34
41
  [0.2.0]:https://gitlab.com/gitlab-org/tanuki_emoji/-/releases/v0.2.0
35
42
  [0.2.1]:https://gitlab.com/gitlab-org/tanuki_emoji/-/releases/v0.2.1
36
43
  [0.2.2]:https://gitlab.com/gitlab-org/tanuki_emoji/-/releases/v0.2.2
44
+ [0.3.0]:https://gitlab.com/gitlab-org/tanuki_emoji/-/releases/v0.3.0
45
+ [0.4.0]:https://gitlab.com/gitlab-org/tanuki_emoji/-/releases/v0.4.0
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tanuki_emoji (0.3.0)
4
+ tanuki_emoji (0.4.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -54,7 +54,9 @@ GEM
54
54
  unicode-display_width (2.0.0)
55
55
 
56
56
  PLATFORMS
57
+ ruby
57
58
  x86_64-darwin-20
59
+ x86_64-linux
58
60
 
59
61
  DEPENDENCIES
60
62
  rake (~> 13.0)
@@ -66,4 +68,4 @@ DEPENDENCIES
66
68
  tanuki_emoji!
67
69
 
68
70
  BUNDLED WITH
69
- 2.2.15
71
+ 2.2.22
@@ -9,6 +9,7 @@ module TanukiEmoji
9
9
  IMAGE_PREFIX = 'emoji_u'
10
10
  IMAGE_EXTENSION = '.png'
11
11
  FLAG_REGEXP = /[🇦-🇿]{2}/u.freeze
12
+ ALPHA_CODE_REGEXP = /:(?<alpha_text>[_+\-a-z0-9]+):/.freeze
12
13
 
13
14
  # This denotes a "color" or "emoji" version
14
15
  EMOJI_VARIATION_SELECTOR = 0xFE0F
@@ -25,7 +26,7 @@ module TanukiEmoji
25
26
  # @param [String] codepoints
26
27
  # @param [String] alpha_code
27
28
  def initialize(name, codepoints:, alpha_code:, description:)
28
- @name = name
29
+ @name = self.class.format_name(name)
29
30
  @codepoints = codepoints
30
31
  @codepoints_alternates = []
31
32
  @alpha_code = self.class.format_alpha_code(alpha_code)
@@ -91,14 +92,18 @@ module TanukiEmoji
91
92
  description == other.description
92
93
  end
93
94
 
94
- # Convert Unicode code points to Hex format for inspection
95
- #
96
- # ensure alpha code is formatted with colons
95
+ # Ensure alpha code is formatted with colons
97
96
  #
98
97
  # @param [String] alpha_code
99
98
  # @return [String] formatted alpha code
100
99
  def self.format_alpha_code(alpha_code)
101
- alpha_code.to_s.match?(/:([_+\-a-z0-9]+):/) ? alpha_code.to_s : ":#{alpha_code}:"
100
+ alpha_code.to_s.match?(ALPHA_CODE_REGEXP) ? alpha_code.to_s : ":#{alpha_code}:"
101
+ end
102
+
103
+ def self.format_name(raw_name)
104
+ matched = raw_name.match(ALPHA_CODE_REGEXP)
105
+
106
+ matched ? matched['alpha_text'] : raw_name
102
107
  end
103
108
 
104
109
  private
@@ -36,7 +36,8 @@ module TanukiEmoji
36
36
  end
37
37
 
38
38
  emoji.aliases.each do |alpha_code|
39
- @alpha_code_index[alpha_code] = emoji
39
+ @name_index[::TanukiEmoji::Character.format_name(alpha_code)] = emoji
40
+ @alpha_code_index[::TanukiEmoji::Character.format_alpha_code(alpha_code)] = emoji
40
41
  end
41
42
  end
42
43
 
@@ -75,6 +76,22 @@ module TanukiEmoji
75
76
  load_data_files if reload
76
77
  end
77
78
 
79
+ # Return a regular expression that can be used to search for indexed `:alpha_codes:`
80
+ #
81
+ # @return [Regexp] regular expression that matches indexed `:alpha_code:`
82
+ def alpha_code_pattern
83
+ /(?<=[^[:alnum:]:]|\n|^)
84
+ :(#{@name_index.keys.map { |name| Regexp.escape(name) }.join('|')}):
85
+ (?=[^[:alnum:]:]|$)/x
86
+ end
87
+
88
+ # Return a regular expression that can be used to search for emoji codepoints
89
+ #
90
+ # @return [Regexp] regular expression that matches indexed emoji codepoints
91
+ def codepoints_pattern
92
+ /(#{@codepoints_index.keys.map { |moji| Regexp.escape(moji) }.join('|')})/
93
+ end
94
+
78
95
  private
79
96
 
80
97
  def initialize
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TanukiEmoji
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
@@ -5861,7 +5861,7 @@
5861
5861
  "moji": "👮🏿"
5862
5862
  },
5863
5863
  "copyright": {
5864
- "moji": "©",
5864
+ "moji": "©️",
5865
5865
  "unicode": "00A9",
5866
5866
  "unicode_alternates": [],
5867
5867
  "name": "copyright sign",
@@ -25694,7 +25694,7 @@
25694
25694
  "moji": "🔴"
25695
25695
  },
25696
25696
  "registered": {
25697
- "moji": "®",
25697
+ "moji": "®️",
25698
25698
  "unicode": "00AE",
25699
25699
  "unicode_alternates": [],
25700
25700
  "name": "registered sign",
@@ -30433,7 +30433,7 @@
30433
30433
  "tm",
30434
30434
  "word"
30435
30435
  ],
30436
- "moji": ""
30436
+ "moji": "™️"
30437
30437
  },
30438
30438
  "toilet": {
30439
30439
  "unicode": "1F6BD",
@@ -7630,7 +7630,7 @@
7630
7630
  "moji": "👮🏿"
7631
7631
  },
7632
7632
  "copyright": {
7633
- "moji": "©",
7633
+ "moji": "©️",
7634
7634
  "unicode": "00A9",
7635
7635
  "unicode_alternates": [
7636
7636
 
@@ -33231,7 +33231,7 @@
33231
33231
  "moji": "🔴"
33232
33232
  },
33233
33233
  "registered": {
33234
- "moji": "®",
33234
+ "moji": "®️",
33235
33235
  "unicode": "00AE",
33236
33236
  "unicode_alternates": [
33237
33237
 
@@ -39373,7 +39373,7 @@
39373
39373
  "tm",
39374
39374
  "word"
39375
39375
  ],
39376
- "moji": ""
39376
+ "moji": "™️"
39377
39377
  },
39378
39378
  "toilet": {
39379
39379
  "unicode": "1F6BD",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tanuki_emoji
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Mazetto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-26 00:00:00.000000000 Z
11
+ date: 2021-09-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Tanuki Emoji provides Emoji character information and metadata with support
14
14
  for Noto Emoji resources as fallback
@@ -1872,7 +1872,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1872
1872
  - !ruby/object:Gem::Version
1873
1873
  version: '0'
1874
1874
  requirements: []
1875
- rubygems_version: 3.2.15
1875
+ rubygems_version: 3.1.6
1876
1876
  signing_key:
1877
1877
  specification_version: 4
1878
1878
  summary: Tanuki Emoji