twemoji 2.1.1 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module Twemoji
2
- VERSION = "2.1.1"
2
+ VERSION = "2.2.1"
3
3
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # coding: utf-8
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
@@ -13,7 +14,7 @@ Gem::Specification.new do |spec|
13
14
  spec.homepage = "https://github.com/jollygoodcode/twemoji"
14
15
  spec.license = "MIT"
15
16
 
16
- spec.files = `git ls-files -z`.split("\x0")
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f =~ %r(^(test)/) }
17
18
  spec.require_paths = %w(lib)
18
19
 
19
20
  spec.add_dependency "nokogiri", "~> 1.6.2"
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: 2.1.1
4
+ version: 2.2.1
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: 2015-10-09 00:00:00.000000000 Z
12
+ date: 2016-06-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -40,14 +40,12 @@ files:
40
40
  - LICENSE.md
41
41
  - README.md
42
42
  - Rakefile
43
+ - bin/hack
43
44
  - lib/twemoji.rb
44
45
  - lib/twemoji/configuration.rb
45
46
  - lib/twemoji/json.rb
46
47
  - lib/twemoji/map.rb
47
48
  - lib/twemoji/version.rb
48
- - test/configuration_test.rb
49
- - test/test_helper.rb
50
- - test/twemoji_test.rb
51
49
  - twemoji.gemspec
52
50
  homepage: https://github.com/jollygoodcode/twemoji
53
51
  licenses:
@@ -69,9 +67,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
67
  version: '0'
70
68
  requirements: []
71
69
  rubyforge_project:
72
- rubygems_version: 2.4.8
70
+ rubygems_version: 2.6.4
73
71
  signing_key:
74
72
  specification_version: 4
75
73
  summary: 'A RubyGem to convert :heart: to Twitter cdn url'
76
74
  test_files: []
