prawn-icon 1.1.0 → 1.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
2
  SHA1:
3
- metadata.gz: 60c827fe1c0063f5a64c2d1a4f19df456880b407
4
- data.tar.gz: 7e4d155380ff3e6266d78ecb35532b29d05f3afd
3
+ metadata.gz: b64e3846aacc7bd1d02241cfa7553f93ff7593e8
4
+ data.tar.gz: c91fdbd43dc2ceb27b4259fa00ced40b7fc96bf8
5
5
  SHA512:
6
- metadata.gz: b27500edce7d1a45e4a51dfd135d3de5212a662509ffaff488aa7a9ec7dd99f7a8643f0da34e272cdb7bd97a6b2c69a14512e628fab6397c0e0bbc6f581529c2
7
- data.tar.gz: d85b373423054100048ac6e9113f589a13e2de5563d2115a98457fc426206ac07a2b34326c169de4dc1bd40bccb3007400e4429ec2bb1cd10c8c938989debd35
6
+ metadata.gz: 7e88aafd5376b82e3275980dce6e1966b80218272aed798016d0701def22141b1d8632fb6c4a2b2ff0b6dc2874677f243addfb686c68644cb1a028aacf82086b
7
+ data.tar.gz: fc8e5ff0f96c4be2e8e3a6a788e150691c0dbba35693926027bdd971944a9cf2c2b732524faaa17d778a704a06a7f557a0f1f48f77815c88696697a2a3be989d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 1.1.1 - Jun 24, 2016
2
+
3
+ - BUGFIX: Inline icons now properly render at the correct cursor position with the correct line gap and box leading[#24](https://github.com/jessedoyle/prawn-icon/issues/24). Thanks @ToniTornado for reporting!
4
+
1
5
  # 1.1.0 - March 16, 2016
2
6
 
3
7
  - Update FontAwesome from v4.4.0 to v4.5.0. See [changelog](http://fontawesome.io/icons#new).
data/GPLv2 CHANGED
@@ -1,12 +1,12 @@
1
- GNU GENERAL PUBLIC LICENSE
2
- Version 2, June 1991
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
3
 
4
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
6
  Everyone is permitted to copy and distribute verbatim copies
7
7
  of this license document, but changing it is not allowed.
8
8
 
9
- Preamble
9
+ Preamble
10
10
 
11
11
  The licenses for most software are designed to take away your
12
12
  freedom to share and change it. By contrast, the GNU General Public
@@ -15,7 +15,7 @@ software--to make sure the software is free for all its users. This
15
15
  General Public License applies to most of the Free Software
16
16
  Foundation's software and to any other program whose authors commit to
17
17
  using it. (Some other Free Software Foundation software is covered by
18
- the GNU Library General Public License instead.) You can apply it to
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
19
  your programs, too.
20
20
 
21
21
  When we speak of free software, we are referring to freedom, not
@@ -55,8 +55,8 @@ patent must be licensed for everyone's free use or not licensed at all.
55
55
 
56
56
  The precise terms and conditions for copying, distribution and
57
57
  modification follow.
58
-
59
- GNU GENERAL PUBLIC LICENSE
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
60
  TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
61
 
62
62
  0. This License applies to any program or other work which contains
@@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions:
110
110
  License. (Exception: if the Program itself is interactive but
111
111
  does not normally print such an announcement, your work based on
112
112
  the Program is not required to print an announcement.)
113
-
113
+
114
114
  These requirements apply to the modified work as a whole. If
115
115
  identifiable sections of that work are not derived from the Program,
116
116
  and can be reasonably considered independent and separate works in
@@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent
168
168
  access to copy the source code from the same place counts as
169
169
  distribution of the source code, even though third parties are not
170
170
  compelled to copy the source along with the object code.
171
-
171
+
172
172
  4. You may not copy, modify, sublicense, or distribute the Program
173
173
  except as expressly provided under this License. Any attempt
174
174
  otherwise to copy, modify, sublicense or distribute the Program is
@@ -225,7 +225,7 @@ impose that choice.
225
225
 
226
226
  This section is intended to make thoroughly clear what is believed to
227
227
  be a consequence of the rest of this License.
228
-
228
+
229
229
  8. If the distribution and/or use of the Program is restricted in
230
230
  certain countries either by patents or by copyrighted interfaces, the
231
231
  original copyright holder who places the Program under this License
@@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals
255
255
  of preserving the free status of all derivatives of our free software and
256
256
  of promoting the sharing and reuse of software generally.
257
257
 
258
- NO WARRANTY
258
+ NO WARRANTY
259
259
 
260
260
  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
261
  FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
@@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
277
  PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
278
  POSSIBILITY OF SUCH DAMAGES.
279
279
 
280
- END OF TERMS AND CONDITIONS
281
-
282
- How to Apply These Terms to Your New Programs
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
283
 
284
284
  If you develop a new program, and you want it to be of the greatest
285
285
  possible use to the public, the best way to achieve this is to make it
@@ -303,17 +303,16 @@ the "copyright" line and a pointer to where the full notice is found.
303
303
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
304
  GNU General Public License for more details.
305
305
 
306
- You should have received a copy of the GNU General Public License
307
- along with this program; if not, write to the Free Software
308
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
309
-
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
310
309
 
311
310
  Also add information on how to contact you by electronic and paper mail.
312
311
 
313
312
  If the program is interactive, make it output a short notice like this
314
313
  when it starts in an interactive mode:
315
314
 
316
- Gnomovision version 69, Copyright (C) year name of author
315
+ Gnomovision version 69, Copyright (C) year name of author
317
316
  Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
318
317
  This is free software, and you are welcome to redistribute it
319
318
  under certain conditions; type `show c' for details.
@@ -336,5 +335,5 @@ necessary. Here is a sample; alter the names:
336
335
  This General Public License does not permit incorporating your program into
337
336
  proprietary programs. If your program is a subroutine library, you may
338
337
  consider it more useful to permit linking proprietary applications with the
339
- library. If this is what you want to do, use the GNU Library General
340
- Public License instead of this License.
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
data/lib/prawn/icon.rb CHANGED
@@ -119,10 +119,14 @@ module Prawn
119
119
  # underlying text call.
120
120
  #
121
121
  def inline_icon(text, opts = {})
122
- parsed = Icon::Parser.format(self, text)
123
- content = Text::Formatted::Parser.format(parsed)
124
- opts.merge!(inline_format: true, document: self)
125
- Text::Formatted::Box.new(content, opts)
122
+ parsed = Icon::Parser.format(self, text)
123
+ content = Text::Formatted::Parser.format(parsed)
124
+ box_options = opts.merge(
125
+ inline_format: true,
126
+ document: self,
127
+ at: [bounds.left, cursor]
128
+ )
129
+ icon_box(content, box_options)
126
130
  end
127
131
 
128
132
  # Initialize a new Prawn::Icon, but don't render
@@ -170,6 +174,18 @@ module Prawn
170
174
  make_icon(key, opts).format_hash
171
175
  end
172
176
  end
177
+
178
+ private
179
+
180
+ def icon_box(content, opts = {}) # :nodoc:
181
+ Text::Formatted::Box.new(content, opts).tap do |box|
182
+ box.render(dry_run: true)
183
+ self.y -= box.height
184
+ unless opts.fetch(:final_gap, true)
185
+ self.y -= box.line_gap + box.leading
186
+ end
187
+ end
188
+ end
173
189
  end
174
190
 
175
191
  attr_reader :set, :unicode
@@ -200,7 +216,7 @@ module Prawn
200
216
 
201
217
  private
202
218
 
203
- def strip_specifier_from_key(key) #:nodoc:
219
+ def strip_specifier_from_key(key) # :nodoc:
204
220
  reg = Regexp.new "#{@data.specifier}-"
205
221
  key.sub(reg, '') # Only one specifier
206
222
  end
@@ -8,6 +8,6 @@
8
8
 
9
9
  module Prawn
10
10
  class Icon
11
- VERSION = '1.1.0'.freeze
11
+ VERSION = '1.1.1'.freeze
12
12
  end
13
13
  end
data/prawn-icon.gemspec CHANGED
@@ -27,9 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency('pdf-inspector', '~> 1.2.1')
28
28
  spec.add_development_dependency('rspec', '~> 3.4.0')
29
29
  spec.add_development_dependency('rubocop', '~> 0.38.0')
30
- spec.add_development_dependency('mocha')
31
30
  spec.add_development_dependency('rake')
32
- spec.add_development_dependency('simplecov')
33
31
  spec.add_development_dependency('pdf-reader', '~> 1.4')
34
32
 
35
33
  spec.description = <<-END_DESC
@@ -40,6 +40,21 @@ describe Prawn::Icon::Interface do
40
40
  expect(text1.strings.first).to eq("\uf047")
41
41
  expect(text2.strings.first).to eq("\uf047")
42
42
  end
43
+
44
+ it 'renders the icon at the proper cursor position (#24)' do
45
+ icon_text = '<icon>fa-info-circle</icon> icon here!'
46
+ pdf = create_pdf
47
+ pdf.text 'Start'
48
+ pdf.move_down 10
49
+ pdf.text 'More'
50
+ pdf.move_down 20
51
+ icon = pdf.icon icon_text, inline_format: true
52
+ pdf.move_down 30
53
+ pdf.text 'End'
54
+
55
+ expect(icon.at.first).to eq(0)
56
+ expect(icon.at.last.round).to eq(734)
57
+ end
43
58
  end
44
59
 
45
60
  context 'without options' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawn-icon
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Doyle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-17 00:00:00.000000000 Z
11
+ date: 2016-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn
@@ -72,20 +72,6 @@ dependencies:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: 0.38.0
75
- - !ruby/object:Gem::Dependency
76
- name: mocha
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - ">="
80
- - !ruby/object:Gem::Version
81
- version: '0'
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - ">="
87
- - !ruby/object:Gem::Version
88
- version: '0'
89
75
  - !ruby/object:Gem::Dependency
90
76
  name: rake
91
77
  requirement: !ruby/object:Gem::Requirement
@@ -100,20 +86,6 @@ dependencies:
100
86
  - - ">="
101
87
  - !ruby/object:Gem::Version
102
88
  version: '0'
103
- - !ruby/object:Gem::Dependency
104
- name: simplecov
105
- requirement: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - ">="
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- type: :development
111
- prerelease: false
112
- version_requirements: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - ">="
115
- - !ruby/object:Gem::Version
116
- version: '0'
117
89
  - !ruby/object:Gem::Dependency
118
90
  name: pdf-reader
119
91
  requirement: !ruby/object:Gem::Requirement