prawn-icon 0.6.4 → 0.7.0

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: 4afdc4554a8b808e2c8f6e9d1671613065866172
4
- data.tar.gz: 9f543c9a1a41a6a4daa5a991e5b78bc65551d018
3
+ metadata.gz: 848e11a6ff5beade9d3e3f05d22adca7787893ae
4
+ data.tar.gz: 8ef5be3f116c32da92c8ab8cbb32ae2a2fa8a919
5
5
  SHA512:
6
- metadata.gz: 94d7961757cf3b1efc79b6cfed0dbf14d9aede80fce4fb8e8e1cc584bd1cacfd4c9d337e62b4cd7d22712898dbfcfa101e1591f98e8c8e8f707894e338da59b0
7
- data.tar.gz: 37de952a3ee296ec162b0aaa2b9414abe46812a8fdf1b18a1679ed3ec3d1fa1a8ece222224d96b0d5b01ff45636e256b040efec269e14a516474a0a656bff886
6
+ metadata.gz: c7efb8ff4d1b3ce84d0e4063c6d8ca88d8ee24b45d7785a82849889f859650a7b0e5d647834ace3aaf4b40d07e5966bed78677a98c75c187b1092711305afaf3
7
+ data.tar.gz: 96783b319a46bf55141e49762333aac2ea57581a81387ca775762a35ec5e5d6b9fd599c305ce607a396ea44563756aa1c646a6e49349cf3115b93e4e722ee6c1
@@ -1,3 +1,9 @@
1
+ # 0.7.0 - July 23, 2015
2
+
3
+ - Update Travis config to relax the versions of `Prawn` and `Ruby` that are tested against. See `.travis.yml` to see what versions are supported (though you shouldn't have issues with other versions).
4
+ - Implement inline_format for table icons. [#14](https://github.com/jessedoyle/prawn-icon/pull/14).
5
+ - Updated Octicons to v2.4.1. See [changelog](https://github.com/github/octicons/releases/) between versions 2.1.2 and 2.4.1.
6
+
1
7
  # 0.6.4 - May 4, 2015
2
8
 
3
9
  - [PaymentFont](http://paymentfont.io) is now supported and included in `Prawn::Icon`.
@@ -1,5 +1,5 @@
1
1
  octicon:
2
- __font_version__: '2.1.2'
2
+ __font_version__: '2.4.1'
3
3
  alert: "\uf02d"
4
4
  alignment-align: "\uf08a"
5
5
  alignment-aligned-to: "\uf08e"
@@ -192,6 +192,8 @@ octicon:
192
192
  telescope: "\uf088"
193
193
  terminal: "\uf0c8"
194
194
  three-bars: "\uf05e"
195
+ thumbsdown: "\uf0db"
196
+ thumbsup: "\uf0da"
195
197
  tools: "\uf031"
196
198
  trashcan: "\uf0d0"
197
199
  triangle-down: "\uf05b"
Binary file
@@ -23,7 +23,8 @@ module Prawn
23
23
 
24
24
  # Easy icon font usage within Prawn. Currently
25
25
  # supported icon fonts include: FontAwesome,
26
- # Zurb Foundicons, and GitHub Octicons.
26
+ # Zurb Foundicons, GitHub Octicons, as well as
27
+ # PaymentFont.
27
28
  #
28
29
  # = Icon Keys
29
30
  #
@@ -134,20 +135,23 @@ module Prawn
134
135
  # == Parameters:
135
136
  # key::
136
137
  # Contains the key to a particular icon within
137
- # a font family. Note that :inline_format is not
138
- # supported as a valid option.
138
+ # a font family. The key may contain a string
139
+ # with format tags if +inline_format: true+ in
140
+ # the +opts+ hash.
139
141
  #
140
142
  # opts::
141
143
  # A hash of options that may be supplied to the
142
- # underlying text call. Note that :inline_format
143
- # is not supported as a valid option.
144
+ # underlying text call.
144
145
  #
145
146
  # == Returns:
146
147
  # A Hash containing +font+ and +content+ keys
147
148
  # that match the data necessary for the
148
149
  # specified icon.
149
150
  #
150
- # eg. { font: 'fa', content: '/uf047' }
151
+ # eg. { font: 'fa', content: '\uf047' }
152
+ #
153
+ # Note that the +font+ key will not be set
154
+ # if +inline_format: true+.
151
155
  #
152
156
  # == Examples:
153
157
  # require 'prawn/table'
@@ -161,13 +165,12 @@ module Prawn
161
165
  # pdf.table(data) => (2 x 2 table)
162
166
  #
163
167
  def table_icon(key, opts = {})
164
- if opts.delete(:inline_format)
165
- raise Prawn::Errors::UnknownOption,
166
- 'Inline formatting is not supported.'
168
+ if opts[:inline_format]
169
+ content = Icon::Parser.format(self, key)
170
+ opts.merge(content: content)
171
+ else
172
+ make_icon(key, opts).format_hash
167
173
  end
168
-
169
- icon = make_icon(key, opts)
170
- icon.format_hash
171
174
  end
172
175
  end
173
176
 
@@ -199,7 +202,7 @@ module Prawn
199
202
 
200
203
  private
201
204
 
202
- def strip_specifier_from_key(key)
205
+ def strip_specifier_from_key(key) #:nodoc:
203
206
  reg = Regexp.new "#{@data.specifier}-"
204
207
  key.sub(reg, '') # Only one specifier
205
208
  end
@@ -8,6 +8,6 @@
8
8
 
9
9
  module Prawn
10
10
  class Icon
11
- VERSION = '0.6.4'.freeze
11
+ VERSION = '0.7.0'.freeze
12
12
  end
13
13
  end
@@ -102,20 +102,49 @@ describe Prawn::Icon::Interface do
102
102
  end
103
103
 
104
104
  describe '::table_icon' do
105
- it 'should return a hash with font and content keys' do
106
- pdf = create_pdf
107
- icon = pdf.table_icon 'fa-arrows'
105
+ context 'inline_format: false (default)' do
106
+ it 'should return a hash with font and content keys' do
107
+ pdf = create_pdf
108
+ icon = pdf.table_icon 'fa-arrows'
108
109
 
109
- expect(icon.class).to eq(Hash)
110
- expect(icon[:font]).to eq('fa')
111
- expect(icon[:content]).to eq("\uf047")
110
+ expect(icon.class).to eq(Hash)
111
+ expect(icon[:font]).to eq('fa')
112
+ expect(icon[:content]).to eq("\uf047")
113
+ end
112
114
  end
113
115
 
114
- it 'should raise an error if inline_format: true' do
115
- pdf = create_pdf
116
- proc = Proc.new { pdf.table_icon 'fa-arrows', inline_format: true }
116
+ context 'inline_format: true' do
117
+ it 'should convert <icon> to <font> tags' do
118
+ pdf = create_pdf
119
+ icon = pdf.table_icon '<icon>fa-user</icon>', inline_format: true
120
+
121
+ expect(icon.class).to eq(Hash)
122
+ expect(icon[:content]).to eq('<font name="fa"></font>')
123
+ expect(icon[:inline_format]).to be_true
124
+ end
117
125
 
118
- expect(proc).to raise_error(Prawn::Errors::UnknownOption)
126
+ it 'should ignore all other tags' do
127
+ pdf = create_pdf
128
+ a = ['<b>BOLD</b> <color rgb="0099FF">BLUE</color>', inline_format: true]
129
+ icon = pdf.table_icon(*a)
130
+
131
+ expect(icon.class).to eq(Hash)
132
+ expect(icon[:content]).to eq(a[0])
133
+ expect(icon[:inline_format]).to be_true
134
+ end
135
+
136
+ context 'multiple icons' do
137
+ it 'should ignore any text not in an icon tag' do
138
+ pdf = create_pdf
139
+ a = ['<icon>fa-user</icon> Some Text <icon>fi-laptop</icon>', inline_format: true]
140
+ out = '<font name="fa"></font> Some Text <font name="fi"></font>'
141
+ icon = pdf.table_icon(*a)
142
+
143
+ expect(icon.class).to eq(Hash)
144
+ expect(icon[:content]).to eq(out)
145
+ expect(icon[:inline_format]).to be_true
146
+ end
147
+ end
119
148
  end
120
149
  end
121
150
  end
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: 0.6.4
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Doyle
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-05 00:00:00.000000000 Z
11
+ date: 2015-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn
@@ -138,46 +138,46 @@ executables: []
138
138
  extensions: []
139
139
  extra_rdoc_files: []
140
140
  files:
141
- - CHANGELOG.md
142
- - COPYING
143
- - GPLv2
144
- - GPLv3
145
- - Gemfile
146
- - LICENSE
147
- - README.md
148
- - Rakefile
149
- - examples/example_helper.rb
150
- - examples/fa-beer-inline.png
151
- - examples/fa-beer.png
152
- - examples/fontawesome.rb
153
- - examples/foundation_icons.rb
154
- - examples/octicons.rb
155
- - examples/paymentfont.rb
141
+ - lib/prawn/icon/font_data.rb
142
+ - lib/prawn/icon/parser.rb
143
+ - lib/prawn/icon/version.rb
144
+ - lib/prawn/icon.rb
145
+ - spec/integration/icon_spec.rb
146
+ - spec/spec_helper.rb
147
+ - spec/support/parser_helper.rb
148
+ - spec/support/pdf_helper.rb
149
+ - spec/unit/font_data_spec.rb
150
+ - spec/unit/icon_spec.rb
151
+ - spec/unit/parser_spec.rb
156
152
  - fonts/DejaVuSans.ttf
157
- - fonts/fa/LICENSE
158
153
  - fonts/fa/fa.yml
159
154
  - fonts/fa/fontawesome.ttf
160
- - fonts/fi/LICENSE
155
+ - fonts/fa/LICENSE
161
156
  - fonts/fi/fi.yml
162
157
  - fonts/fi/foundation-icons.ttf
158
+ - fonts/fi/LICENSE
163
159
  - fonts/octicon/LICENSE
164
160
  - fonts/octicon/octicon.yml
165
161
  - fonts/octicon/octicons.ttf
166
162
  - fonts/pf/LICENSE
167
163
  - fonts/pf/paymentfont-webfont.ttf
168
164
  - fonts/pf/pf.yml
169
- - lib/prawn/icon.rb
170
- - lib/prawn/icon/font_data.rb
171
- - lib/prawn/icon/parser.rb
172
- - lib/prawn/icon/version.rb
165
+ - examples/example_helper.rb
166
+ - examples/fa-beer-inline.png
167
+ - examples/fa-beer.png
168
+ - examples/fontawesome.rb
169
+ - examples/foundation_icons.rb
170
+ - examples/octicons.rb
171
+ - examples/paymentfont.rb
173
172
  - prawn-icon.gemspec
174
- - spec/integration/icon_spec.rb
175
- - spec/spec_helper.rb
176
- - spec/support/parser_helper.rb
177
- - spec/support/pdf_helper.rb
178
- - spec/unit/font_data_spec.rb
179
- - spec/unit/icon_spec.rb
180
- - spec/unit/parser_spec.rb
173
+ - Gemfile
174
+ - Rakefile
175
+ - README.md
176
+ - CHANGELOG.md
177
+ - COPYING
178
+ - LICENSE
179
+ - GPLv2
180
+ - GPLv3
181
181
  homepage: https://github.com/jessedoyle/prawn-icon/
182
182
  licenses:
183
183
  - RUBY
@@ -200,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
200
  version: 1.3.6
201
201
  requirements: []
202
202
  rubyforge_project:
203
- rubygems_version: 2.4.5
203
+ rubygems_version: 2.0.14
204
204
  signing_key:
205
205
  specification_version: 4
206
206
  summary: Provides icon fonts for PrawnPDF