prawn-emoji 2.1.0 → 2.1.1

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: 30464f704625995fdd24c34529781eb09f5cc988
4
- data.tar.gz: 730b6f231a9db3d31f560372bbffcc1e45da50cf
2
+ SHA256:
3
+ metadata.gz: 7c7814b9fcdf6df957493097c0a5a82b8759e4102058afda188a3323f7a48ea2
4
+ data.tar.gz: 5759ef6fbdfdc30bb48dbf9a8c8e87c7ddf9aa65c7f7ea5ddf52aa643d4d3469
5
5
  SHA512:
6
- metadata.gz: 00c4a04c30c7c42b529a16a0368e2f9d689dcfece6adb14c2b8d2eb339de921175e8ed469f0415fe0a21f77624ff35de9401293c9e64959002d1726c7263e02f
7
- data.tar.gz: 871b4cdf8e5af80ac414160bd2603884900438746f08b9a43da551e90c04d25b465c54f1a5dba4f6f939219e0e96b14680e181e6354959decfce767cf30d6c21
6
+ metadata.gz: 6ca4f75d9382b7a9df0be903b07761b7d924edbdb493516d48784664885e9fe775024273c0c049298b627d69770c74d6bed3c11415a0e4c5a4c42418576ec30d
7
+ data.tar.gz: d6040f8f133f46b844523836e10e4ec0f0bf3ab326e31a42349894a8f828e4ba66769538756384a0d58f0be581456760b420787443e2219e798c9acbf1fc5319
@@ -4,12 +4,16 @@ sudo: false
4
4
 
5
5
  rvm:
6
6
  - 2.1.10
7
- - 2.2.7
8
- - 2.3.4
9
- - 2.4.1
7
+ - 2.2.9
8
+ - 2.3.6
9
+ - 2.4.3
10
+ - 2.5.0
10
11
 
11
12
  gemfile:
12
13
  - test/gemfiles/prawn-2.1
13
14
  - test/gemfiles/prawn-2.2
14
15
 
16
+ before_install:
17
+ - travis_retry gem update --system
18
+
15
19
  script: bundle exec rake test
@@ -1,3 +1,9 @@
1
+ ## 2.1.1
2
+
3
+ ### Bug Fixes:
4
+
5
+ * Fixed: A text including multiple emojis are broken #19
6
+
1
7
  ## 2.1.0
2
8
 
3
9
  ### Breaking Changes
data/README.md CHANGED
@@ -61,7 +61,7 @@ See also https://travis-ci.org/hidakatsuya/prawn-emoji.
61
61
 
62
62
  ### Ruby
63
63
 
64
- 2.1, 2.2, 2.3, 2.4
64
+ 2.1, 2.2, 2.3, 2.4, 2.5
65
65
 
66
66
  ### Prawn
67
67
 
@@ -25,35 +25,38 @@ module Prawn
25
25
  def draw_emoji(text, text_options)
26
26
  return text unless @emoji_index.to_regexp =~ text
27
27
 
28
- result = []
29
- target = text
28
+ result_texts = []
29
+ target_text = text
30
30
 
31
- while target do
32
- left_text, emoji_unicode, remaining_text = partition_emoji(target)
31
+ while target_text do
32
+ left_text, emoji_unicode, remaining_text = partition_emoji(target_text)
33
33
 
34
34
  if emoji_unicode.nil?
35
- result << target
35
+ result_texts << target_text
36
36
  break
37
37
  end
38
38
 
39
- result << left_text
40
- result << if emoji_unicode.text?
41
- emoji_unicode.to_s
42
- else
43
- emoji_image = Emoji::Image.new(emoji_unicode)
39
+ current_result_texts = [left_text]
40
+ current_result_texts <<
41
+ if emoji_unicode.text?
42
+ emoji_unicode.to_s
43
+ else
44
+ emoji_image = Emoji::Image.new(emoji_unicode)
44
45
 
45
- emoji_x, emoji_y = text_options[:at]
46
- emoji_x += @document.width_of(left_text, text_options)
47
- emoji_y += @document.font_size
46
+ emoji_x, emoji_y = text_options[:at]
47
+ emoji_x += @document.width_of(result_texts.join + left_text, text_options)
48
+ emoji_y += @document.font_size
48
49
 
49
- draw_emoji_image emoji_image, at: [emoji_x, emoji_y], width: @document.font_size
50
+ draw_emoji_image emoji_image, at: [emoji_x, emoji_y], width: @document.font_size
50
51
 
51
- Emoji::Substitution.new(@document).to_s
52
- end
53
- target = remaining_text
52
+ Emoji::Substitution.new(@document).to_s
53
+ end
54
+
55
+ result_texts += current_result_texts
56
+ target_text = remaining_text
54
57
  end
55
58
 
56
- result.join
59
+ result_texts.join
57
60
  end
58
61
 
59
62
  def draw_emoji_image(emoji_image, at:, width:)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Prawn
