tanuki_emoji 0.2.2 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +3 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +32 -1
- data/Dangerfile +5 -0
- data/Gemfile.lock +90 -2
- data/README.md +25 -6
- data/Rakefile +4 -5
- data/lib/tanuki_emoji/character.rb +36 -7
- data/lib/tanuki_emoji/db/gemojione.rb +6 -1
- data/lib/tanuki_emoji/db/unicode_version.rb +37 -0
- data/lib/tanuki_emoji/db.rb +1 -0
- data/lib/tanuki_emoji/index.rb +34 -3
- data/lib/tanuki_emoji/version.rb +1 -1
- data/lib/tanuki_emoji.rb +9 -2
- data/tanuki_emoji.gemspec +5 -2
- data/vendor/emoji-unicode-version/README.md +57 -0
- data/vendor/emoji-unicode-version/emoji-unicode-version-map.json +4302 -0
- data/vendor/gemojione/index-3.3.0.json +5 -5
- data/vendor/gemojione/index-4.1.0.json +5 -5
- metadata +27 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80827a5454f2eb6ed96102851f315c04215bda544c83892570e6b035ce43cbdd
|
4
|
+
data.tar.gz: c3a97c5c042b909a8544173865f8921e23093333b465fc47ee4f6e306df9480f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5d4fa24f4a0a954df5000d6a04f5c7f8621f6e1b9c2aa5fcb448b3e15af4df927f7033f57c125d9d1b0e11132175cf7351b631c19fe05aa4678c07f402e7636
|
7
|
+
data.tar.gz: 59439b83f98f62e9ace8756accfa327499182309b777864ad87847e567ddfe157b5056844a9033b50548784dec78d51b3d6ab358ef9b0c0a78ffff0e2fe20a67
|
data/.gitlab-ci.yml
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.5
|
data/CHANGELOG.md
CHANGED
@@ -6,7 +6,33 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
-
## [0.
|
9
|
+
## [0.6.0] - 2022-02-16
|
10
|
+
### Added
|
11
|
+
- `Character` responds to `ascii_aliases` which contain ASCII aliases from Gemojione
|
12
|
+
|
13
|
+
### Fixed
|
14
|
+
- Fixed `TanukiEmoji.add` command, which should now require `category:` to be provided
|
15
|
+
- Fixed issue where `TanukiEmoji::Index#codepoints_pattern` would split apart emoji-modifier pairs
|
16
|
+
|
17
|
+
## [0.5.0] - 2021-09-16
|
18
|
+
### Added
|
19
|
+
- Add Category information into `Character`
|
20
|
+
- Add Character.unicode_version and index in which unicode version an emoji was introduced
|
21
|
+
|
22
|
+
## [0.4.0] - 2021-09-07
|
23
|
+
### Added
|
24
|
+
- Index can return the `alpha_code_pattern` and `codepoints_pattern` to be used as text extraction sources
|
25
|
+
|
26
|
+
### Fixed
|
27
|
+
- Fixed `registered sign`, `copyright sign` and `trade mark sign` codepoints from gemojione index
|
28
|
+
|
29
|
+
## [0.3.0] - 2021-08-26
|
30
|
+
### Modified
|
31
|
+
- Characters can be compared and will be considered equal when all of its attributes matches
|
32
|
+
- `:+1:` and `:-1:` which are aliases for `:thumbsup:` and `:thumbsdown:` can now be used with `find_by_alpha_code`
|
33
|
+
- added tests for both `find_by_alpha_code` and `find_by_codepoints` and make sure `find_by_alpha_code` can handle `nil` correctly
|
34
|
+
|
35
|
+
## [0.2.2] - 2021-08-23
|
10
36
|
### Modified
|
11
37
|
- Fixed autoload load_path
|
12
38
|
|
@@ -27,3 +53,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
27
53
|
[0.1.0]:https://gitlab.com/gitlab-org/tanuki_emoji/-/releases/v0.1.0
|
28
54
|
[0.2.0]:https://gitlab.com/gitlab-org/tanuki_emoji/-/releases/v0.2.0
|
29
55
|
[0.2.1]:https://gitlab.com/gitlab-org/tanuki_emoji/-/releases/v0.2.1
|
56
|
+
[0.2.2]:https://gitlab.com/gitlab-org/tanuki_emoji/-/releases/v0.2.2
|
57
|
+
[0.3.0]:https://gitlab.com/gitlab-org/tanuki_emoji/-/releases/v0.3.0
|
58
|
+
[0.4.0]:https://gitlab.com/gitlab-org/tanuki_emoji/-/releases/v0.4.0
|
59
|
+
[0.5.0]:https://gitlab.com/gitlab-org/tanuki_emoji/-/releases/v0.5.0
|
60
|
+
[0.6.0]:https://gitlab.com/gitlab-org/tanuki_emoji/-/releases/v0.6.0
|
data/Dangerfile
ADDED
data/Gemfile.lock
CHANGED
@@ -1,19 +1,98 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
tanuki_emoji (0.
|
4
|
+
tanuki_emoji (0.6.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
+
addressable (2.8.0)
|
10
|
+
public_suffix (>= 2.0.2, < 5.0)
|
9
11
|
ast (2.4.2)
|
12
|
+
claide (1.1.0)
|
13
|
+
claide-plugins (0.9.2)
|
14
|
+
cork
|
15
|
+
nap
|
16
|
+
open4 (~> 1.3)
|
17
|
+
colored2 (3.1.2)
|
18
|
+
cork (0.3.0)
|
19
|
+
colored2 (~> 3.1)
|
20
|
+
danger (8.4.2)
|
21
|
+
claide (~> 1.0)
|
22
|
+
claide-plugins (>= 0.9.2)
|
23
|
+
colored2 (~> 3.1)
|
24
|
+
cork (~> 0.1)
|
25
|
+
faraday (>= 0.9.0, < 2.0)
|
26
|
+
faraday-http-cache (~> 2.0)
|
27
|
+
git (~> 1.7)
|
28
|
+
kramdown (~> 2.3)
|
29
|
+
kramdown-parser-gfm (~> 1.0)
|
30
|
+
no_proxy_fix
|
31
|
+
octokit (~> 4.7)
|
32
|
+
terminal-table (>= 1, < 4)
|
33
|
+
danger-gitlab (8.0.0)
|
34
|
+
danger
|
35
|
+
gitlab (~> 4.2, >= 4.2.0)
|
10
36
|
diff-lcs (1.4.4)
|
11
37
|
docile (1.4.0)
|
38
|
+
faraday (1.9.3)
|
39
|
+
faraday-em_http (~> 1.0)
|
40
|
+
faraday-em_synchrony (~> 1.0)
|
41
|
+
faraday-excon (~> 1.1)
|
42
|
+
faraday-httpclient (~> 1.0)
|
43
|
+
faraday-multipart (~> 1.0)
|
44
|
+
faraday-net_http (~> 1.0)
|
45
|
+
faraday-net_http_persistent (~> 1.0)
|
46
|
+
faraday-patron (~> 1.0)
|
47
|
+
faraday-rack (~> 1.0)
|
48
|
+
faraday-retry (~> 1.0)
|
49
|
+
ruby2_keywords (>= 0.0.4)
|
50
|
+
faraday-em_http (1.0.0)
|
51
|
+
faraday-em_synchrony (1.0.0)
|
52
|
+
faraday-excon (1.1.0)
|
53
|
+
faraday-http-cache (2.2.0)
|
54
|
+
faraday (>= 0.8)
|
55
|
+
faraday-httpclient (1.0.1)
|
56
|
+
faraday-multipart (1.0.3)
|
57
|
+
multipart-post (>= 1.2, < 3)
|
58
|
+
faraday-net_http (1.0.1)
|
59
|
+
faraday-net_http_persistent (1.2.0)
|
60
|
+
faraday-patron (1.0.0)
|
61
|
+
faraday-rack (1.0.0)
|
62
|
+
faraday-retry (1.0.3)
|
63
|
+
git (1.10.2)
|
64
|
+
rchardet (~> 1.8)
|
65
|
+
gitlab (4.18.0)
|
66
|
+
httparty (~> 0.18)
|
67
|
+
terminal-table (>= 1.5.1)
|
68
|
+
gitlab-dangerfiles (2.8.0)
|
69
|
+
danger (>= 8.3.1)
|
70
|
+
danger-gitlab (>= 8.0.0)
|
71
|
+
httparty (0.20.0)
|
72
|
+
mime-types (~> 3.0)
|
73
|
+
multi_xml (>= 0.5.2)
|
74
|
+
kramdown (2.3.1)
|
75
|
+
rexml
|
76
|
+
kramdown-parser-gfm (1.1.0)
|
77
|
+
kramdown (~> 2.0)
|
78
|
+
mime-types (3.4.1)
|
79
|
+
mime-types-data (~> 3.2015)
|
80
|
+
mime-types-data (3.2022.0105)
|
81
|
+
multi_xml (0.6.0)
|
82
|
+
multipart-post (2.1.1)
|
83
|
+
nap (1.1.0)
|
84
|
+
no_proxy_fix (0.1.2)
|
85
|
+
octokit (4.22.0)
|
86
|
+
faraday (>= 0.9)
|
87
|
+
sawyer (~> 0.8.0, >= 0.5.3)
|
88
|
+
open4 (1.3.4)
|
12
89
|
parallel (1.20.1)
|
13
90
|
parser (3.0.2.0)
|
14
91
|
ast (~> 2.4.1)
|
92
|
+
public_suffix (4.0.6)
|
15
93
|
rainbow (3.0.0)
|
16
94
|
rake (13.0.6)
|
95
|
+
rchardet (1.8.0)
|
17
96
|
regexp_parser (2.1.1)
|
18
97
|
rexml (3.2.5)
|
19
98
|
rspec (3.10.0)
|
@@ -43,6 +122,10 @@ GEM
|
|
43
122
|
rubocop-ast (1.8.0)
|
44
123
|
parser (>= 3.0.1.1)
|
45
124
|
ruby-progressbar (1.11.0)
|
125
|
+
ruby2_keywords (0.0.5)
|
126
|
+
sawyer (0.8.2)
|
127
|
+
addressable (>= 2.3.5)
|
128
|
+
faraday (> 0.8, < 2.0)
|
46
129
|
simplecov (0.21.2)
|
47
130
|
docile (~> 1.1)
|
48
131
|
simplecov-html (~> 0.11)
|
@@ -51,12 +134,17 @@ GEM
|
|
51
134
|
simplecov (~> 0.8)
|
52
135
|
simplecov-html (0.12.3)
|
53
136
|
simplecov_json_formatter (0.1.3)
|
137
|
+
terminal-table (3.0.2)
|
138
|
+
unicode-display_width (>= 1.1.1, < 3)
|
54
139
|
unicode-display_width (2.0.0)
|
55
140
|
|
56
141
|
PLATFORMS
|
142
|
+
ruby
|
57
143
|
x86_64-darwin-20
|
144
|
+
x86_64-linux
|
58
145
|
|
59
146
|
DEPENDENCIES
|
147
|
+
gitlab-dangerfiles (~> 2.8.0)
|
60
148
|
rake (~> 13.0)
|
61
149
|
rspec (~> 3.0)
|
62
150
|
rspec_junit_formatter (~> 0.4.0)
|
@@ -66,4 +154,4 @@ DEPENDENCIES
|
|
66
154
|
tanuki_emoji!
|
67
155
|
|
68
156
|
BUNDLED WITH
|
69
|
-
2.2.
|
157
|
+
2.2.22
|
data/README.md
CHANGED
@@ -70,17 +70,36 @@ File.join(TanukiEmoji.images_path, c.image_name)
|
|
70
70
|
|
71
71
|
## Development
|
72
72
|
|
73
|
-
|
74
|
-
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
73
|
+
In order to contribute to TanukiEmoji gem, you need to:
|
75
74
|
|
76
|
-
|
77
|
-
|
78
|
-
|
75
|
+
1. Clone the repository to your local machine.
|
76
|
+
1. Run `bin/setup` to initialize `git submodules` and install ruby dependencies.
|
77
|
+
|
78
|
+
Many workflow tasks are available as Rake tasks:
|
79
|
+
|
80
|
+
- `bundle exec rake spec` can be used to run tests.
|
81
|
+
- `bundle exec rake install` will build and install the gem on your local machine.
|
82
|
+
|
83
|
+
To load an interactive console with the gem you can use `bin/console`.
|
84
|
+
|
85
|
+
### Releasing a new version
|
86
|
+
|
87
|
+
Before releasing a new gem, create a MR with the following changes:
|
88
|
+
|
89
|
+
- Update `CHANGELOG.md` by adding a version section and moving any changes from `[Unreleased]` to it.
|
90
|
+
- Update the version number in `lib/tanuki_emoji/version.rb`.
|
91
|
+
|
92
|
+
With that MR approved and merged, pull the changes to your `main` branch and run `bundle exec rake release`.
|
93
|
+
This command will create a git tag for the version and push it, generate a new `.gem` file and publish into
|
79
94
|
[rubygems.org](https://rubygems.org).
|
80
95
|
|
81
96
|
## Contributing
|
82
97
|
|
83
|
-
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
98
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) and [Development](#development) section.
|
99
|
+
|
100
|
+
When you create a new Merge Request, consider adding your change to the `CHANGELOG.md` if it includes a new feature, a feature change or a fix.
|
101
|
+
|
102
|
+
Please do not increase the version numbers, as this is handled by a separate process when we [release a new version](#releasing-a-new-version).
|
84
103
|
|
85
104
|
## License
|
86
105
|
|
data/Rakefile
CHANGED
@@ -42,12 +42,11 @@ namespace :noto_emoji do
|
|
42
42
|
|
43
43
|
task :generate_flags do
|
44
44
|
chdir(File.expand_path(noto_emoji_path)) do
|
45
|
-
Dir['third_party/region-flags/png/*.png'].
|
46
|
-
|
47
|
-
puts filename
|
48
|
-
|
49
|
-
sh("make build/flags/#{filename}")
|
45
|
+
flags = Dir['third_party/region-flags/png/*.png'].map do |file|
|
46
|
+
File.join('build/flags', File.basename(file))
|
50
47
|
end
|
48
|
+
|
49
|
+
sh('make', *flags)
|
51
50
|
end
|
52
51
|
end
|
53
52
|
end
|
@@ -9,28 +9,36 @@ 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
|
15
16
|
|
16
17
|
# This denotes a "plain" (black/white) or "textual" version
|
17
18
|
PLAIN_VARIATION_SELECTOR = 0xFE0E
|
19
|
+
PLAIN_VARIATION_SELECTOR_STRING = PLAIN_VARIATION_SELECTOR.chr(Encoding::UTF_8)
|
18
20
|
|
19
21
|
# Zero Width Joiner is used in sequences to indicate they should all be evaluated and displayed as a single thing
|
20
22
|
ZWJ_TAG = 0x200D
|
21
23
|
|
22
|
-
attr_reader :name, :codepoints, :codepoints_alternates, :alpha_code, :aliases, :description
|
24
|
+
attr_reader :name, :codepoints, :codepoints_alternates, :alpha_code, :aliases, :ascii_aliases, :description, :category
|
25
|
+
|
26
|
+
attr_accessor :unicode_version
|
23
27
|
|
24
28
|
# @param [String] name
|
25
29
|
# @param [String] codepoints
|
26
30
|
# @param [String] alpha_code
|
27
|
-
|
28
|
-
|
31
|
+
# @param [String] description
|
32
|
+
# @param [String] category
|
33
|
+
def initialize(name, codepoints:, alpha_code:, description:, category:)
|
34
|
+
@name = self.class.format_name(name)
|
29
35
|
@codepoints = codepoints
|
30
36
|
@codepoints_alternates = []
|
31
37
|
@alpha_code = self.class.format_alpha_code(alpha_code)
|
32
38
|
@aliases = []
|
39
|
+
@ascii_aliases = []
|
33
40
|
@description = description
|
41
|
+
@category = category
|
34
42
|
end
|
35
43
|
|
36
44
|
# Add alternative codepoints to this character
|
@@ -47,6 +55,13 @@ module TanukiEmoji
|
|
47
55
|
aliases << self.class.format_alpha_code(alpha_code)
|
48
56
|
end
|
49
57
|
|
58
|
+
# Add alternative ASCII aliases to this character
|
59
|
+
#
|
60
|
+
# @param [String] ascii_string
|
61
|
+
def add_ascii_alias(ascii_string)
|
62
|
+
ascii_aliases << ascii_string
|
63
|
+
end
|
64
|
+
|
50
65
|
# Return a Hex formatted version of the Unicode code points
|
51
66
|
#
|
52
67
|
# @return [String] Hex formatted version of the unicode
|
@@ -82,14 +97,28 @@ module TanukiEmoji
|
|
82
97
|
"#<#{self.class.name}:#{name} #{codepoints}(#{hex})>"
|
83
98
|
end
|
84
99
|
|
85
|
-
|
86
|
-
|
87
|
-
|
100
|
+
def ==(other)
|
101
|
+
name == other.name &&
|
102
|
+
codepoints == other.codepoints &&
|
103
|
+
codepoints_alternates == other.codepoints_alternates &&
|
104
|
+
alpha_code == other.alpha_code &&
|
105
|
+
aliases == other.aliases &&
|
106
|
+
ascii_aliases == other.ascii_aliases &&
|
107
|
+
description == other.description
|
108
|
+
end
|
109
|
+
|
110
|
+
# Ensure alpha code is formatted with colons
|
88
111
|
#
|
89
112
|
# @param [String] alpha_code
|
90
113
|
# @return [String] formatted alpha code
|
91
114
|
def self.format_alpha_code(alpha_code)
|
92
|
-
alpha_code.match?(
|
115
|
+
alpha_code.to_s.match?(ALPHA_CODE_REGEXP) ? alpha_code.to_s : ":#{alpha_code}:"
|
116
|
+
end
|
117
|
+
|
118
|
+
def self.format_name(raw_name)
|
119
|
+
matched = raw_name.match(ALPHA_CODE_REGEXP)
|
120
|
+
|
121
|
+
matched ? matched['alpha_text'] : raw_name
|
93
122
|
end
|
94
123
|
|
95
124
|
private
|
@@ -28,7 +28,8 @@ module TanukiEmoji
|
|
28
28
|
emoji = Character.new(emoji_name.to_s,
|
29
29
|
codepoints: emoji_data[:moji],
|
30
30
|
alpha_code: emoji_data[:shortname],
|
31
|
-
description: emoji_data[:name]
|
31
|
+
description: emoji_data[:name],
|
32
|
+
category: emoji_data[:category])
|
32
33
|
|
33
34
|
emoji_data[:unicode_alternates].each do |unicode_alternates|
|
34
35
|
codepoints = unicode_hex_to_codepoint(unicode_alternates)
|
@@ -40,6 +41,10 @@ module TanukiEmoji
|
|
40
41
|
emoji.add_alias(alpha_code)
|
41
42
|
end
|
42
43
|
|
44
|
+
emoji_data[:aliases_ascii].each do |ascii_string|
|
45
|
+
emoji.add_ascii_alias(ascii_string)
|
46
|
+
end
|
47
|
+
|
43
48
|
@index.add(emoji)
|
44
49
|
end
|
45
50
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module TanukiEmoji
|
6
|
+
module Db
|
7
|
+
# Emoji Unicode Version database
|
8
|
+
class UnicodeVersion
|
9
|
+
DATA_FILE = 'vendor/emoji-unicode-version/emoji-unicode-version-map.json'
|
10
|
+
|
11
|
+
def self.data_file
|
12
|
+
File.expand_path(File.join(__dir__, '../../../', DATA_FILE))
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :data_file
|
16
|
+
|
17
|
+
def initialize(index:, data_file: self.class.data_file)
|
18
|
+
@data_file = data_file
|
19
|
+
@index = index
|
20
|
+
end
|
21
|
+
|
22
|
+
def load!
|
23
|
+
db = File.open(data_file, 'r:UTF-8') do |file|
|
24
|
+
JSON.parse(file.read, symbolize_names: true)
|
25
|
+
end
|
26
|
+
|
27
|
+
db.each do |emoji_name, unicode_version|
|
28
|
+
emoji = @index.find_by_alpha_code(emoji_name)
|
29
|
+
|
30
|
+
next unless emoji
|
31
|
+
|
32
|
+
emoji.unicode_version = unicode_version
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/tanuki_emoji/db.rb
CHANGED
data/lib/tanuki_emoji/index.rb
CHANGED
@@ -8,11 +8,13 @@ module TanukiEmoji
|
|
8
8
|
include Singleton
|
9
9
|
include Enumerable
|
10
10
|
|
11
|
+
# @return [Array<TanukiEmoji::Character>] a collection of TanukiEmoji::Character
|
11
12
|
attr_reader :all
|
12
13
|
|
13
14
|
# Add a new Emoji to the index
|
14
15
|
#
|
15
16
|
# @param [TanukiEmoji::Character] emoji
|
17
|
+
# @return [TanukiEmoji::Character]
|
16
18
|
def add(emoji)
|
17
19
|
@name_index ||= {}
|
18
20
|
@alpha_code_index ||= {}
|
@@ -36,7 +38,8 @@ module TanukiEmoji
|
|
36
38
|
end
|
37
39
|
|
38
40
|
emoji.aliases.each do |alpha_code|
|
39
|
-
@
|
41
|
+
@name_index[::TanukiEmoji::Character.format_name(alpha_code)] = emoji
|
42
|
+
@alpha_code_index[::TanukiEmoji::Character.format_alpha_code(alpha_code)] = emoji
|
40
43
|
end
|
41
44
|
end
|
42
45
|
|
@@ -68,11 +71,32 @@ module TanukiEmoji
|
|
68
71
|
def reset!(reload: true)
|
69
72
|
@all = []
|
70
73
|
|
71
|
-
load_data_files if reload
|
72
|
-
|
73
74
|
remove_instance_variable :@name_index if defined? @name_index
|
74
75
|
remove_instance_variable :@alpha_code_index if defined? @alpha_code_index
|
75
76
|
remove_instance_variable :@codepoints_index if defined? @codepoints_index
|
77
|
+
|
78
|
+
load_data_files if reload
|
79
|
+
end
|
80
|
+
|
81
|
+
# Return a regular expression that can be used to search for indexed `:alpha_codes:`
|
82
|
+
#
|
83
|
+
# @return [Regexp] regular expression that matches indexed `:alpha_code:`
|
84
|
+
def alpha_code_pattern
|
85
|
+
/(?<=[^[:alnum:]:]|\n|^)
|
86
|
+
:(#{@name_index.keys.map { |name| Regexp.escape(name) }.join('|')}):
|
87
|
+
(?=[^[:alnum:]:]|$)/x
|
88
|
+
end
|
89
|
+
|
90
|
+
# Return a regular expression that can be used to search for emoji codepoints
|
91
|
+
#
|
92
|
+
# @param [Boolean] exclude_text_presentation exclude codepoints and sequences with text presentation selector
|
93
|
+
# @return [Regexp] regular expression that matches indexed emoji codepoints
|
94
|
+
def codepoints_pattern(exclude_text_presentation: false)
|
95
|
+
possible_codepoints = sorted_codepoints.map { |moji, _| Regexp.escape(moji) }.join('|')
|
96
|
+
variation_selector = ""
|
97
|
+
variation_selector = /(?!#{TanukiEmoji::Character::PLAIN_VARIATION_SELECTOR_STRING})/ if exclude_text_presentation
|
98
|
+
|
99
|
+
/(#{possible_codepoints})#{variation_selector}/
|
76
100
|
end
|
77
101
|
|
78
102
|
private
|
@@ -89,6 +113,13 @@ module TanukiEmoji
|
|
89
113
|
|
90
114
|
def load_data_files
|
91
115
|
Db::Gemojione.new(index: self).load!
|
116
|
+
Db::UnicodeVersion.new(index: self).load!
|
117
|
+
end
|
118
|
+
|
119
|
+
# Order the codepoints to match the most specific (longest) sequences first,
|
120
|
+
# so #gsub doesn't unintentionally split an emoji from its modifier(s).
|
121
|
+
def sorted_codepoints
|
122
|
+
@sorted_codepoints ||= @codepoints_index.dup.sort_by { |_, v| -v.hex.length }
|
92
123
|
end
|
93
124
|
end
|
94
125
|
end
|
data/lib/tanuki_emoji/version.rb
CHANGED
data/lib/tanuki_emoji.rb
CHANGED
@@ -38,8 +38,15 @@ module TanukiEmoji
|
|
38
38
|
# @param [String] name
|
39
39
|
# @param [String] codepoints
|
40
40
|
# @param [String] alpha_code
|
41
|
-
|
42
|
-
|
41
|
+
# @param [String] description
|
42
|
+
# @param [String] category
|
43
|
+
# @return [TanukiEmoji::Character]
|
44
|
+
def self.add(name, codepoints:, alpha_code:, description:, category:)
|
45
|
+
emoji = Character.new(name,
|
46
|
+
codepoints: codepoints,
|
47
|
+
alpha_code: alpha_code,
|
48
|
+
description: description,
|
49
|
+
category: category)
|
43
50
|
|
44
51
|
index.add(emoji)
|
45
52
|
end
|
data/tanuki_emoji.gemspec
CHANGED
@@ -15,8 +15,9 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
16
16
|
|
17
17
|
spec.metadata['homepage_uri'] = spec.homepage
|
18
|
-
spec.metadata['source_code_uri'] =
|
19
|
-
spec.metadata['changelog_uri'] =
|
18
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
19
|
+
spec.metadata['changelog_uri'] = "#{spec.homepage}/-/blob/main/CHANGELOG.md"
|
20
|
+
spec.metadata['bug_tracker_uri'] = "#{spec.homepage}/-/issues"
|
20
21
|
|
21
22
|
# Specify which files should be added to the gem when it is released.
|
22
23
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -27,4 +28,6 @@ Gem::Specification.new do |spec|
|
|
27
28
|
git_files + asset_files
|
28
29
|
end
|
29
30
|
spec.require_paths = ['lib']
|
31
|
+
|
32
|
+
spec.add_development_dependency 'gitlab-dangerfiles', '~> 2.8.0'
|
30
33
|
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
[![npm](https://img.shields.io/npm/v/emoji-unicode-version.svg?style=flat-square)](https://www.npmjs.com/package/emoji-unicode-version)
|
2
|
+
|
3
|
+
# emoji-unicode-version
|
4
|
+
|
5
|
+
Get the unicode version for a given emoji name.
|
6
|
+
|
7
|
+
Useful for testing native unicode emoji support. Test a single emoji and assume any other emoji with that same version is supported.
|
8
|
+
|
9
|
+
```
|
10
|
+
npm install emoji-unicode-version
|
11
|
+
```
|
12
|
+
|
13
|
+
|
14
|
+
# Usage
|
15
|
+
|
16
|
+
```js
|
17
|
+
const emojiNameToUnicodeVersion = require('emoji-unicode-version');
|
18
|
+
|
19
|
+
// 6.1
|
20
|
+
console.log(emojiNameToUnicodeVersion('grinning'));
|
21
|
+
// 9.0
|
22
|
+
console.log(emojiNameToUnicodeVersion('rofl'));
|
23
|
+
```
|
24
|
+
|
25
|
+
### Get version from unicode
|
26
|
+
|
27
|
+
```js
|
28
|
+
const emojiNameToUnicodeVersion = require('emoji-unicode-version');
|
29
|
+
const emojione = require('emojione');
|
30
|
+
|
31
|
+
function unicodeToName(emojiUnicode) {
|
32
|
+
const emojiShortName = emojione.toShort(emojiUnicode);
|
33
|
+
const emojiName = emojiShortName.slice(1, emojiShortName.length - 1);
|
34
|
+
return emojiName;
|
35
|
+
}
|
36
|
+
|
37
|
+
// grinning, 6.1
|
38
|
+
console.log(emojiNameToUnicodeVersion(unicodeToName('😀')));
|
39
|
+
// rofl, 9.0
|
40
|
+
console.log(emojiNameToUnicodeVersion(unicodeToName('🤣')));
|
41
|
+
```
|
42
|
+
|
43
|
+
|
44
|
+
# About
|
45
|
+
|
46
|
+
Emoji name list is pulled from [EmojiOne](https://github.com/Ranks/emojione)
|
47
|
+
|
48
|
+
We grab the emoji unicode versions from [Emojipedia](http://emojipedia.org/unicode-6.1/).
|
49
|
+
|
50
|
+
[ZWJ sequences](http://emojipedia.org/emoji-zwj-sequences/) use the unicode version for the highest individual emoji in the sequence.
|
51
|
+
|
52
|
+
|
53
|
+
Also See
|
54
|
+
|
55
|
+
- http://unicode.org/emoji/charts-beta/full-emoji-list.html
|
56
|
+
- http://www.unicode.org/Public/emoji/5.0/emoji-data.txt
|
57
|
+
- http://unicode.org/Public/emoji/5.0/emoji-zwj-sequences.txt
|