twemoji 3.1.2 → 3.1.7

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: 9e8e331f42d9cf8b602c4466ade46546a733277f
4
- data.tar.gz: 0a337ff8837085faf8e5e8b6605f38f812e1b8f3
2
+ SHA256:
3
+ metadata.gz: d9a1954a7f67da596f244eda65edc096ff49e2ad2b99d1f5953ebd80eb4db463
4
+ data.tar.gz: 5769167d7fe63671ac1a4270b7a7091559693aa3011f026c58904bf2ef2bb866
5
5
  SHA512:
6
- metadata.gz: 159906c1634d0afee8d1793157afcf9e7bba286816aa545f501ab5569b82e557c05c6b4ab5bef0f1411a8d8527f80098a61ded5f064723e5ac84c3aa53a9e942
7
- data.tar.gz: 34102f8e46e2b6405f709c2eb8228e0aef8bc60e8d6b6e78505d92d75189bb9aa7c16e22fc76c58477e9d8d0e8bd066172f5edb951296066a99e2124fdda1c44
6
+ metadata.gz: 7b17055f1396ed5bf86453c5bf81fea0a341eddb3bf0ef2566f809697a07a0c6a54426c4fa55f94607f6423b60e30ab54f13dcd2ff853e07d9869fb402b291a1
7
+ data.tar.gz: 4ab9fcd8d6f1c66a64c90eb8704edfc70a75e80600eeb4d6610289adabcf9a1f5ee72b66379dd52c1f1381e59b44a09cb318ad73560916421c741efb2df8b64d
@@ -2,6 +2,27 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.1.7 - 2020.09.28
6
+
7
+ - Relax required ruby version
8
+
9
+ ## 3.1.6 - 2019.12.21
10
+
11
+ - Moved expensive computations to constant [#53](https://github.com/jollygoodcode/twemoji/pull/53)
12
+
13
+ ## 3.1.5 - 2019.06.02
14
+
15
+ - Introduced `Twemoji::Utils::Unicode.unpack` [#51](https://github.com/jollygoodcode/twemoji/pull/51)
16
+ - Do not set attribute on generated element if not specified [#49](https://github.com/jollygoodcode/twemoji/pull/49)
17
+
18
+ ## 3.1.4 - 2017.07.22
19
+
20
+ - Fixes woman skin 6 emoji [#44](https://github.com/jollygoodcode/twemoji/pull/44)
21
+
22
+ ## 3.1.3 - 2017.07.22
23
+
24
+ - Fixes name of kiss emoji [#42](https://github.com/jollygoodcode/twemoji/pull/42)
25
+
5
26
  ## 3.1.2 - 2017.03.20
6
27
 
7
28
  - Abstract constants into yaml files [#39](https://github.com/jollygoodcode/twemoji/pull/39)
data/README.md CHANGED
@@ -297,7 +297,7 @@ To properly support emoji, the document character must be set to UTF-8. This can
297
297
 
298
298
  ## Attribution Requirements
299
299
 
300
- **IMPORTANT:** Please follow the [Attribution Requirements](https://github.com/twitter/twemoji#attribution-requirements) as stated on the official Twemoji (JS) repo.
300
+ **IMPORTANT:** Please follow the [Attribution Requirements](https://github.com/twitter/twemoji#attribution-requirements) as stated on the official Twemoji (JavaScript) repo.
301
301
 
302
302
  ## Contributing
303
303
 
@@ -5,6 +5,7 @@ require "json"
5
5
  require "twemoji/version"
6
6
  require "twemoji/map"
7
7
  require "twemoji/configuration"
8
+ require "twemoji/utils/unicode"
8
9
 
9
10
  # Twemoji is a Ruby implementation, parses your text, replace emoji text
10
11
  # with corresponding emoji image. Default emoji images are from Twiiter CDN.
@@ -125,7 +126,7 @@ module Twemoji
125
126
  #
126
127
  # @return [RegExp] A Regular expression consists of all emojis text.
127
128
  def self.emoji_pattern
128
- @emoji_pattern ||= /(#{codes.keys.map { |name| Regexp.quote(name) }.join("|") })/
129
+ EMOJI_PATTERN
129
130
  end
130
131
 
131
132
  # Return all emoji patterns' regular expressions in unicode.
@@ -133,21 +134,31 @@ module Twemoji
133
134
  #
134
135
  # @return [RegExp] A Regular expression consists of all emojis unicode.
135
136
  def self.emoji_pattern_unicode
136
- @emoji_pattern_unicode ||= /(#{sorted_codepoint_values.map { |name| Regexp.quote(name.split('-').collect {|n| n.hex}.pack("U*")) }.join("|") })/
137
+ EMOJI_PATTERN_UNICODE
137
138
  end
138
139
 
139
140
  # Return all emoji patterns' regular expressions in unicode and name.
140
141
  #
141
142
  # @return [RegExp] A Regular expression consists of all emojis unicode codepoint and names.
142
143
  def self.emoji_pattern_all
143
- names = codes.keys.map { |name| Regexp.quote(name) }.join("|")
144
- codepoints = sorted_codepoint_values.map { |name| Regexp.quote(name.split('-').collect {|n| n.hex}.pack("U*")) }.join("|")
145
-
146
- @emoji_pattern_all ||= /(#{names}|#{codepoints})/
144
+ EMOJI_PATTERN_ALL
147
145
  end
148
146
 
149
147
  private
150
148
 
149
+ # Return sorted codepoint values by descending length.
150
+ #
151
+ # @return [Array] An array of emoji codepoint values sorted by descending length
152
+ def self.sorted_codepoint_values
153
+ # has to be sorted to match the combined codepoint (2-3 char emojis) before single char emojis
154
+ @sorted_codepoint_values ||= invert_codes.keys.sort_by {|key| key.length }.reverse
155
+ end
156
+
157
+ EMOJI_PATTERN = /#{codes.keys.map { |name| Regexp.quote(name) }.join("|")}/.freeze
158
+ EMOJI_PATTERN_UNICODE = /#{sorted_codepoint_values.map { |name| Regexp.quote(name.split('-').collect {|n| n.hex}.pack("U*")) }.join("|")}/.freeze
159
+ EMOJI_PATTERN_ALL = /(#{EMOJI_PATTERN}|#{EMOJI_PATTERN_UNICODE})/.freeze
160
+ private_constant :EMOJI_PATTERN, :EMOJI_PATTERN_UNICODE, :EMOJI_PATTERN_ALL
161
+
151
162
  # Ensure text is a string.
152
163
  #
153
164
  # @param text [String] Text to ensure to be a string.
@@ -309,7 +320,7 @@ module Twemoji
309
320
  # @return String representation of unicode codepoint
310
321
  # @private
311
322
  def self.unicode_to_str(unicode)
312
- unicode.split("").map { |r| "%x" % r.ord }.join("-")
323
+ Twemoji::Utils::Unicode.unpack(unicode)
313
324
  end
314
325
 
315
326
  # Coverts hash of attributes into HTML attributes.
@@ -318,14 +329,6 @@ module Twemoji
318
329
  # @return [String] HTML attributes suitable for use in tag
319
330
  # @private
320
331
  def self.hash_to_html_attrs(hash)
321
- hash.map { |attr, value| %(#{attr}="#{value}") }.join(" ")
322
- end
323
-
324
- # Return sorted codepoint values by descending length.
325
- #
326
- # @return [Array] An array of emoji codepoint values sorted by descending length
327
- def self.sorted_codepoint_values
328
- # has to be sorted to match the combined codepoint (2-3 char emojis) before single char emojis
329
- @sorted_codepoint_values ||= invert_codes.keys.sort_by {|key| key.length }.reverse
332
+ hash.reject { |key, value| value.nil? || value == '' }.map { |attr, value| %(#{attr}="#{value}") }.join(" ")
330
333
  end
331
334
  end
@@ -797,7 +797,7 @@
797
797
  ":woman::skin-tone-3:": https://twemoji.maxcdn.com/2/72x72/1f469-1f3fc.png
798
798
  ":woman::skin-tone-4:": https://twemoji.maxcdn.com/2/72x72/1f469-1f3fd.png
799
799
  ":woman::skin-tone-5:": https://twemoji.maxcdn.com/2/72x72/1f469-1f3fe.png
800
- ":woman::skin-tone-6": https://twemoji.maxcdn.com/2/72x72/1f469-1f3ff.png
800
+ ":woman::skin-tone-6:": https://twemoji.maxcdn.com/2/72x72/1f469-1f3ff.png
801
801
  ":woman:": https://twemoji.maxcdn.com/2/72x72/1f469.png
802
802
  ":woman-woman-boy:": https://twemoji.maxcdn.com/2/72x72/1f469-200d-1f469-200d-1f466.png
803
803
  ":woman-woman-boy-boy:": https://twemoji.maxcdn.com/2/72x72/1f469-200d-1f469-200d-1f466-200d-1f466.png
@@ -806,7 +806,7 @@
806
806
  ":woman-woman-girl-girl:": https://twemoji.maxcdn.com/2/72x72/1f469-200d-1f469-200d-1f467-200d-1f467.png
807
807
  ":woman-heart-man:": https://twemoji.maxcdn.com/2/72x72/1f469-200d-2764-fe0f-200d-1f468.png
808
808
  ":woman-heart-woman:": https://twemoji.maxcdn.com/2/72x72/1f469-200d-2764-fe0f-200d-1f469.png
809
- ":kiss::man:": https://twemoji.maxcdn.com/2/72x72/1f469-200d-2764-fe0f-200d-1f48b-200d-1f468.png
809
+ ":woman-kiss-man:": https://twemoji.maxcdn.com/2/72x72/1f469-200d-2764-fe0f-200d-1f48b-200d-1f468.png
810
810
  ":woman-kiss-woman:": https://twemoji.maxcdn.com/2/72x72/1f469-200d-2764-fe0f-200d-1f48b-200d-1f469.png
811
811
  ":family:": https://twemoji.maxcdn.com/2/72x72/1f46a.png
812
812
  ":couple:": https://twemoji.maxcdn.com/2/72x72/1f46b.png
@@ -797,7 +797,7 @@
797
797
  ":woman::skin-tone-3:": https://twemoji.maxcdn.com/2/svg/1f469-1f3fc.svg
798
798
  ":woman::skin-tone-4:": https://twemoji.maxcdn.com/2/svg/1f469-1f3fd.svg
799
799
  ":woman::skin-tone-5:": https://twemoji.maxcdn.com/2/svg/1f469-1f3fe.svg
800
- ":woman::skin-tone-6": https://twemoji.maxcdn.com/2/svg/1f469-1f3ff.svg
800
+ ":woman::skin-tone-6:": https://twemoji.maxcdn.com/2/svg/1f469-1f3ff.svg
801
801
  ":woman:": https://twemoji.maxcdn.com/2/svg/1f469.svg
802
802
  ":woman-woman-boy:": https://twemoji.maxcdn.com/2/svg/1f469-200d-1f469-200d-1f466.svg
803
803
  ":woman-woman-boy-boy:": https://twemoji.maxcdn.com/2/svg/1f469-200d-1f469-200d-1f466-200d-1f466.svg
@@ -806,7 +806,7 @@
806
806
  ":woman-woman-girl-girl:": https://twemoji.maxcdn.com/2/svg/1f469-200d-1f469-200d-1f467-200d-1f467.svg
807
807
  ":woman-heart-man:": https://twemoji.maxcdn.com/2/svg/1f469-200d-2764-fe0f-200d-1f468.svg
808
808
  ":woman-heart-woman:": https://twemoji.maxcdn.com/2/svg/1f469-200d-2764-fe0f-200d-1f469.svg
809
- ":kiss::man:": https://twemoji.maxcdn.com/2/svg/1f469-200d-2764-fe0f-200d-1f48b-200d-1f468.svg
809
+ ":woman-kiss-man:": https://twemoji.maxcdn.com/2/svg/1f469-200d-2764-fe0f-200d-1f48b-200d-1f468.svg
810
810
  ":woman-kiss-woman:": https://twemoji.maxcdn.com/2/svg/1f469-200d-2764-fe0f-200d-1f48b-200d-1f469.svg
811
811
  ":family:": https://twemoji.maxcdn.com/2/svg/1f46a.svg
812
812
  ":couple:": https://twemoji.maxcdn.com/2/svg/1f46b.svg
@@ -797,7 +797,7 @@
797
797
  ":woman::skin-tone-3:": 1f469-1f3fc
798
798
  ":woman::skin-tone-4:": 1f469-1f3fd
799
799
  ":woman::skin-tone-5:": 1f469-1f3fe
800
- ":woman::skin-tone-6": 1f469-1f3ff
800
+ ":woman::skin-tone-6:": 1f469-1f3ff
801
801
  ":woman:": 1f469
802
802
  ":woman-woman-boy:": 1f469-200d-1f469-200d-1f466
803
803
  ":woman-woman-boy-boy:": 1f469-200d-1f469-200d-1f466-200d-1f466
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Twemoji
4
+ module Utils
5
+ module Unicode
6
+ # Convert raw unicode to string key version.
7
+ #
8
+ # e.g. 🇲🇾 converts to "1f1f2-1f1fe"
9
+ #
10
+ # @param unicode [String] Unicode codepoint.
11
+ # @param connector [String] (optional) connector to join codepoints
12
+ #
13
+ # @return [String] codepoints of unicode join by connector argument, defaults to "-".
14
+ def self.unpack(unicode, connector: "-")
15
+ unicode.split("").map { |r| "%x" % r.ord }.join(connector)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Twemoji
4
- VERSION = "3.1.2"
4
+ VERSION = "3.1.7"
5
5
  end
@@ -17,7 +17,5 @@ Gem::Specification.new do |spec|
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f =~ %r(^(test)/) }
18
18
  spec.require_paths = %w(lib)
19
19
 
20
- spec.required_ruby_version = "~> 2.0"
21
-
22
20
  spec.add_dependency "nokogiri", "~> 1.6"
23
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twemoji
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.2
4
+ version: 3.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juanito
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-03-20 00:00:00.000000000 Z
12
+ date: 2020-09-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -49,6 +49,7 @@ files:
49
49
  - lib/twemoji/map.rb
50
50
  - lib/twemoji/png.rb
51
51
  - lib/twemoji/svg.rb
52
+ - lib/twemoji/utils/unicode.rb
52
53
  - lib/twemoji/version.rb
53
54
  - twemoji.gemspec
54
55
  homepage: https://github.com/jollygoodcode/twemoji
@@ -61,17 +62,16 @@ require_paths:
61
62
  - lib
62
63
  required_ruby_version: !ruby/object:Gem::Requirement
63
64
  requirements:
64
- - - "~>"
65
+ - - ">="
65
66
  - !ruby/object:Gem::Version
66
- version: '2.0'
67
+ version: '0'
67
68
  required_rubygems_version: !ruby/object:Gem::Requirement
68
69
  requirements:
69
70
  - - ">="
70
71
  - !ruby/object:Gem::Version
71
72
  version: '0'
72
73
  requirements: []
73
- rubyforge_project:
74
- rubygems_version: 2.5.2
74
+ rubygems_version: 3.0.3
75
75
  signing_key:
76
76
  specification_version: 4
77
77
  summary: 'A RubyGem to convert :heart: to Twitter cdn url'