twemoji 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -0
- data/LICENSE +17 -18
- data/README.md +77 -21
- data/Rakefile +1 -1
- data/lib/twemoji.rb +51 -16
- data/lib/twemoji/version.rb +1 -1
- data/test/twemoji_test.rb +29 -17
- data/twemoji.gemspec +2 -2
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 040b1375538c9592bbd3de7c69c124d528bf3b91
|
4
|
+
data.tar.gz: 10bd6f5853d5ce12ea28574527719b440b979e15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f57702af7530e3c0216a664c99e727272891533eb7110c7a9b556fdb20a57ecebc3caf798e57fbabc7c71da39ac00d84557c0655505e5188f55a562748a97bc
|
7
|
+
data.tar.gz: 815d8f456aa191f9fe1721be68d460843def8754b4ad814f988f408b53c799835aa1b9343c619ab055cf4d60fd17090e7db43d53d68d84b9d51a74fba8a959e7
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,26 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## 1.1.0 - 2015.02.27
|
6
|
+
|
7
|
+
- Some more documentations @JuanitoFatas
|
8
|
+
|
9
|
+
- Behave more like twemoji.js. @bramswenson [#5](https://github.com/jollygoodcode/twemoji/pull/5)
|
10
|
+
|
11
|
+
**New Methods**:
|
12
|
+
|
13
|
+
* [`Twemoji.find_by`](https://github.com/jollygoodcode/twemoji/blob/fe2810ddbe1f2cfdb496bcdd9e1576ba1e05eb06/lib/twemoji.rb#L9-L35) now accepts `unicode` keyword argument (either a raw unicode or escaped-unicode string) to find emoji text
|
14
|
+
|
15
|
+
* Add [`Twemoji.find_by_unicode`](https://github.com/jollygoodcode/twemoji/blob/fe2810ddbe1f2cfdb496bcdd9e1576ba1e05eb06/lib/twemoji.rb#L61-L71) to find emoji text by raw emoji unicode or escaped-unicode string
|
16
|
+
|
17
|
+
* Add [`Twemoji.render_unicode`](https://github.com/jollygoodcode/twemoji/blob/fe2810ddbe1f2cfdb496bcdd9e1576ba1e05eb06/lib/twemoji.rb#L73-L86) to render raw emoji unicode from emoji text or emoji code
|
18
|
+
|
19
|
+
**Changes**:
|
20
|
+
|
21
|
+
* `img` tag's `alt` changes from emoji text like `:heart_eyes:` to actual unicode `"😍"`
|
22
|
+
|
23
|
+
- Restrict Nokogiri to (1.4..1.6.5). @JuanitoFatas [#3](https://github.com/jollygoodcode/twemoji/pull/3)
|
24
|
+
|
5
25
|
## 1.0.1 - 2015.01.13
|
6
26
|
|
7
27
|
- Add ability to specify img tag attribute. @JuanitoFatas [#1](https://github.com/jollygoodcode/twemoji/pull/1).
|
data/LICENSE
CHANGED
@@ -1,22 +1,21 @@
|
|
1
|
-
|
1
|
+
The MIT License (MIT)
|
2
2
|
|
3
|
-
|
3
|
+
Copyright (c) 2015 Jolly Good Code
|
4
4
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
the following conditions:
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
12
11
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
15
14
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
OF
|
22
|
-
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](http://img.shields.io/gem/v/twemoji.svg)][gem]
|
4
4
|
[![Build Status](https://travis-ci.org/jollygoodcode/twemoji.svg)][travis]
|
5
|
+
[![Inline docs](http://inch-ci.org/github/jollygoodcode/twemoji.svg?branch=master)][inch-doc]
|
5
6
|
|
6
7
|
[gem]: https://rubygems.org/gems/twemoji
|
7
8
|
[travis]: https://travis-ci.org/jollygoodcode/twemoji
|
9
|
+
[inch-doc]: http://inch-ci.org/github/jollygoodcode/twemoji
|
8
10
|
|
9
11
|
Twitter Emoji has a official JavaScript implementation of [twemoji](https://github.com/twitter/twemoji). This RubyGem Twemoji is a minimum implementation in Ruby, does not implement all its features.
|
10
12
|
|
@@ -13,7 +15,7 @@ Twitter Emoji has a official JavaScript implementation of [twemoji](https://gith
|
|
13
15
|
Add this line to your application's Gemfile:
|
14
16
|
|
15
17
|
```ruby
|
16
|
-
gem
|
18
|
+
gem "twemoji"
|
17
19
|
```
|
18
20
|
|
19
21
|
And then execute:
|
@@ -24,82 +26,126 @@ Or install it yourself as:
|
|
24
26
|
|
25
27
|
$ gem install twemoji
|
26
28
|
|
29
|
+
### Ruby 1.9.3 Support
|
30
|
+
|
31
|
+
@bramswenson has put an effeort to support Ruby 1.9.3, please use [his forked branch](https://github.com/bramswenson/twemoji/tree/ruby-1.9.3):
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
gem "twemoji", github: "bramswenson/twemoji", branch: "ruby-1.9.3"
|
35
|
+
```
|
36
|
+
|
37
|
+
## Integration
|
38
|
+
|
39
|
+
- [Integration with html-pipeline](https://github.com/jollygoodcode/twemoji/wiki/Integrate-with-html-pipeline)
|
40
|
+
|
27
41
|
## Usage
|
28
42
|
|
29
43
|
### API
|
30
44
|
|
31
|
-
####
|
45
|
+
#### `Twemoji.find_by` text or code or unicode
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
> Twemoji.find_by(text: ":heart_eyes:")
|
49
|
+
=> "1f60d"
|
50
|
+
|
51
|
+
> Twemoji.find_by(code: "1f60d")
|
52
|
+
=> ":heart_eyes:"
|
53
|
+
|
54
|
+
> Twemoji.find_by(unicode: "😍")
|
55
|
+
=> ":heart_eyes:"
|
56
|
+
|
57
|
+
> Twemoji.find_by(unicode: "\u{1f60d}")
|
58
|
+
=> ":heart_eyes:"
|
59
|
+
```
|
60
|
+
|
61
|
+
#### `Twemoji.find_by_text`
|
32
62
|
|
33
63
|
```ruby
|
34
64
|
> Twemoji.find_by_text(":heart_eyes:")
|
35
65
|
=> "1f60d"
|
36
66
|
```
|
37
67
|
|
38
|
-
####
|
68
|
+
#### `Twemoji.find_by_code`
|
39
69
|
|
40
70
|
```ruby
|
41
71
|
> Twemoji.find_by_code("1f60d")
|
42
72
|
=> ":heart_eyes:"
|
43
73
|
```
|
44
74
|
|
45
|
-
####
|
75
|
+
#### `Twemoji.find_by_unicode`
|
46
76
|
|
47
77
|
```ruby
|
48
|
-
> Twemoji.find_by(
|
49
|
-
=>
|
78
|
+
> Twemoji.find_by(unicode: "😍")
|
79
|
+
=> ":heart_eyes:"
|
80
|
+
```
|
50
81
|
|
51
|
-
|
52
|
-
|
82
|
+
#### `Twemoji.render_unicode`
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
> Twemoji.render_unicode ":heart_eyes:"
|
86
|
+
=> "😍"
|
87
|
+
|
88
|
+
> Twemoji.render_unicode "1f60d"
|
89
|
+
=> "😍"
|
53
90
|
```
|
54
91
|
|
55
|
-
####
|
92
|
+
#### `Twemoji.parse`
|
56
93
|
|
57
94
|
```ruby
|
58
95
|
> Twemoji.parse "I like chocolate :heart_eyes:!"
|
59
|
-
=>
|
96
|
+
=> "I like chocolate <img class='emoji' draggable='false' title=':heart_eyes:' alt='😍' src='https://twemoji.maxcdn.com/16x16/1f60d.png'>!"
|
60
97
|
```
|
61
98
|
|
62
|
-
#####
|
99
|
+
##### `Twemoji.parse` options
|
100
|
+
|
101
|
+
##### `asset_root`
|
63
102
|
|
64
103
|
Default assets root url, by default will be `https://twemoji.maxcdn.com/`:
|
65
104
|
|
66
105
|
```ruby
|
67
106
|
> Twemoji.parse 'I like chocolate :heart_eyes:!', asset_root: "foocdn.com"
|
68
|
-
=>
|
107
|
+
=> "I like chocolate <img class='emoji' draggable='false' title=':heart_eyes:' alt='😍' src='foocdn.com/16x16/1f60d.png'>!"
|
69
108
|
```
|
70
109
|
|
71
|
-
##### file_ext
|
110
|
+
##### `file_ext`
|
72
111
|
|
73
112
|
Default assets file extensions, by default `.png`.
|
74
113
|
|
75
114
|
```ruby
|
76
115
|
> Twemoji.parse 'I like chocolate :heart_eyes:!', file_ext: ".svg"
|
77
|
-
=>
|
116
|
+
=> "I like chocolate <img class='emoji' draggable='false' title=':heart_eyes:' alt='😍' src='https://twemoji.maxcdn.com/svg/1f60d.svg'>!"
|
78
117
|
```
|
79
118
|
|
80
|
-
##### image_size
|
119
|
+
##### `image_size`
|
81
120
|
|
82
121
|
Default assets/folder size, by default `"16x16"`. Available via Twitter CDN: `16`, `36`, `72`.
|
83
122
|
|
84
123
|
```ruby
|
85
124
|
> Twemoji.parse 'I like chocolate :heart_eyes:!', image_size: "72x72"
|
86
|
-
=>
|
125
|
+
=> "I like chocolate <img class='emoji' draggable='false' title=':heart_eyes:' alt='😍' src='https://twemoji.maxcdn.com/72x72/1f60d.png'>!"
|
87
126
|
```
|
88
127
|
|
89
|
-
##### class_name
|
128
|
+
##### `class_name`
|
90
129
|
|
91
130
|
Default img css class name, by default `"emoji"`.
|
92
131
|
|
93
132
|
```ruby
|
94
133
|
> Twemoji.parse 'I like chocolate :heart_eyes:!', class_name: "superemoji"
|
95
|
-
=>
|
134
|
+
=> "I like chocolate <img class='superemoji' draggable='false' title=':heart_eyes:' alt='😍' src='https://twemoji.maxcdn.com/16x16/1f60d.png'>!"
|
96
135
|
```
|
97
136
|
|
98
|
-
##### img_attr
|
137
|
+
##### `img_attr`
|
99
138
|
|
100
139
|
```ruby
|
101
|
-
Twemoji.parse("I like chocolate :heart_eyes:!", class_name: 'twemoji', img_attr: "style='height: 1.3em;'")
|
102
|
-
=> "I like chocolate <img class='twemoji' draggable='false' title=':heart_eyes:' alt='
|
140
|
+
> Twemoji.parse("I like chocolate :heart_eyes:!", class_name: 'twemoji', img_attr: "style='height: 1.3em;'")
|
141
|
+
=> "I like chocolate <img class='twemoji' draggable='false' title=':heart_eyes:' alt='😍' style='height: 1.3em;' src='https://twemoji.maxcdn.com/16x16/1f60d.png'>!"
|
142
|
+
```
|
143
|
+
|
144
|
+
#### `Twemoji.emoji_pattern`
|
145
|
+
|
146
|
+
```ruby
|
147
|
+
> Twemoji.emoji_pattern
|
148
|
+
=> /(:smile:|:laughing:| ... |:womens:|:x:|:zero:)/
|
103
149
|
```
|
104
150
|
|
105
151
|
## Contributing
|
@@ -109,3 +155,13 @@ Twemoji.parse("I like chocolate :heart_eyes:!", class_name: 'twemoji', img_attr:
|
|
109
155
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
110
156
|
4. Push to the branch (`git push origin my-new-feature`)
|
111
157
|
5. Create a new Pull Request
|
158
|
+
|
159
|
+
## Credits
|
160
|
+
|
161
|
+
A huge THANK YOU to all our [contributors] (https://github.com/jollygoodcode/twemoji/graphs/contributors)! :heart:
|
162
|
+
|
163
|
+
This project is maintained by [Jolly Good Code](http://www.jollygoodcode.com).
|
164
|
+
|
165
|
+
## License
|
166
|
+
|
167
|
+
MIT License. See [LICENSE](LICENSE) for details.
|
data/Rakefile
CHANGED
data/lib/twemoji.rb
CHANGED
@@ -6,29 +6,35 @@ require "twemoji/map"
|
|
6
6
|
# Twemoji is a Ruby implementation, parses your text, replace emoji text
|
7
7
|
# with corresponding emoji image. Default emoji images are from Twiiter CDN.
|
8
8
|
module Twemoji
|
9
|
-
# Find code by text and find text by
|
9
|
+
# Find code by text, find text by code, and find text by unicode.
|
10
10
|
#
|
11
11
|
# @example Usage
|
12
|
-
# Twemoji.find_by(text: :heart_eyes:) # => "1f60d"
|
13
|
-
# Twemoji.find_by(code: :1f60d:) # => ":heart_eyes:"
|
12
|
+
# Twemoji.find_by(text: ":heart_eyes:") # => "1f60d"
|
13
|
+
# Twemoji.find_by(code: ":1f60d:") # => ":heart_eyes:"
|
14
|
+
# Twemoji.find_by(unicode: "😍") # => ":heart_eyes:"
|
15
|
+
# Twemoji.find_by(unicode: "\u{1f60d}") # => ":heart_eyes:"
|
14
16
|
#
|
15
17
|
# @option options [String] (optional) :text
|
16
18
|
# @option options [String] (optional) :code
|
19
|
+
# @option options [String] (optional) :unicode
|
17
20
|
#
|
18
|
-
# @return [String]
|
19
|
-
def self.find_by(
|
20
|
-
if text
|
21
|
-
|
21
|
+
# @return [String] Emoji text or code.
|
22
|
+
def self.find_by(text: nil, code: nil, unicode: nil)
|
23
|
+
if [ text, code, unicode ].compact!.size > 1
|
24
|
+
fail ArgumentError, "Can only specify text, code or unicode one at a time"
|
22
25
|
end
|
23
26
|
|
24
|
-
|
27
|
+
case
|
28
|
+
when text
|
25
29
|
find_by_text text
|
30
|
+
when unicode
|
31
|
+
find_by_unicode unicode
|
26
32
|
else
|
27
33
|
find_by_code code
|
28
34
|
end
|
29
35
|
end
|
30
36
|
|
31
|
-
# Find emoji code by emoji text
|
37
|
+
# Find emoji code by emoji text.
|
32
38
|
#
|
33
39
|
# @example Usage
|
34
40
|
# Twemoji.find_by_text ":heart_eyes:"
|
@@ -52,11 +58,39 @@ module Twemoji
|
|
52
58
|
ICODES[must_str(code)]
|
53
59
|
end
|
54
60
|
|
55
|
-
#
|
61
|
+
# Find emoji text by raw emoji unicode.
|
62
|
+
#
|
63
|
+
# @example Usage
|
64
|
+
# Twemoji.find_by_unicode "😍"
|
65
|
+
# => ":heart_eyes:"
|
66
|
+
#
|
67
|
+
# @param unicode [String] Emoji raw unicode to find text.
|
68
|
+
# @return [String] Emoji Text.
|
69
|
+
def self.find_by_unicode(raw)
|
70
|
+
ICODES[must_str("%4.4x" % raw.ord)]
|
71
|
+
end
|
72
|
+
|
73
|
+
# Render raw emoji unicode from emoji text or emoji code.
|
74
|
+
#
|
75
|
+
# @example Usage
|
76
|
+
# Twemoji.render_unicode ":heart_eyes:"
|
77
|
+
# => "😍"
|
78
|
+
# Twemoji.render_unicode "1f60d"
|
79
|
+
# => "😍"
|
80
|
+
#
|
81
|
+
# @param text_or_code [String] Emoji text or code to render as unicode.
|
82
|
+
# @return [String] Emoji UTF-8 Text.
|
83
|
+
def self.render_unicode(text_or_code)
|
84
|
+
text_or_code = find_by_text(text_or_code) if text_or_code[0] == ":"
|
85
|
+
[text_or_code.hex].pack("U")
|
86
|
+
end
|
87
|
+
|
88
|
+
# Parse string, replace emoji text with image.
|
89
|
+
# Parse DOM, replace emoji with image.
|
56
90
|
#
|
57
91
|
# @example Usage
|
58
92
|
# Twemoji.parse("I like chocolate :heart_eyes:!")
|
59
|
-
# =>
|
93
|
+
# => "I like chocolate <img class='emoji' draggable='false' title=':heart_eyes:' alt='😍' src='https://twemoji.maxcdn.com/16x16/1f60d.png'>!"
|
60
94
|
#
|
61
95
|
# @param text [String] Source text to parse.
|
62
96
|
#
|
@@ -80,7 +114,7 @@ module Twemoji
|
|
80
114
|
options[:class_name] = class_name
|
81
115
|
options[:img_attr] = img_attr
|
82
116
|
|
83
|
-
if text.
|
117
|
+
if text.is_a?(Nokogiri::HTML::DocumentFragment)
|
84
118
|
parse_document(text)
|
85
119
|
else
|
86
120
|
parse_html(text)
|
@@ -102,7 +136,7 @@ module Twemoji
|
|
102
136
|
# @return [String] A String.
|
103
137
|
# @private
|
104
138
|
def self.must_str(text)
|
105
|
-
text
|
139
|
+
text.respond_to?(:to_str) ? text.to_str : text.to_s
|
106
140
|
end
|
107
141
|
|
108
142
|
# Options hash for Twemoji.
|
@@ -172,10 +206,11 @@ module Twemoji
|
|
172
206
|
# @return [String] Emoji image tag generated by name and options.
|
173
207
|
# @private
|
174
208
|
def self.img_tag(name)
|
209
|
+
unicode = render_unicode(name)
|
175
210
|
if options[:img_attr]
|
176
|
-
"<img class='#{options[:class_name]}' draggable='false' title='#{name}' alt='#{
|
211
|
+
"<img class='#{options[:class_name]}' draggable='false' title='#{name}' alt='#{unicode}' #{options[:img_attr]} src='#{emoji_url(name)}'>"
|
177
212
|
else
|
178
|
-
"<img class='#{options[:class_name]}' draggable='false' title='#{name}' alt='#{
|
213
|
+
"<img class='#{options[:class_name]}' draggable='false' title='#{name}' alt='#{unicode}' src='#{emoji_url(name)}'>"
|
179
214
|
end
|
180
215
|
end
|
181
216
|
|
@@ -192,7 +227,7 @@ module Twemoji
|
|
192
227
|
elsif options[:file_ext] == ".svg"
|
193
228
|
File.join(options[:asset_root], "svg", "#{code}.svg")
|
194
229
|
else
|
195
|
-
|
230
|
+
fail "Unspported file extension: #{options[:file_ext]}"
|
196
231
|
end
|
197
232
|
end
|
198
233
|
end
|
data/lib/twemoji/version.rb
CHANGED
data/test/twemoji_test.rb
CHANGED
@@ -5,12 +5,12 @@ class TwemojiTest < Minitest::Test
|
|
5
5
|
@option = {}
|
6
6
|
end
|
7
7
|
|
8
|
-
def
|
9
|
-
|
10
|
-
|
8
|
+
def test_finder_methods_cannot_find_by_more_than_one
|
9
|
+
exception = assert_raises ArgumentError do
|
10
|
+
Twemoji.find_by(text: ":heart_eyes:", code: "1f60d")
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
assert_equal ":heart_eyes:", Twemoji.find_by_code("1f60d")
|
13
|
+
assert_equal "Can only specify text, code or unicode one at a time", exception.message
|
14
14
|
end
|
15
15
|
|
16
16
|
def test_finder_methods_find_by_text
|
@@ -21,35 +21,47 @@ class TwemojiTest < Minitest::Test
|
|
21
21
|
assert_equal ":heart_eyes:", Twemoji.find_by(code: "1f60d")
|
22
22
|
end
|
23
23
|
|
24
|
-
def
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
def test_finder_methods_find_by_unicode
|
25
|
+
assert_equal ":heart_eyes:", Twemoji.find_by(unicode: "😍")
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_find_by_text
|
29
|
+
assert_equal "1f60d", Twemoji.find_by_text(":heart_eyes:")
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_find_by_code
|
33
|
+
assert_equal ":heart_eyes:", Twemoji.find_by_code("1f60d")
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_find_by_unicode
|
37
|
+
assert_equal ":heart_eyes:", Twemoji.find_by_unicode("😍")
|
38
|
+
end
|
28
39
|
|
29
|
-
|
40
|
+
def test_find_by_escaped_unicode
|
41
|
+
assert_equal ":heart_eyes:", Twemoji.find_by_unicode("\u{1f60d}")
|
30
42
|
end
|
31
43
|
|
32
44
|
def test_parse_html_string
|
33
|
-
expected = "I like chocolate <img class='emoji' draggable='false' title=':heart_eyes:' alt='
|
45
|
+
expected = "I like chocolate <img class='emoji' draggable='false' title=':heart_eyes:' alt='😍' src='https://twemoji.maxcdn.com/16x16/1f60d.png'>!"
|
34
46
|
|
35
47
|
assert_equal expected, Twemoji.parse("I like chocolate :heart_eyes:!")
|
36
48
|
end
|
37
49
|
|
38
50
|
def test_parse_document
|
39
51
|
doc = Nokogiri::HTML::DocumentFragment.parse("<p>I like chocolate :heart_eyes:!</p>")
|
40
|
-
expected = '<p>I like chocolate <img class="emoji" draggable="false" title=":heart_eyes:" alt="
|
52
|
+
expected = '<p>I like chocolate <img class="emoji" draggable="false" title=":heart_eyes:" alt="😍" src="https://twemoji.maxcdn.com/16x16/1f60d.png">!</p>'
|
41
53
|
|
42
54
|
assert_equal expected, Twemoji.parse(doc).to_html
|
43
55
|
end
|
44
56
|
|
45
57
|
def test_parse_option_asset_root
|
46
|
-
expected = "I like chocolate <img class='emoji' draggable='false' title=':heart_eyes:' alt='
|
58
|
+
expected = "I like chocolate <img class='emoji' draggable='false' title=':heart_eyes:' alt='😍' src='https://emoji.bestcdn.com/16x16/1f60d.png'>!"
|
47
59
|
|
48
60
|
assert_equal expected, Twemoji.parse("I like chocolate :heart_eyes:!", asset_root: 'https://emoji.bestcdn.com')
|
49
61
|
end
|
50
62
|
|
51
63
|
def test_parse_option_file_ext_svg
|
52
|
-
expected = "I like chocolate <img class='emoji' draggable='false' title=':heart_eyes:' alt='
|
64
|
+
expected = "I like chocolate <img class='emoji' draggable='false' title=':heart_eyes:' alt='😍' src='https://twemoji.maxcdn.com/svg/1f60d.svg'>!"
|
53
65
|
|
54
66
|
assert_equal expected, Twemoji.parse("I like chocolate :heart_eyes:!", file_ext: '.svg')
|
55
67
|
end
|
@@ -63,19 +75,19 @@ class TwemojiTest < Minitest::Test
|
|
63
75
|
end
|
64
76
|
|
65
77
|
def test_parse_option_image_size
|
66
|
-
expected = "I like chocolate <img class='emoji' draggable='false' title=':heart_eyes:' alt='
|
78
|
+
expected = "I like chocolate <img class='emoji' draggable='false' title=':heart_eyes:' alt='😍' src='https://twemoji.maxcdn.com/72x72/1f60d.png'>!"
|
67
79
|
|
68
80
|
assert_equal expected, Twemoji.parse("I like chocolate :heart_eyes:!", file_ext: ".png", image_size: "72x72")
|
69
81
|
end
|
70
82
|
|
71
83
|
def test_parse_option_class_name
|
72
|
-
expected = "I like chocolate <img class='twemoji' draggable='false' title=':heart_eyes:' alt='
|
84
|
+
expected = "I like chocolate <img class='twemoji' draggable='false' title=':heart_eyes:' alt='😍' src='https://twemoji.maxcdn.com/16x16/1f60d.png'>!"
|
73
85
|
|
74
86
|
assert_equal expected, Twemoji.parse("I like chocolate :heart_eyes:!", class_name: 'twemoji')
|
75
87
|
end
|
76
88
|
|
77
89
|
def test_parse_option_img_attr
|
78
|
-
expected = "I like chocolate <img class='twemoji' draggable='false' title=':heart_eyes:' alt='
|
90
|
+
expected = "I like chocolate <img class='twemoji' draggable='false' title=':heart_eyes:' alt='😍' style='height: 1.3em;' src='https://twemoji.maxcdn.com/16x16/1f60d.png'>!"
|
79
91
|
|
80
92
|
assert_equal expected, Twemoji.parse("I like chocolate :heart_eyes:!", class_name: 'twemoji', img_attr: "style='height: 1.3em;'")
|
81
93
|
end
|
data/twemoji.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Twemoji::VERSION
|
9
9
|
spec.authors = %w(Juanito Fatas)
|
10
10
|
spec.email = %w(katehuang0320@gmail.com)
|
11
|
-
spec.summary = %
|
11
|
+
spec.summary = %(A RubyGem to convert :heart: to Twitter cdn url)
|
12
12
|
spec.description = spec.summary
|
13
13
|
spec.homepage = "https://github.com/jollygoodcode/twemoji"
|
14
14
|
spec.license = "MIT"
|
@@ -16,5 +16,5 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.require_paths = %w(lib)
|
18
18
|
|
19
|
-
spec.add_dependency "nokogiri", "
|
19
|
+
spec.add_dependency "nokogiri", [">= 1.4", "<= 1.6.5"]
|
20
20
|
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: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juanito
|
@@ -9,22 +9,28 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-02-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '1.
|
20
|
+
version: '1.4'
|
21
|
+
- - "<="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.6.5
|
21
24
|
type: :runtime
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
27
|
requirements:
|
25
|
-
- - "
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '1.4'
|
31
|
+
- - "<="
|
26
32
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
33
|
+
version: 1.6.5
|
28
34
|
description: 'A RubyGem to convert :heart: to Twitter cdn url'
|
29
35
|
email:
|
30
36
|
- katehuang0320@gmail.com
|