4
4
  module Emoji
5
- VERSION = '2.1.0'.freeze
5
+ VERSION = '2.1.1'.freeze
6
6
  end
7
7
  end
@@ -38,7 +38,9 @@ describe Prawn::Emoji::Drawer do
38
38
 
39
39
  describe '#draw_emoji' do
40
40
  subject { drawer.send :draw_emoji, text, text_options }
41
- let(:text_options) { { at: [100, 100], font_size: 12 } }
41
+
42
+ let(:text_options) { { at: [100, 200], font_size: 12 } }
43
+ let(:sub_char) { Prawn::Emoji::Substitution.new(document) }
42
44
 
43
45
  describe 'when not includes emoji' do
44
46
  let(:text) { 'abc' }
@@ -49,18 +51,23 @@ describe Prawn::Emoji::Drawer do
49
51
  end
50
52
 
51
53
  describe 'when includes emoji' do
52
- let(:text) { "aaa#{sushi}bbb" }
53
-
54
- it 'draws image for included emoji' do
55
- image_width = 12
56
- image_at = [100 + document.width_of('aaa', text_options), 100 + 12]
57
-
58
- mock(drawer).draw_emoji_image(sushi_image, at: image_at, width: image_width).once
54
+ let(:text) { "aaa#{sushi}bbb#{sushi}#{sushi}ccc" }
55
+
56
+ it 'draws alternative images for each emoji included in the text' do
57
+ image_x_positions = [
58
+ 100 + document.width_of('aaa', text_options),
59
+ 100 + document.width_of("aaa#{sub_char}bbb", text_options),
60
+ 100 + document.width_of("aaa#{sub_char}bbb#{sub_char}", text_options)
61
+ ]
62
+
63
+ image_x_positions.each { |x|
64
+ mock(drawer).draw_emoji_image(sushi_image, at: [x, 200 + 12], width: 12).once
65
+ }
59
66
  subject
60
67
  end
61
68
 
62
69
  it 'returns text that all emoji has substituted' do
63
- subject.must_equal "aaa#{Prawn::Emoji::Substitution.new(document)}bbb"
70
+ subject.must_equal "aaa#{sub_char}bbb#{sub_char}#{sub_char}ccc"
64
71
  end
65
72
  end
66
73
  end
@@ -3,34 +3,36 @@
3
3
  require 'test_helper'
4
4
 
5
5
  describe Prawn::Emoji::Unicode do
6
- let(:klass) { Prawn::Emoji::Unicode }
6
+ def unicode(emoji)
7
+ Prawn::Emoji::Unicode.new(emoji)
8
+ end
7
9
 
8
10
  describe '#==' do
9
- it { klass.new('🐟').must_be :==, klass.new('🐟') }
10
- it { klass.new('🐟').wont_be :==, klass.new('🍣') }
11
+ it { unicode('🐟').must_be :==, unicode('🐟') }
12
+ it { unicode('🐟').wont_be :==, unicode('🍣') }
11
13
  end
12
14
 
13
15
  describe '#codepoint' do
14
- it { klass.new('🍣').codepoint.must_equal '1f363' }
15
- it { klass.new('🇯🇵').codepoint.must_equal '1f1ef-1f1f5' }
16
+ it { unicode('🍣').codepoint.must_equal '1f363' }
17
+ it { unicode('🇯🇵').codepoint.must_equal '1f1ef-1f1f5' }
16
18
  end
17
19
 
18
20
  describe '#to_s' do
19
- it { klass.new('🍣').to_s.must_equal '🍣' }
20
- it { klass.new('❤️').to_s.wont_match /[\ufe0e\ufe0f]/ }
21
+ it { unicode('🍣').to_s.must_equal '🍣' }
22
+ it { unicode('❤️').to_s.wont_match /[\ufe0e\ufe0f]/ }
21
23
  end
22
24
 
23
25
  describe '#text?' do
24
26
  describe 'no selector' do
25
- it { klass.new('☀').wont_be :text? }
27
+ it { unicode('☀').wont_be :text? }
26
28
  end
27
29
 
28
30
  describe 'with text presentation selector' do
29
- it { klass.new('☀︎').must_be :text? }
31
+ it { unicode('☀︎').must_be :text? }
30
32
  end
31
33
 
32
34
  describe 'with emoji presentation selector' do
33
- it { klass.new('☀️').wont_be :text? }
35
+ it { unicode('☀️').wont_be :text? }
34
36
  end
35
37
  end
36
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawn-emoji
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Katsuya HIDAKA
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-30 00:00:00.000000000 Z
11
+ date: 2018-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn
@@ -1983,7 +1983,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1983
1983
  version: '0'
1984
1984
  requirements: []
1985
1985
  rubyforge_project:
1986
- rubygems_version: 2.6.11
1986
+ rubygems_version: 2.7.4
1987
1987
  signing_key:
1988
1988
  specification_version: 4
1989
1989
  summary: Provides support for Emoji in Prawn