unicode-emoji 2.0.0 β†’ 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 32bec9a0f826ab808cf77b3bf69e8248de000d99
4
- data.tar.gz: 6c8a53dc8874ab6bf508aad2a914eded9a7a4889
2
+ SHA256:
3
+ metadata.gz: 8d675646d8ef27dbc768ba3d6369e73517a02304fab8e3d347f19fd9547530fd
4
+ data.tar.gz: d51a73ac0f15a6157b54d10fc4f8abca20f77857ba713a646bf9830c286b7449
5
5
  SHA512:
6
- metadata.gz: c5ebaf7c4c6a66331af9c0f927f8f41079aaf89d3389c4ba84533c1f64fbd2b4456657971e05c437987568c6853f844f1084986721cede6da8979696e4efffd6
7
- data.tar.gz: 3fc8af7fc6bdcaac8ac14ec148c4322a8d26a1e627895ec54a3a038a85062c9f00d37317208cdbe876cdc31603e83943eac569ee937bccfd7e44df15d239ac19
6
+ metadata.gz: 49c0162a4784b3f67307e558fa40d64024f79c2a67c365e5dda05895249b2c3148a78d0021ecfcf29387583a3c738584dad5634ca1317eb48521cb6511755ae8
7
+ data.tar.gz: 5dddd9292e205b09330cd2adfc69e838b86cb96ee72b205b4aab2db860667b8e31ce7ea2e55d12dbf8f5b5f08097fa1ee2a51ffff3d5fcaa00f4aafa5f1729aa
@@ -1,5 +1,10 @@
1
1
  ## CHANGELOG
2
2
 
3
+ ### 2.1.0
4
+
5
+ - Add `REGEX_PICTO` which matches codepoints with the **Extended_Pictographic** property
6
+ - Add `REGEX_PICTO_NO_EMOJI` which matches codepoints with the **Extended_Pictographic** property, but no **Emoji** property
7
+
3
8
  ### 2.0.0
4
9
 
5
10
  - Emoji 12.0 data (including valid subdivisions)
data/Gemfile CHANGED
@@ -1,6 +1,7 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'minitest'
6
- gem 'rake'
5
+ gem "minitest"
6
+ gem "rake"
7
+ gem "irb"
data/README.md CHANGED
@@ -89,6 +89,14 @@ Regex | Description | Example Matches | Example Non-Matc
89
89
  `Unicode::Emoji::REGEX_VALID_INCLUDE_TEXT` | `REGEX_VALID` + `REGEX_TEXT` | `😴`, `▢️`, `πŸ›ŒπŸ½`, `πŸ‡΅πŸ‡Ή`, `2️⃣`, `🏴󠁧󠁒󠁳󠁣󠁴󠁿`, `🏴󠁧󠁒󠁑󠁧󠁒󠁿`, `πŸ€ΎπŸ½β€β™€οΈ`, `πŸ€ β€πŸ€’`, `😴︎`, `β–Ά` | `🏻`, `πŸ‡΅πŸ‡΅`
90
90
  `Unicode::Emoji::REGEX_WELL_FORMED_INCLUDE_TEXT` | `REGEX_WELL_FORMED` + `REGEX_TEXT` | `😴`, `▢️`, `πŸ›ŒπŸ½`, `πŸ‡΅πŸ‡Ή`, `2️⃣`, `🏴󠁧󠁒󠁳󠁣󠁴󠁿`, `🏴󠁧󠁒󠁑󠁧󠁒󠁿`, `πŸ€ΎπŸ½β€β™€οΈ`, `πŸ€ β€πŸ€’`, `πŸ‡΅πŸ‡΅`, `😴︎`, `β–Ά` | `🏻`
91
91
 
