prawn-emoji 1.0.0 โ†’ 1.0.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
2
  SHA1:
3
- metadata.gz: 4018674fc6fdeb63d6da75cbe75118147b263b19
4
- data.tar.gz: f0d3f9737ab49fc52b985000f905c02f2ec6134c
3
+ metadata.gz: ae9aeb81129d389d4e6d20d78f17108f67929714
4
+ data.tar.gz: 62ee20930c26282d2f5b88b1a9bb5e0d93264e04
5
5
  SHA512:
6
- metadata.gz: f8f5526419759082020850b42bcb7520c0087a3cdb2832814b738cb7759a57610ec5eee727a4f37b625fbc92dfdec5a42d1c5dd6eb5cde9a2c91e0d6372f6d62
7
- data.tar.gz: fe62c9a615dc7d0b97a715f6496532956b386d8cebb02272d09eb2dbd786582010f4b351e21b907a464290e146bb0c6e5e3332704a0a5cea80f4de6abce25e3e
6
+ metadata.gz: f4a13f9f5b3f29493b70191865ea01c7fe66301a3126d75013650d71bee6aff95871bbbcc0bcda136f0f0d6e7a5a1945ab8b9a2915d3e37d43a6f00861c6344b
7
+ data.tar.gz: 1e15f873809b41c6dc67fdf96ab9508fa20e8fae353bebae5285b5a0919be2f281b4e5aca42b44d2a403e7172a86665ba3a7a60f535b075b736791e0540bb7e2
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Prawn::Emoji
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/prawn-emoji.svg)](https://badge.fury.io/rb/prawn-emoji)
3
4
  [![Build Status](https://travis-ci.org/hidakatsuya/prawn-emoji.svg)](https://travis-ci.org/hidakatsuya/prawn-emoji)
4
5
 
5
6
  Prawn::Emoji is an extention for [Prawn](https://github.com/prawnpdf/prawn), provides feature for drawing Emoji.
@@ -22,13 +23,15 @@ Or install it yourself as:
22
23
 
23
24
  ## Usage
24
25
 
26
+ In order to run the following code, you need to place both [DejaVuSans.ttf](http://sourceforge.net/projects/dejavu/) and [ipag.ttf](http://ipafont.ipa.go.jp/old/ipafont/download.html) in the same directory as the script file.
27
+
25
28
  ```ruby
26
29
  require 'prawn'
27
30
  require 'prawn/emoji'
28
31
 
29
- Prawn::Docment.generate 'foo.pdf' do
32
+ Prawn::Document.generate 'foo.pdf' do
30
33
  font 'DejaVuSans.ttf'
31
- text 'I want to eat ๐Ÿฃ.'
34
+ text '๐ŸŸ + ๐Ÿ”ช = ๐Ÿฃ'
32
35
 
33
36
  font 'ipag.ttf'
34
37
  text_box '๐ŸฃใŒ้ฃŸในใŸใ„', at: [100, 100], width: 300
@@ -37,9 +40,10 @@ Prawn::Docment.generate 'foo.pdf' do
37
40
  end
38
41
  ```
39
42
 
40
- ### CAUTION
41
43
 
42
- In order to draw emoji, you will need to use a TTF - True Type Font. I strongly recommended you use a Japanese font.
44
+ ### IMPORTANT
45
+
46
+ In order to draw emoji, you must use a TTF - True Type Font. I recommend you use a Japanese font.
43
47
 
44
48
  ## Feature
45
49
 
@@ -4,7 +4,7 @@ module Prawn
4
4
  module Emoji
5
5
  module Drawable
6
6
  def draw_text!(text, options)
7
- text_without_emoji = emoji_drawer.draw(text, options)
7
+ text_without_emoji = emoji_drawer.draw(text.to_s, options)
8
8
  super text_without_emoji, options
9
9
  end
10
10
 
@@ -11,6 +11,9 @@ module Prawn
11
11
  end
12
12
 
13
13
  def draw(text, text_options)
14
+ # Skip if text encoding is not UTF-8.
15
+ return text unless text.encoding == ::Encoding::UTF_8
16
+
14
17
  draw_emoji(text, text_options)
15
18
  end
16
19
 
@@ -1,5 +1,5 @@
1
1
  module Prawn
2
2
  module Emoji
3
- VERSION = '1.0.0'.freeze
3
+ VERSION = '1.0.1'.freeze
4
4
  end
5
5
  end
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.homepage = 'https://github.com/hidakatsuya/prawn-emoji'
15
15
  spec.license = 'MIT'
16
16
  spec.platform = Gem::Platform::RUBY
17
- spec.required_ruby_version = '>= 2.0'
17
+ spec.required_ruby_version = '>= 2.1'
18
18
 
19
19
  spec.files = `git ls-files`.split("\n")
20
20
  spec.test_files = `git ls-files -- {test}/*`.split("\n")
@@ -10,7 +10,7 @@ describe Prawn::Emoji::Drawable do
10
10
  describe '#draw_text!' do
11
11
  it 'calls Emoji::Drawer#draw before processing self' do
12
12
  any_instance_of(Prawn::Emoji::Drawer) do |drawer|
13
- stub(drawer).draw('text', { option: 'value' }).once
13
+ mock(drawer).draw('text', { option: 'value' }).once
14
14
  end
15
15
  document_test.draw_text!('text', option: 'value')
16
16
  end
@@ -11,6 +11,28 @@ describe Prawn::Emoji::Drawer do
11
11
  document.font Prawn::Emoji.root.join 'test', 'fonts', 'DejaVuSans.ttf'
12
12
  end
13
13
 
14
+ describe '#draw' do
15
+ subject { drawer.draw(text, {}) }
16
+
17
+ describe 'when text encoding is not utf-8' do
18
+ let(:text) { "\xe8\x8a\xb1".force_encoding('ascii-8bit') }
19
+
20
+ it 'skip' do
21
+ mock(drawer).draw_emoji(text, {}).never
22
+ subject
23
+ end
24
+ end
25
+
26
+ describe 'when text encoding is utf-8' do
27
+ let(:text) { "\xe8\x8a\xb1" }
28
+
29
+ it 'performs' do
30
+ mock(drawer).draw_emoji(text, {}).once
31
+ subject
32
+ end
33
+ end
34
+ end
35
+
14
36
  describe '#draw_emoji' do
15
37
  subject { drawer.send :draw_emoji, text, text_options }
16
38
  let(:text_options) { { at: [100, 100], font_size: 12 } }
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: 1.0.0
4
+ version: 1.0.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: 2016-01-04 00:00:00.000000000 Z
11
+ date: 2016-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn
@@ -1156,7 +1156,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
1156
1156
  requirements:
1157
1157
  - - ">="
1158
1158
  - !ruby/object:Gem::Version
1159
- version: '2.0'
1159
+ version: '2.1'
1160
1160
  required_rubygems_version: !ruby/object:Gem::Requirement
1161
1161
  requirements:
1162
1162
  - - ">="
@@ -1164,8 +1164,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
1164
1164
  version: '0'
1165
1165
  requirements: []
1166
1166
  rubyforge_project:
1167
- rubygems_version: 2.4.5.1
1167
+ rubygems_version: 2.5.1
1168
1168
  signing_key:
1169
1169
  specification_version: 4
1170
1170
  summary: Provides support for Emoji in Prawn
1171
1171
  test_files: []
1172
+ has_rdoc: