twemoji 2.2.2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -3
- data/CHANGELOG.md +33 -2
- data/Gemfile +1 -1
- data/README.md +86 -54
- data/Rakefile +1 -1
- data/lib/twemoji.rb +17 -44
- data/lib/twemoji/configuration.rb +6 -5
- data/lib/twemoji/map.rb +834 -38
- data/lib/twemoji/png.rb +1672 -0
- data/lib/twemoji/svg.rb +1672 -0
- data/lib/twemoji/version.rb +3 -1
- data/twemoji.gemspec +4 -2
- metadata +6 -5
- data/lib/twemoji/json.rb +0 -3321
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca77ba3081ece95f9a99dd12cea08feb0d46dd52
|
4
|
+
data.tar.gz: f9062643a1cd0b4c95ecc7a7049f15c940b3de18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7ee8617d645cae1cc5af9e2a7e623c3acd2e770e6162ddcb82c91fa7f38da08831aeab500441d6960a9751d3a90e72ea61b90a02705e6057b2d4335d7e20b17
|
7
|
+
data.tar.gz: fbc093472b082ba45a89fc3cd6fc9a5562c4ece473ed4fb74b6ff1ff0bce21d77dbffb7597ce54e2ebf0e30fff77f50927bc502fb4094b968bf57b5b934cbcae
|
data/.travis.yml
CHANGED
@@ -1,13 +1,17 @@
|
|
1
1
|
language: ruby
|
2
|
-
sudo: false
|
3
2
|
bundler_args: "--retry=3 --jobs=3"
|
3
|
+
cache: bundler
|
4
|
+
sudo: false
|
4
5
|
rvm:
|
5
|
-
- 2.
|
6
|
-
- 2.
|
6
|
+
- 2.3.1
|
7
|
+
- 2.3.0
|
7
8
|
- 2.2
|
9
|
+
- 2.1
|
10
|
+
- 2.0
|
8
11
|
- ruby-head
|
9
12
|
matrix:
|
10
13
|
allow_failures:
|
14
|
+
- rvm: 2.0
|
11
15
|
- rvm: ruby-head
|
12
16
|
fast_finish: true
|
13
17
|
notifications:
|
data/CHANGELOG.md
CHANGED
@@ -2,9 +2,40 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
-
##
|
5
|
+
## 3.0.0 - 2016.06.08
|
6
6
|
|
7
|
-
|
7
|
+
### Features
|
8
|
+
|
9
|
+
- Add support to twemoji.js V2
|
10
|
+
- Add `Twemoji.svg` (not loaded by default), looks like:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
{
|
14
|
+
...
|
15
|
+
":heart_eyes:" => "https://twemoji.maxcdn.com/2/svg/1f60d.svg",
|
16
|
+
...
|
17
|
+
}
|
18
|
+
```
|
19
|
+
|
20
|
+
- Add `Twemoji.png` (not loaded by default), looks like:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
{
|
24
|
+
...
|
25
|
+
":heart_eyes:" => "https://twemoji.maxcdn.com/2/72x72/1f60d.png",
|
26
|
+
...
|
27
|
+
}
|
28
|
+
```
|
29
|
+
|
30
|
+
### Breaking Changes
|
31
|
+
|
32
|
+
- Require Ruby 2.0+
|
33
|
+
- `Twemoji::CODES` changes to `Twemoji.codes`
|
34
|
+
- `Twemoji::ICODES` changes to `Twemoji.invert_codes`
|
35
|
+
- `asset_root` config default value changed to `https://twemoji.maxcdn.com/2`
|
36
|
+
- `file_ext` config default value changed to `svg`, available values are `"svg"` and `"png"`
|
37
|
+
- PNG now only has one size `72x72`
|
38
|
+
- Remove `Twemoji.to_json` method
|
8
39
|
|
9
40
|
## 2.2.1 - 2016.06.07
|
10
41
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -14,6 +14,11 @@ This RubyGem `twemoji` is a minimum implementation of Twitter Emoji in Ruby so t
|
|
14
14
|
|
15
15
|
__Note:__ This gem might not implement all the features available in the JavaScript implementation.
|
16
16
|
|
17
|
+
## Twemoji Gem and twemoji.js versions
|
18
|
+
|
19
|
+
- Twemoji Gem 3.x supports twemoji.js V2 (1661 emojis)
|
20
|
+
- Twemoji Gem 2.x supports twemoji.js V1 (874 emojis)
|
21
|
+
|
17
22
|
## Installation
|
18
23
|
|
19
24
|
Add this line to your application's Gemfile:
|
@@ -30,14 +35,6 @@ Or install it yourself as:
|
|
30
35
|
|
31
36
|
$ gem install twemoji
|
32
37
|
|
33
|
-
### Ruby 1.9.3 Support
|
34
|
-
|
35
|
-
@bramswenson has put in effort to support Ruby 1.9.3, please use [his forked branch](https://github.com/bramswenson/twemoji/tree/ruby-1.9.3):
|
36
|
-
|
37
|
-
```ruby
|
38
|
-
gem "twemoji", github: "bramswenson/twemoji", branch: "ruby-1.9.3"
|
39
|
-
```
|
40
|
-
|
41
38
|
## Integration
|
42
39
|
|
43
40
|
- [Integration with `HTML::Pipeline`](https://github.com/jollygoodcode/twemoji/wiki/Integrate-with-HTML%3A%3APipeline)
|
@@ -57,13 +54,13 @@ end
|
|
57
54
|
In your ERb view:
|
58
55
|
|
59
56
|
```erb
|
60
|
-
<%= emojify "I like chocolate :heart_eyes:!"
|
57
|
+
<%= emojify "I like chocolate :heart_eyes:!" %>
|
61
58
|
```
|
62
59
|
|
63
60
|
will render
|
64
61
|
|
65
62
|
```
|
66
|
-
I like chocolate <img class="emoji" draggable="false" title=":heart_eyes:" alt="😍" src="https://twemoji.maxcdn.com/
|
63
|
+
I like chocolate <img class="emoji" draggable="false" title=":heart_eyes:" alt="😍" src="https://twemoji.maxcdn.com/2/72x72/1f60d.png">!
|
67
64
|
```
|
68
65
|
|
69
66
|
More options could be passed in, please see [Twemoji.parse options](https://github.com/jollygoodcode/twemoji#twemojiparse-options) for more details.
|
@@ -123,38 +120,29 @@ More options could be passed in, please see [Twemoji.parse options](https://gith
|
|
123
120
|
|
124
121
|
```ruby
|
125
122
|
> Twemoji.parse "I like chocolate :heart_eyes:!"
|
126
|
-
=>
|
123
|
+
=> 'I like chocolate <img draggable="false" title=":heart_eyes:" alt="😍" src="https://twemoji.maxcdn.com/2/svg/1f60d.svg" class="emoji">!'
|
127
124
|
```
|
128
125
|
|
129
126
|
##### `Twemoji.parse` options
|
130
127
|
|
131
128
|
##### `asset_root`
|
132
129
|
|
133
|
-
Default assets root url. Defaults to `https://twemoji.maxcdn.com/`:
|
130
|
+
Default assets root url. Defaults to `https://twemoji.maxcdn.com/2/`:
|
134
131
|
|
135
132
|
```ruby
|
136
|
-
> Twemoji.parse
|
137
|
-
=>
|
133
|
+
> Twemoji.parse "I like chocolate :heart_eyes:!", asset_root: "foocdn.com"
|
134
|
+
=> 'I like chocolate <img draggable="false" title=":heart_eyes:" alt="😍" src="foocdn.com/svg/1f60d.svg" class="emoji">!'
|
138
135
|
```
|
139
136
|
|
140
137
|
##### `file_ext`
|
141
138
|
|
142
|
-
Default assets file extensions. Defaults to `.
|
139
|
+
Default assets file extensions. Defaults to `svg`.
|
143
140
|
|
144
|
-
|
145
|
-
> Twemoji.parse 'I like chocolate :heart_eyes:!', file_ext: ".svg"
|
146
|
-
=> "I like chocolate <img class='emoji' draggable='false' title=':heart_eyes:' alt='😍' src='https://twemoji.maxcdn.com/svg/1f60d.svg'>!"
|
147
|
-
```
|
148
|
-
|
149
|
-
##### `image_size`
|
150
|
-
|
151
|
-
Default assets/folder size. Defaults to `"16x16"`.
|
152
|
-
|
153
|
-
Sizes available via Twitter CDN: `16`, `36`, `72`.
|
141
|
+
Can change to `"png"`:
|
154
142
|
|
155
143
|
```ruby
|
156
|
-
> Twemoji.parse 'I like chocolate :heart_eyes:!',
|
157
|
-
=>
|
144
|
+
> Twemoji.parse 'I like chocolate :heart_eyes:!', file_ext: "png"
|
145
|
+
=> 'I like chocolate <img draggable="false" title=":heart_eyes:" alt="😍" src="https://twemoji.maxcdn.com/2/72x72/1f60d.png" class="emoji">!'
|
158
146
|
```
|
159
147
|
|
160
148
|
##### `class_name`
|
@@ -162,8 +150,8 @@ Sizes available via Twitter CDN: `16`, `36`, `72`.
|
|
162
150
|
Default image CSS class name. Defaults to `"emoji"`.
|
163
151
|
|
164
152
|
```ruby
|
165
|
-
> Twemoji.parse
|
166
|
-
=>
|
153
|
+
> Twemoji.parse "I like chocolate :heart_eyes:!", class_name: "superemoji"
|
154
|
+
=> 'I like chocolate <img draggable="false" title=":heart_eyes:" alt="😍" src="https://twemoji.maxcdn.com/2/svg/1f60d.svg" class="superemoji">!'
|
167
155
|
```
|
168
156
|
|
169
157
|
##### `img_attrs`
|
@@ -171,8 +159,8 @@ Default image CSS class name. Defaults to `"emoji"`.
|
|
171
159
|
List of image attributes for the `img` tag. Optional.
|
172
160
|
|
173
161
|
```ruby
|
174
|
-
> Twemoji.parse
|
175
|
-
=>
|
162
|
+
> Twemoji.parse "I like chocolate :heart_eyes:!", class_name: "twemoji", img_attrs: { style: "height: 1.3em;" }
|
163
|
+
=> 'I like chocolate <img draggable="false" title=":heart_eyes:" alt="😍" src="https://twemoji.maxcdn.com/2/svg/1f60d.svg" class="twemoji" style="height: 1.3em;">!'
|
176
164
|
```
|
177
165
|
|
178
166
|
attribute value can apply proc-like object, remove `:` from title attribute:
|
@@ -180,58 +168,100 @@ attribute value can apply proc-like object, remove `:` from title attribute:
|
|
180
168
|
```ruby
|
181
169
|
> no_colons = ->(name) { name.gsub(":", "") }
|
182
170
|
|
183
|
-
> Twemoji.parse
|
184
|
-
=>
|
171
|
+
> Twemoji.parse "I like chocolate :heart_eyes:!", class_name: "twemoji", img_attrs: { title: no_colons }
|
172
|
+
=> 'I like chocolate <img draggable="false" title="heart_eyes" alt="😍" src="https://twemoji.maxcdn.com/2/svg/1f60d.svg" class="twemoji">!'
|
185
173
|
```
|
186
174
|
|
187
175
|
#### `Twemoji.emoji_pattern`
|
188
176
|
|
189
177
|
```ruby
|
190
178
|
> Twemoji.emoji_pattern
|
191
|
-
=> /(:
|
179
|
+
=> /(:mahjong:|:black_joker:| ... |:registered_sign:|:shibuya:)/
|
192
180
|
```
|
193
181
|
|
194
|
-
####
|
182
|
+
#### JSON for your front-end
|
195
183
|
|
196
|
-
|
184
|
+
We prepare two constants: [Twemoji::PNG](lib/twemoji/png.rb) and [Twemoji::SVG](lib/twemoji/svg.rb) (**not loaded by default**), you need to require them to use:
|
197
185
|
|
198
|
-
```
|
199
|
-
|
200
|
-
|
201
|
-
":heart_eyes:": "https://twemoji.maxcdn.com/svg/1f60d.svg"
|
202
|
-
...
|
203
|
-
}
|
186
|
+
```ruby
|
187
|
+
require "twemoji/png" # If you want to use Twemoji::PNG
|
188
|
+
require "twemoji/svg" # If you want to use Twemoji::SVG
|
204
189
|
```
|
205
190
|
|
206
|
-
|
191
|
+
Or require at `Gemfile`:
|
207
192
|
|
208
193
|
```ruby
|
209
|
-
|
194
|
+
# Require the one you need, require Twemoji::PNG
|
195
|
+
gem "twemoji", require: "twemoji/png"
|
196
|
+
|
197
|
+
# Or Twemoji::SVG
|
198
|
+
gem "twemoji", require: "twemoji/svg"
|
199
|
+
|
200
|
+
# Or both
|
201
|
+
gem "twemoji", require: ["twemoji/png", "twemoji/svg"]
|
202
|
+
```
|
210
203
|
|
211
|
-
|
204
|
+
Then you can do `to_json` to feed your front-end.
|
212
205
|
|
213
|
-
|
206
|
+
You can also make custom format by leverage `Twemoji.codes`:
|
214
207
|
|
215
|
-
|
208
|
+
```html+erb
|
209
|
+
# emojis.json.erb
|
210
|
+
<%= Twemoji.codes.collect do |code, _|
|
211
|
+
Hash(
|
212
|
+
value: code,
|
213
|
+
html: content_tag(:span, Twemoji.parse(code).html_safe + " #{code}" )
|
214
|
+
)
|
215
|
+
end.to_json.html_safe %>
|
216
216
|
```
|
217
217
|
|
218
218
|
## Configuration
|
219
219
|
|
220
|
-
`Twemoji.parse` options can be given in configure block:
|
220
|
+
`Twemoji.parse` options can be given in configure block, default values are:
|
221
221
|
|
222
222
|
```ruby
|
223
223
|
Twemoji.configure do |config|
|
224
|
-
config.asset_root = "https://twemoji.
|
225
|
-
config.file_ext = "
|
226
|
-
config.
|
227
|
-
config.
|
228
|
-
config.img_attrs = { style: "height: 1.3em;" }
|
224
|
+
config.asset_root = "https://twemoji.maxcdn.com/2"
|
225
|
+
config.file_ext = "svg"
|
226
|
+
config.class_name = "emoji"
|
227
|
+
config.img_attrs = {}
|
229
228
|
end
|
230
229
|
```
|
231
230
|
|
231
|
+
Specify additional img attributes like so:
|
232
|
+
|
233
|
+
```ruby
|
234
|
+
config.img_attrs = { style: "height: 1.3em;" }
|
235
|
+
```
|
236
|
+
|
237
|
+
## Tips (from twitter/twemoji)
|
238
|
+
|
239
|
+
### Inline Styles
|
240
|
+
|
241
|
+
If you'd like to size the emoji according to the surrounding text, you can add the following CSS to your stylesheet:
|
242
|
+
|
243
|
+
```css
|
244
|
+
img.emoji {
|
245
|
+
height: 1em;
|
246
|
+
width: 1em;
|
247
|
+
margin: 0 .05em 0 .1em;
|
248
|
+
vertical-align: -0.1em;
|
249
|
+
}
|
250
|
+
```
|
251
|
+
|
252
|
+
This will make sure emoji derive their width and height from the font-size of the text they're shown with. It also adds just a little bit of space before and after each emoji, and pulls them upwards a little bit for better optical alignment.
|
253
|
+
|
254
|
+
### UTF-8 Character Set
|
255
|
+
|
256
|
+
To properly support emoji, the document character must be set to UTF-8. This can done by including the following meta tag in the document <head>
|
257
|
+
|
258
|
+
```html
|
259
|
+
<meta charset="utf-8">
|
260
|
+
```
|
261
|
+
|
232
262
|
## Attribution Requirements
|
233
263
|
|
234
|
-
Please follow the [Attribution Requirements](https://github.com/twitter/twemoji#attribution-requirements) as stated on the official Twemoji (JS) repo.
|
264
|
+
**IMPORTANT:** Please follow the [Attribution Requirements](https://github.com/twitter/twemoji#attribution-requirements) as stated on the official Twemoji (JS) repo.
|
235
265
|
|
236
266
|
## Contributing
|
237
267
|
|
@@ -241,6 +271,8 @@ Please see the [CONTRIBUTING.md](/CONTRIBUTING.md) file.
|
|
241
271
|
|
242
272
|
A huge THANK YOU to all our [contributors](https://github.com/jollygoodcode/twemoji/graphs/contributors)! :heart:
|
243
273
|
|
274
|
+
The emoji keywords are from [jollygoodcode/emoji-keywords](https://github.com/jollygoodcode/emoji-keywords).
|
275
|
+
|
244
276
|
## License
|
245
277
|
|
246
278
|
Please see the [LICENSE.md](/LICENSE.md) file.
|
data/Rakefile
CHANGED
data/lib/twemoji.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "nokogiri"
|
2
4
|
require "json"
|
3
5
|
require "twemoji/version"
|
4
6
|
require "twemoji/map"
|
5
|
-
require "twemoji/json"
|
6
7
|
require "twemoji/configuration"
|
7
8
|
|
8
9
|
# Twemoji is a Ruby implementation, parses your text, replace emoji text
|
@@ -12,7 +13,7 @@ module Twemoji
|
|
12
13
|
#
|
13
14
|
# @example Usage
|
14
15
|
# Twemoji.find_by(text: ":heart_eyes:") # => "1f60d"
|
15
|
-
# Twemoji.find_by(code: "
|
16
|
+
# Twemoji.find_by(code: "1f60d") # => ":heart_eyes:"
|
16
17
|
# Twemoji.find_by(unicode: "😍") # => ":heart_eyes:"
|
17
18
|
# Twemoji.find_by(unicode: "\u{1f60d}") # => ":heart_eyes:"
|
18
19
|
#
|
@@ -45,7 +46,7 @@ module Twemoji
|
|
45
46
|
# @param text [String] Text to find emoji code.
|
46
47
|
# @return [String] Emoji Code.
|
47
48
|
def self.find_by_text(text)
|
48
|
-
|
49
|
+
codes[must_str(text)]
|
49
50
|
end
|
50
51
|
|
51
52
|
# Find emoji text by emoji code.
|
@@ -57,7 +58,7 @@ module Twemoji
|
|
57
58
|
# @param code [String] Emoji code to find text.
|
58
59
|
# @return [String] Emoji Text.
|
59
60
|
def self.find_by_code(code)
|
60
|
-
|
61
|
+
invert_codes[must_str(code)]
|
61
62
|
end
|
62
63
|
|
63
64
|
# Find emoji text by raw emoji unicode.
|
@@ -69,7 +70,7 @@ module Twemoji
|
|
69
70
|
# @param raw [String] Emoji raw unicode to find text.
|
70
71
|
# @return [String] Emoji Text.
|
71
72
|
def self.find_by_unicode(raw)
|
72
|
-
|
73
|
+
invert_codes[raw.split("").map { |r| "%4.4x" % r.ord }.join("-")]
|
73
74
|
end
|
74
75
|
|
75
76
|
# Render raw emoji unicode from emoji text or emoji code.
|
@@ -92,26 +93,24 @@ module Twemoji
|
|
92
93
|
#
|
93
94
|
# @example Usage
|
94
95
|
# Twemoji.parse("I like chocolate :heart_eyes:!")
|
95
|
-
# =>
|
96
|
+
# => 'I like chocolate <img draggable="false" title=":heart_eyes:" alt="😍" src="https://twemoji.maxcdn.com/2/svg/1f60d.svg" class="emoji">!'
|
96
97
|
#
|
97
98
|
# @param text [String] Source text to parse.
|
98
99
|
#
|
99
100
|
# @option options [String] (optional) asset_root Asset root url to serve emoji.
|
100
101
|
# @option options [String] (optional) file_ext File extension.
|
101
|
-
# @option options [String] (optional)
|
102
|
-
# @option options [String] (optional) img_attrs
|
102
|
+
# @option options [String] (optional) class_name Emoji image's tag class attribute.
|
103
|
+
# @option options [String] (optional) img_attrs Emoji image's img tag attributes.
|
103
104
|
#
|
104
105
|
# @return [String] Original text with all occurrences of emoji text
|
105
106
|
# replaced by emoji image according to given options.
|
106
107
|
def self.parse(text, asset_root: Twemoji.configuration.asset_root,
|
107
108
|
file_ext: Twemoji.configuration.file_ext,
|
108
|
-
image_size: Twemoji.configuration.image_size,
|
109
109
|
class_name: Twemoji.configuration.class_name,
|
110
110
|
img_attrs: Twemoji.configuration.img_attrs)
|
111
111
|
|
112
112
|
options[:asset_root] = asset_root
|
113
113
|
options[:file_ext] = file_ext
|
114
|
-
options[:image_size] = image_size
|
115
114
|
options[:img_attrs] = { class: class_name }.merge! img_attrs
|
116
115
|
|
117
116
|
if text.is_a?(Nokogiri::HTML::DocumentFragment)
|
@@ -125,36 +124,7 @@ module Twemoji
|
|
125
124
|
#
|
126
125
|
# @return [RegExp] A Regular expression consists of all emojis text.
|
127
126
|
def self.emoji_pattern
|
128
|
-
@emoji_pattern ||= /(#{
|
129
|
-
end
|
130
|
-
|
131
|
-
# Return Twemoji json string, unicode => twemoji CDN url
|
132
|
-
#
|
133
|
-
# @example Output
|
134
|
-
# {
|
135
|
-
# ":heart_eyes:": "https://twemoji.maxcdn.com/svg/1f60d.svg"
|
136
|
-
# }
|
137
|
-
#
|
138
|
-
# option [String] (optional) :file_ext - image extension: svg or png
|
139
|
-
# option [String] (optional) :image_size - if file_ext is png, can choose size of png from
|
140
|
-
# "16x16", "32x32", "72x72"
|
141
|
-
# @return [String] Twemoji json string
|
142
|
-
def self.to_json(file_ext: "png", image_size: "16x16")
|
143
|
-
output = if file_ext == "svg"
|
144
|
-
Twemoji::SVG
|
145
|
-
elsif file_ext == "png"
|
146
|
-
case image_size
|
147
|
-
when "16x16" then Twemoji::PNG_16x16
|
148
|
-
when "36x36" then Twemoji::PNG_36x36
|
149
|
-
when "72x72" then Twemoji::PNG_72x72
|
150
|
-
else
|
151
|
-
fail %(Unsupported png image size: `#{image_size}', supported: "16x16", "36x36", "72x72".)
|
152
|
-
end
|
153
|
-
else
|
154
|
-
fail %(Unsupported file extension: `#{file_ext}', supported: "png" and "svg".)
|
155
|
-
end
|
156
|
-
|
157
|
-
output.to_json
|
127
|
+
@emoji_pattern ||= /(#{codes.keys.map { |name| Regexp.quote(name) }.join("|") })/
|
158
128
|
end
|
159
129
|
|
160
130
|
private
|
@@ -194,7 +164,7 @@ module Twemoji
|
|
194
164
|
# @return [Nokogiri::HTML::DocumentFragment] Parsed document.
|
195
165
|
# @private
|
196
166
|
def self.parse_document(doc)
|
197
|
-
doc.xpath(
|
167
|
+
doc.xpath(".//text() | text()").each do |node|
|
198
168
|
content = node.to_html
|
199
169
|
next if !content.include?(":")
|
200
170
|
next if has_ancestor?(node, %w(pre code tt))
|
@@ -240,6 +210,9 @@ module Twemoji
|
|
240
210
|
%(<img #{hash_to_html_attrs(img_attrs_hash)}>)
|
241
211
|
end
|
242
212
|
|
213
|
+
PNG_IMAGE_SIZE = "72x72"
|
214
|
+
private_constant :PNG_IMAGE_SIZE
|
215
|
+
|
243
216
|
# Returns emoji url by given name and options from `Twemoji.parse`.
|
244
217
|
#
|
245
218
|
# @param name [String] Emoji name to generate image url.
|
@@ -248,9 +221,9 @@ module Twemoji
|
|
248
221
|
def self.emoji_url(name)
|
249
222
|
code = find_by_text(name)
|
250
223
|
|
251
|
-
if options[:file_ext] == "
|
252
|
-
File.join(options[:asset_root],
|
253
|
-
elsif options[:file_ext] == "
|
224
|
+
if options[:file_ext] == "png"
|
225
|
+
File.join(options[:asset_root], PNG_IMAGE_SIZE, "#{code}.png")
|
226
|
+
elsif options[:file_ext] == "svg"
|
254
227
|
File.join(options[:asset_root], "svg", "#{code}.svg")
|
255
228
|
else
|
256
229
|
fail "Unsupported file extension: #{options[:file_ext]}"
|