92
+ #### Extended Pictographic Regex
93
+
94
+ `Unicode::Emoji::REGEX_PICTO` matches single codepoints with the **Extended_Pictographic** property. For example, it will match `βœ€` BLACK SAFETY SCISSORS.
95
+
96
+ `Unicode::Emoji::REGEX_PICTO_NO_EMOJI` matches single codepoints with the **Extended_Pictographic** property, but excludes Emoji characters.
97
+
98
+ See [character.construction/picto](https://character.construction/picto) for a list of all non-Emoji pictographic characters.
99
+
92
100
  #### Partial Regexes
93
101
 
94
102
  Matches potential Emoji parts (often, this is not what you want):
@@ -115,7 +123,7 @@ Unicode::Emoji.list("Food & Drink", "food-asian")
115
123
 
116
124
  Please note that categories might change with future versions of the Emoji standard. This gem will issue warnings when attemting to retrieve old categories using the `#list` method.
117
125
 
118
- A markdown file with all recommended Emoji can be found [in this gist](https://gist.github.com/janlelis/72f9be1f0ecca07372c64cf13894b801).
126
+ A list of all Emoji can be found at [character.construction](https://character.construction).
119
127
 
120
128
  ### Properties
121
129
 
Binary file
@@ -29,8 +29,9 @@ module Unicode
29
29
  EMOJI_COMPONENT = INDEX[:PROPERTIES].select{ |ord, props| props.include?(:C) }.keys.freeze
30
30
  EMOJI_MODIFIER_BASES = INDEX[:PROPERTIES].select{ |ord, props| props.include?(:B) }.keys.freeze
31
31
  EMOJI_MODIFIERS = INDEX[:PROPERTIES].select{ |ord, props| props.include?(:M) }.keys.freeze
32
- # Not needed right now:
33
- # EXTENDED_PICTOGRAPHIC = INDEX[:PROPERTIES].select{ |ord, props| props.include?(:X) }.keys.freeze
32
+
33
+ EXTENDED_PICTOGRAPHIC = INDEX[:PROPERTIES].select{ |ord, props| props.include?(:X) }.keys.freeze
34
+ EXTENDED_PICTOGRAPHIC_NO_EMOJI= INDEX[:PROPERTIES].select{ |ord, props| props.include?(:X) && !props.include?(:E) }.keys.freeze
34
35
  EMOJI_KEYCAPS = INDEX[:KEYCAPS].freeze
35
36
  VALID_REGION_FLAGS = INDEX[:FLAGS].freeze
36
37
  VALID_SUBDIVISIONS = INDEX[:SD].freeze
@@ -53,12 +54,16 @@ module Unicode
53
54
  emoji_modifier_base = "\\p{Emoji Modifier Base}"
54
55
  emoji_component = "\\p{Emoji Component}"
55
56
  emoji_presentation = "\\p{Emoji Presentation}"
57
+ picto = "\\p{Extended Pictographic}"
58
+ picto_no_emoji = "\\p{Extended Pictographic}(?<!\\p{Emoji})"
56
59
  else
57
60
  emoji_character = pack_and_join[EMOJI_CHAR]
58
61
  emoji_modifier = pack_and_join[EMOJI_MODIFIERS]
59
62
  emoji_modifier_base = pack_and_join[EMOJI_MODIFIER_BASES]
60
63
  emoji_component = pack_and_join[EMOJI_COMPONENT]
61
64
  emoji_presentation = pack_and_join[EMOJI_PRESENTATION]
65
+ picto = pack_and_join[EXTENDED_PICTOGRAPHIC]
66
+ picto_no_emoji = pack_and_join[EXTENDED_PICTOGRAPHIC_NO_EMOJI]
62
67
  end
63
68
 
64
69
  emoji_presentation_sequence = \
@@ -196,6 +201,14 @@ module Unicode
196
201
  REGEX_VALID_INCLUDE_TEXT = Regexp.union(REGEX_VALID, REGEX_TEXT)
197
202
  REGEX_WELL_FORMED_INCLUDE_TEXT = Regexp.union(REGEX_WELL_FORMED, REGEX_TEXT)
198
203
 
204
+ REGEX_PICTO = Regexp.compile(
205
+ picto
206
+ )
207
+
208
+ REGEX_PICTO_NO_EMOJI = Regexp.compile(
209
+ picto_no_emoji
210
+ )
211
+
199
212
  def self.properties(char)
200
213
  ord = get_codepoint_value(char)
201
214
  props = INDEX[:PROPERTIES][ord]
@@ -2,10 +2,10 @@
2
2
 
3
3
  module Unicode
4
4
  module Emoji
5
- VERSION = "2.0.0".freeze
6
- EMOJI_VERSION = "12.0".freeze
7
- DATA_DIRECTORY = File.expand_path(File.dirname(__FILE__) + '/../../../data/').freeze
8
- INDEX_FILENAME = (DATA_DIRECTORY + '/emoji.marshal.gz').freeze
5
+ VERSION = "2.1.0"
6
+ EMOJI_VERSION = "12.0"
7
+ DATA_DIRECTORY = File.expand_path(File.dirname(__FILE__) + "/../../../data/").freeze
8
+ INDEX_FILENAME = (DATA_DIRECTORY + "/emoji.marshal.gz").freeze
9
9
 
10
10
  ENABLE_NATIVE_EMOJI_UNICODE_PROPERTIES = false # As of Ruby 2.6.1, Emoji version 11 is included
11
11
  end
@@ -4,8 +4,8 @@ require "minitest/autorun"
4
4
  describe Unicode::Emoji do
5
5
  describe ".properties" do
6
6
  it "returns an Array for Emoji properties if has codepoints" do
7
- assert_equal ["Emoji", "Emoji_Presentation"], Unicode::Emoji.properties("😴")
8
- assert_equal ["Emoji"], Unicode::Emoji.properties("β™ ")
7
+ assert_equal ["Emoji", "Emoji_Presentation", "Extended_Pictographic"], Unicode::Emoji.properties("😴")
8
+ assert_equal ["Emoji", "Extended_Pictographic"], Unicode::Emoji.properties("β™ ")
9
9
  end
10
10
 
11
11
  it "returns nil for Emoji properties if has no codepoints" do
@@ -380,6 +380,20 @@ describe Unicode::Emoji do
380
380
  end
381
381
  end
382
382
 
383
+ describe "REGEX_PICTO" do
384
+ it "matches codepoints with Extended_Pictograph property (almost all emoji are, but also others)" do
385
+ matches = "U+1F32D 🌭 HOT DOG, U+203C β€Ό DOUBLE EXCLAMATION MARK, U+26E8 ⛨ BLACK CROSS ON SHIELD".scan(Unicode::Emoji::REGEX_PICTO)
386
+ assert_equal ["🌭", "β€Ό", "⛨"], matches
387
+ end
388
+ end
389
+
390
+ describe "REGEX_PICTO" do
391
+ it "matches codepoints with Extended_Pictograph property, but no Emoji property" do
392
+ matches = "U+1F32D 🌭 HOT DOG, U+203C β€Ό DOUBLE EXCLAMATION MARK, U+26E8 ⛨ BLACK CROSS ON SHIELD".scan(Unicode::Emoji::REGEX_PICTO_NO_EMOJI)
393
+ assert_equal ["⛨"], matches
394
+ end
395
+ end
396
+
383
397
  describe ".list" do
384
398
  it "returns a grouped list of emoji" do
385
399
  assert_includes Unicode::Emoji.list.keys, "Smileys & Emotion"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unicode-emoji
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.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: 2019-02-19 00:00:00.000000000 Z
11
+ date: 2019-03-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: "[Emoji 12.0] Retrieve emoji data about Unicode codepoints. Also contains
14
14
  a regex to match emoji."
@@ -52,8 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
54
  requirements: []
55
- rubyforge_project:
56
- rubygems_version: 2.5.1
55
+ rubygems_version: 3.0.3
57
56
  signing_key:
58
57
  specification_version: 4
59
58
  summary: Retrieve Emoji data about Unicode codepoints.