77
- has_rdoc:
@@ -1,57 +0,0 @@
1
- require "test_helper"
2
-
3
- class TwemojiConfigurationTest < Minitest::Test
4
- def teardown
5
- Twemoji.configuration = nil
6
- Twemoji.configure {}
7
- end
8
-
9
- def test_configuration_defaults
10
- assert_equal "https://twemoji.maxcdn.com/", Twemoji.configuration.asset_root
11
- assert_equal ".png", Twemoji.configuration.file_ext
12
- assert_equal "16x16", Twemoji.configuration.image_size
13
- assert_equal "emoji", Twemoji.configuration.class_name
14
- assert_equal Hash(nil), Twemoji.configuration.img_attrs
15
- end
16
-
17
- def test_configuration_asset_root
18
- Twemoji.configure do |config|
19
- config.asset_root = "https://twemoji.awesomecdn.com/"
20
- end
21
-
22
- assert_equal "https://twemoji.awesomecdn.com/", Twemoji.configuration.asset_root
23
- end
24
-
25
- def test_configuration_file_ext
26
- Twemoji.configure do |config|
27
- config.file_ext = ".svg"
28
- end
29
-
30
- assert_equal ".svg", Twemoji.configuration.file_ext
31
- end
32
-
33
- def test_configuration_image_size
34
- Twemoji.configure do |config|
35
- config.file_ext = ".png"
36
- config.image_size = "36x36"
37
- end
38
-
39
- assert_equal "36x36", Twemoji.configuration.image_size
40
- end
41
-
42
- def test_configuration_class_name
43
- Twemoji.configure do |config|
44
- config.class_name = "twemoji"
45
- end
46
-
47
- assert_equal "twemoji", Twemoji.configuration.class_name
48
- end
49
-
50
- def test_configuration_img_attrs
51
- Twemoji.configure do |config|
52
- config.img_attrs = { style: "height: 1.3em" }
53
- end
54
-
55
- assert_equal Hash(style: "height: 1.3em"), Twemoji.configuration.img_attrs
56
- end
57
- end
@@ -1,15 +0,0 @@
1
- require "bundler/setup"
2
- require "twemoji"
3
- require "minitest/autorun"
4
-
5
- module Twemoji
6
- module TestExtensions
7
- def assert_nothing_raised
8
- yield if block_given?
9
- end
10
- end
11
- end
12
-
13
- class Minitest::Test
14
- include Twemoji::TestExtensions
15
- end
@@ -1,170 +0,0 @@
1
- require "test_helper"
2
-
3
- class TwemojiTest < Minitest::Test
4
- def setup
5
- @option = {}
6
- end
7
-
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
12
-
13
- assert_equal "Can only specify text, code or unicode one at a time", exception.message
14
- end
15
-
16
- def test_finder_methods_find_by_text
17
- assert_equal "1f60d", Twemoji.find_by(text: ":heart_eyes:")
18
- end
19
-
20
- def test_finder_methods_find_by_code
21
- assert_equal ":heart_eyes:", Twemoji.find_by(code: "1f60d")
22
- end
23
-
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
39
-
40
- def test_find_by_escaped_unicode
41
- assert_equal ":heart_eyes:", Twemoji.find_by_unicode("\u{1f60d}")
42
- end
43
-
44
- def test_parse_html_string
45
- expected = %(I like chocolate <img draggable="false" title=":heart_eyes:" alt="😍" src="https://twemoji.maxcdn.com/16x16/1f60d.png" class="emoji">!)
46
-
47
- assert_equal expected, Twemoji.parse("I like chocolate :heart_eyes:!")
48
- end
49
-
50
- def test_parse_document
51
- doc = Nokogiri::HTML::DocumentFragment.parse("<p>I like chocolate :heart_eyes:!</p>")
52
- expected = '<p>I like chocolate <img draggable="false" title=":heart_eyes:" alt="😍" src="https://twemoji.maxcdn.com/16x16/1f60d.png" class="emoji">!</p>'
53
-
54
- assert_equal expected, Twemoji.parse(doc).to_html
55
- end
56
-
57
- def test_parse_option_asset_root
58
- expected = %(I like chocolate <img draggable="false" title=":heart_eyes:" alt="😍" src="https://emoji.bestcdn.com/16x16/1f60d.png" class="emoji">!)
59
-
60
- assert_equal expected, Twemoji.parse("I like chocolate :heart_eyes:!", asset_root: 'https://emoji.bestcdn.com')
61
- end
62
-
63
- def test_parse_option_file_ext_svg
64
- expected = %(I like chocolate <img draggable="false" title=":heart_eyes:" alt="😍" src="https://twemoji.maxcdn.com/svg/1f60d.svg" class="emoji">!)
65
-
66
- assert_equal expected, Twemoji.parse("I like chocolate :heart_eyes:!", file_ext: '.svg')
67
- end
68
-
69
- def test_parse_option_unsupport_file_ext_gif
70
- exception = assert_raises RuntimeError do
71
- Twemoji.parse("I like chocolate :heart_eyes:!", file_ext: '.gif')
72
- end
73
-
74
- assert_equal "Unsupported file extension: .gif", exception.message
75
- end
76
-
77
- def test_parse_option_image_size
78
- expected = %(I like chocolate <img draggable="false" title=":heart_eyes:" alt="😍" src="https://twemoji.maxcdn.com/72x72/1f60d.png" class="emoji">!)
79
-
80
- assert_equal expected, Twemoji.parse("I like chocolate :heart_eyes:!", file_ext: ".png", image_size: "72x72")
81
- end
82
-
83
- def test_parse_option_class_name
84
- expected = %(I like chocolate <img draggable="false" title=":heart_eyes:" alt="😍" src="https://twemoji.maxcdn.com/16x16/1f60d.png" class="twemoji">!)
85
-
86
- assert_equal expected, Twemoji.parse("I like chocolate :heart_eyes:!", class_name: 'twemoji')
87
- end
88
-
89
- def test_parse_option_single_img_attr
90
- expected = %(I like chocolate <img draggable="false" title=":heart_eyes:" alt="😍" src="https://twemoji.maxcdn.com/16x16/1f60d.png" class="twemoji" style="height: 1.3em;">!)
91
-
92
- assert_equal expected, Twemoji.parse("I like chocolate :heart_eyes:!", class_name: 'twemoji', img_attrs: { style: 'height: 1.3em;' })
93
- end
94
-
95
- def test_parse_option_multiple_img_attrs
96
- expected = %(I like chocolate <img draggable="false" title=":heart_eyes:" alt="😍" src="https://twemoji.maxcdn.com/16x16/1f60d.png" class="twemoji" style="height: 1.3em;" width="20">!)
97
-
98
- assert_equal expected, Twemoji.parse("I like chocolate :heart_eyes:!", class_name: 'twemoji', img_attrs: { style: 'height: 1.3em;', width: "20" })
99
- end
100
-
101
- def test_parse_option_img_attr_callable
102
- shortname_filter = ->(name) { name.gsub(":", "") }
103
-
104
- img_attrs = {
105
- style: "height: 1.3em;",
106
- title: shortname_filter,
107
- alt: shortname_filter,
108
- }
109
-
110
- expected = %(I like chocolate <img draggable="false" title="heart_eyes" alt="heart_eyes" src="https://twemoji.maxcdn.com/16x16/1f60d.png" class="twemoji" style="height: 1.3em;">!)
111
-
112
- assert_equal expected, Twemoji.parse("I like chocolate :heart_eyes:!", class_name: 'twemoji', img_attrs: img_attrs)
113
- end
114
-
115
- def test_emoji_pattern
116
- assert_kind_of Regexp, Twemoji.emoji_pattern
117
- end
118
-
119
- def test_to_json_unsupported_file_ext
120
- assert_raises RuntimeError do
121
- Twemoji.to_json(file_ext: "bmp")
122
- end
123
- end
124
-
125
- def test_to_json_unsupported_png_size
126
- assert_raises RuntimeError do
127
- Twemoji.to_json(file_ext: "png", image_size: "24x24")
128
- end
129
- end
130
-
131
- def test_to_json_svg_format
132
- json = assert_nothing_raised do
133
- Twemoji.to_json(file_ext: "svg")
134
- end
135
-
136
- refute_includes json, "png"
137
- end
138
-
139
- def test_to_json_svg_format_ignore_image_size
140
- json = assert_nothing_raised do
141
- Twemoji.to_json(file_ext: "svg", image_size: "16x16")
142
- end
143
-
144
- refute_includes json, "png"
145
- end
146
-
147
- def test_to_json_png_format_size_16x16
148
- json = assert_nothing_raised do
149
- Twemoji.to_json(file_ext: "png", image_size: "16x16")
150
- end
151
-
152
- refute_includes json, "svg"
153
- end
154
-
155
- def test_to_json_png_format_size_36x36
156
- json = assert_nothing_raised do
157
- Twemoji.to_json(file_ext: "png", image_size: "36x36")
158
- end
159
-
160
- refute_includes json, "svg"
161
- end
162
-
163
- def test_to_json_png_format_size_72x72
164
- json = assert_nothing_raised do
165
- Twemoji.to_json(file_ext: "png", image_size: "72x72")
166
- end
167
-
168
- refute_includes json, "svg"
169
- end
170
- end