prawn-icon 1.3.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,7 +12,7 @@ describe Prawn::Icon::Errors::IconNotFound do
12
12
  end
13
13
 
14
14
  it 'is thrown on an invalid icon key' do
15
- proc = Proc.new { pdf.icon 'fa-an invalid key' }
15
+ proc = Proc.new { pdf.icon 'far-an invalid key' }
16
16
 
17
17
  expect(proc).to raise_error(described_class)
18
18
  end
@@ -8,21 +8,21 @@ require 'spec_helper'
8
8
 
9
9
  describe Prawn::Icon::FontData do
10
10
  let(:pdf) { create_pdf }
11
- let(:fontawesome) { Prawn::Icon::FontData.new(pdf, set: :fa) }
11
+ let(:fontawesome) { Prawn::Icon::FontData.new(pdf, set: :far) }
12
12
 
13
13
  before { Prawn::Icon::FontData.release_data }
14
14
 
15
15
  describe '#initialize' do
16
- before { Prawn::Icon::FontData.new(pdf, set: :fa) }
16
+ before { Prawn::Icon::FontData.new(pdf, set: :far) }
17
17
 
18
18
  it 'should update font_families on initialization' do
19
- expect(pdf.font_families['fa']).not_to be_nil
19
+ expect(pdf.font_families['far']).not_to be_nil
20
20
  end
21
21
  end
22
22
 
23
23
  describe '::load' do
24
24
  context 'specifier is a string' do
25
- let(:data) { Prawn::Icon::FontData.load(pdf, 'fa') }
25
+ let(:data) { Prawn::Icon::FontData.load(pdf, 'far') }
26
26
 
27
27
  it 'should load the font' do
28
28
  expect(data).not_to be_nil
@@ -30,7 +30,7 @@ describe Prawn::Icon::FontData do
30
30
 
31
31
  it 'should only load a single object for multiple documents' do
32
32
  obj_id_1 = data.object_id
33
- second = Prawn::Icon::FontData.load(pdf, 'fa')
33
+ second = Prawn::Icon::FontData.load(pdf, 'far')
34
34
  obj_id_2 = second.object_id
35
35
 
36
36
  expect(obj_id_1).to eq(obj_id_2)
@@ -38,7 +38,7 @@ describe Prawn::Icon::FontData do
38
38
  end
39
39
 
40
40
  context 'specifier is a symbol' do
41
- let(:data) { Prawn::Icon::FontData.load(pdf, :fa) }
41
+ let(:data) { Prawn::Icon::FontData.load(pdf, :far) }
42
42
 
43
43
  it 'should load the font' do
44
44
  expect(data).not_to be_nil
@@ -48,9 +48,8 @@ describe Prawn::Icon::FontData do
48
48
 
49
49
  describe '::release_data' do
50
50
  it 'should remove all data references if requested' do
51
- Prawn::Icon::FontData.load(pdf, :fa)
51
+ Prawn::Icon::FontData.load(pdf, :far)
52
52
  Prawn::Icon::FontData.load(pdf, :fi)
53
- Prawn::Icon::FontData.load(pdf, :octicon)
54
53
  data = Prawn::Icon::FontData.release_data
55
54
 
56
55
  expect(data).to be_empty
@@ -59,7 +58,7 @@ describe Prawn::Icon::FontData do
59
58
 
60
59
  describe '::unicode_from_key' do
61
60
  it 'should provide a UTF-8 string for a valid key' do
62
- unicode = Prawn::Icon::FontData.unicode_from_key(pdf, 'fa-arrows')
61
+ unicode = Prawn::Icon::FontData.unicode_from_key(pdf, 'far-address-book')
63
62
  valid = unicode.force_encoding('UTF-8').valid_encoding?
64
63
 
65
64
  expect(valid).to be true
@@ -68,8 +67,8 @@ describe Prawn::Icon::FontData do
68
67
 
69
68
  describe '::specifier_from_key' do
70
69
  it 'should provide the font specifier from a valid key' do
71
- specifier = Prawn::Icon::FontData.specifier_from_key('fa-arrows')
72
- expect(specifier).to eq(:fa)
70
+ specifier = Prawn::Icon::FontData.specifier_from_key('far-address-book')
71
+ expect(specifier).to eq(:far)
73
72
  end
74
73
 
75
74
  it 'should error when key is nil' do
@@ -129,13 +128,13 @@ describe Prawn::Icon::FontData do
129
128
  it 'should retrieve the string specifier from the yaml legend file' do
130
129
  specifier = fontawesome.specifier
131
130
 
132
- expect(specifier).to eq('fa')
131
+ expect(specifier).to eq('far')
133
132
  end
134
133
  end
135
134
 
136
135
  describe '#unicode' do
137
136
  it 'should provide a valid UTF-8 encoded string for a valid key' do
138
- unicode = fontawesome.unicode('arrows')
137
+ unicode = fontawesome.unicode('address-book')
139
138
  valid = unicode.force_encoding('UTF-8').valid_encoding?
140
139
 
141
140
  expect(valid).to be true
@@ -167,13 +166,13 @@ describe Prawn::Icon::FontData do
167
166
  it 'should return a hash with the specifier as the first key' do
168
167
  yaml = fontawesome.yaml
169
168
  key = yaml.keys.first
170
- mapping = yaml['fa']
169
+ mapping = yaml['far']
171
170
  inner_key = mapping.keys.last
172
171
  inner_value = mapping.values.last
173
172
  proc = Proc.new { inner_value.force_encoding('UTF-8').valid_encoding? }
174
173
 
175
174
  expect(yaml).to be_a(Hash)
176
- expect(key).to eq('fa')
175
+ expect(key).to eq('far')
177
176
  expect(inner_key).to be_a(String)
178
177
  expect(inner_value).to be_a(String)
179
178
  expect(proc.call).to be true
@@ -13,13 +13,13 @@ describe Prawn::Icon do
13
13
  describe '#initialize' do
14
14
  context 'valid icon family specifier' do
15
15
  it 'should be capable of creating icon instances' do
16
- icon = Prawn::Icon.new 'fa-arrows', pdf
16
+ icon = Prawn::Icon.new 'far-address-book', pdf
17
17
 
18
- expect(icon.unicode).to eq("\uf047")
18
+ expect(icon.unicode).to eq('')
19
19
  end
20
20
 
21
21
  it 'should raise an error if icon key is not found' do
22
- proc = Proc.new { Prawn::Icon.new 'fa-__INVALID__', pdf }
22
+ proc = Proc.new { Prawn::Icon.new 'far-__INVALID__', pdf }
23
23
 
24
24
  expect(proc).to raise_error(errors::IconNotFound)
25
25
  end
@@ -35,7 +35,7 @@ describe Prawn::Icon do
35
35
 
36
36
  context 'without a pdf object' do
37
37
  it 'should raise an ArgumentError' do
38
- proc = Proc.new { Prawn::Icon.new('fa-arrows') }
38
+ proc = Proc.new { Prawn::Icon.new('far-address-book') }
39
39
 
40
40
  expect(proc).to raise_error(ArgumentError)
41
41
  end
@@ -44,15 +44,15 @@ describe Prawn::Icon do
44
44
 
45
45
  describe '#format_hash' do
46
46
  it 'should add :font and :content keys' do
47
- icon = Prawn::Icon.new 'fa-arrows', pdf
47
+ icon = Prawn::Icon.new 'far-address-book', pdf
48
48
  hash = icon.format_hash
49
49
 
50
- expect(hash[:font]).to eq('fa')
51
- expect(hash[:content]).to eq("\uf047")
50
+ expect(hash[:font]).to eq('far')
51
+ expect(hash[:content]).to eq('')
52
52
  end
53
53
 
54
54
  it 'should rename key :color to :text_color' do
55
- icon = Prawn::Icon.new 'fa-arrows', pdf, color: '0099ff'
55
+ icon = Prawn::Icon.new 'far-address-book', pdf, color: '0099ff'
56
56
  hash = icon.format_hash
57
57
 
58
58
  expect(hash[:color]).to be_nil
@@ -62,7 +62,7 @@ describe Prawn::Icon do
62
62
 
63
63
  describe '#render' do
64
64
  it 'should render an icon to the page' do
65
- pdf.icon('fa-arrows').render
65
+ pdf.icon('far-address-book').render
66
66
  text = PDF::Inspector::Text.analyze(pdf.render)
67
67
 
68
68
  expect(text.font_settings.first[:name]).to match(/FontAwesome/)
@@ -72,9 +72,9 @@ describe Prawn::Icon do
72
72
  describe '#set' do
73
73
  context 'with dashes in key' do
74
74
  it 'should return the set as a symbol from key' do
75
- set = Prawn::Icon.new('fa-arrows', pdf).set
75
+ set = Prawn::Icon.new('far-address-book', pdf).set
76
76
 
77
- expect(set).to eq(:fa)
77
+ expect(set).to eq(:far)
78
78
  end
79
79
  end
80
80
 
@@ -90,7 +90,7 @@ describe Prawn::Icon do
90
90
  describe '#unicode' do
91
91
  context 'valid icon key' do
92
92
  it 'should return a unicode character' do
93
- icon = Prawn::Icon.new 'fa-arrows', pdf
93
+ icon = Prawn::Icon.new 'far-address-book', pdf
94
94
 
95
95
  expect(valid_unicode?(icon.unicode)).to be true
96
96
  end
@@ -98,10 +98,10 @@ describe Prawn::Icon do
98
98
 
99
99
  context 'invalid icon key' do
100
100
  it 'should raise IconNotFound' do
101
- proc = Proc.new { Prawn::Icon.new 'fa-__INVALID__', pdf }
101
+ proc = Proc.new { Prawn::Icon.new 'far-__INVALID__', pdf }
102
102
 
103
103
  expect(proc).to raise_error(errors::IconNotFound)
104
104
  end
105
105
  end
106
106
  end
107
- end
107
+ end
@@ -11,16 +11,16 @@ describe Prawn::Icon::Parser do
11
11
 
12
12
  describe '::format' do
13
13
  it 'should return a raw prawn-formatted string on valid input' do
14
- string = '<icon>fa-arrows</icon>'
14
+ string = '<icon>far-address-book</icon>'
15
15
  formatted = Prawn::Icon::Parser.format(pdf, string)
16
- match = "<font name=\"fa\"></font>"
16
+ match = '<font name="far"></font>'
17
17
 
18
18
  expect(formatted).to eq(match)
19
19
  end
20
20
 
21
21
  it 'should return unchanged if no icon tags are found' do
22
22
  string = <<-EOS
23
- <link href="#">test</link>
23
+ <link href='#'>test</link>
24
24
  Here's some sample text.
25
25
  <i>more text</i>
26
26
  EOS
@@ -44,7 +44,7 @@ describe Prawn::Icon::Parser do
44
44
  end
45
45
 
46
46
  it 'should raise an error when an icon is not found for valid set' do
47
- string = '<icon>fa-__INVALID__</icon>'
47
+ string = '<icon>far-__INVALID__</icon>'
48
48
  proc = Proc.new { Prawn::Icon::Parser.format(pdf, string) }
49
49
 
50
50
  expect(proc).to raise_error(Prawn::Icon::Errors::IconNotFound)
@@ -53,7 +53,7 @@ describe Prawn::Icon::Parser do
53
53
 
54
54
  describe '::config_from_tokens' do
55
55
  it 'should handle attrs with double quotes' do
56
- string = '<icon size="20">fa-arrows</icon>'
56
+ string = '<icon size="20">far-address-book</icon>'
57
57
  tokens = tokenize_string(string)
58
58
  config = Prawn::Icon::Parser.config_from_tokens(tokens)
59
59
  inner = config.first
@@ -62,7 +62,7 @@ describe Prawn::Icon::Parser do
62
62
  end
63
63
 
64
64
  it 'should handle attrs with single quotes' do
65
- string = "<icon size='20'>fa-arrows</icon>"
65
+ string = '<icon size="20">far-address-book</icon>'
66
66
  tokens = tokenize_string(string)
67
67
  config = Prawn::Icon::Parser.config_from_tokens(tokens)
68
68
  inner = config.first
@@ -71,7 +71,7 @@ describe Prawn::Icon::Parser do
71
71
  end
72
72
 
73
73
  it 'should handle both single/double quotes in same string' do
74
- string = '<icon color="0099FF" size=\'20\'>fa-arrows</icon>'
74
+ string = '<icon color="0099FF" size=\'20\'>far-address-book</icon>'
75
75
  tokens = tokenize_string(string)
76
76
  config = Prawn::Icon::Parser.config_from_tokens(tokens)
77
77
  inner = config.first
@@ -81,7 +81,7 @@ describe Prawn::Icon::Parser do
81
81
  end
82
82
 
83
83
  it 'should return an array containing only an empty hash' do
84
- string = '<icon>fa-arrows</icon>'
84
+ string = '<icon>far-address-book</icon>'
85
85
  tokens = tokenize_string(string)
86
86
  config = Prawn::Icon::Parser.config_from_tokens(tokens)
87
87
  inner = config.first
@@ -91,7 +91,7 @@ describe Prawn::Icon::Parser do
91
91
  end
92
92
 
93
93
  it 'should return an array containing a single hash of attrs' do
94
- string = '<icon size="12" color="CCCCCC">fa-arrows</icon>'
94
+ string = '<icon size="12" color="CCCCCC">far-address-book</icon>'
95
95
  tokens = tokenize_string(string)
96
96
  config = Prawn::Icon::Parser.config_from_tokens(tokens)
97
97
  inner = config.first
@@ -103,9 +103,9 @@ describe Prawn::Icon::Parser do
103
103
 
104
104
  it 'should return an array containing as many hashes as icons' do
105
105
  string = <<-EOS
106
- <icon>fa-arrows</icon>
107
- <icon>fa-arrows</icon>
108
- <icon>fa-arrows</icon>
106
+ <icon>far-address-book</icon>
107
+ <icon>far-address-book</icon>
108
+ <icon>far-address-book</icon>
109
109
  EOS
110
110
  tokens = tokenize_string(string)
111
111
  config = Prawn::Icon::Parser.config_from_tokens(tokens)
@@ -125,7 +125,7 @@ describe Prawn::Icon::Parser do
125
125
  end
126
126
 
127
127
  it 'should return an array with unicode content' do
128
- string = '<icon>fa-arrows</icon>'
128
+ string = '<icon>far-address-book</icon>'
129
129
  tokens = tokenize_string(string)
130
130
  content = contentize_string(string)
131
131
  config = Prawn::Icon::Parser.config_from_tokens(tokens)
@@ -137,23 +137,23 @@ describe Prawn::Icon::Parser do
137
137
 
138
138
  it 'should return a single array containing attr hash of defaults' do
139
139
  # Hash must contain :set and :content by default
140
- string = '<icon>fa-arrows</icon>'
140
+ string = '<icon>far-address-book</icon>'
141
141
  tokens = tokenize_string(string)
142
142
  content = contentize_string(string)
143
143
  config = Prawn::Icon::Parser.config_from_tokens(tokens)
144
144
  icons = Prawn::Icon::Parser.keys_to_unicode(pdf, content, config)
145
145
  icon = icons.first
146
146
 
147
- expect(icon[:set]).to eq(:fa)
147
+ expect(icon[:set]).to eq(:far)
148
148
  expect(icon[:content]).not_to be_empty
149
149
  end
150
150
 
151
151
  it 'should handle strings with multiple icons/attrs combinations' do
152
152
  string = <<-EOS
153
- <icon size="20">fa-arrows</icon>
153
+ <icon size='20'>far-address-book</icon>
154
154
  some filler text
155
- <icon>fa-arrows</icon>
156
- <icon size="8" color="0099FF">fa-arrows</icon>
155
+ <icon>far-address-book</icon>
156
+ <icon size='8' color='0099FF'>far-address-book</icon>
157
157
  EOS
158
158
  tokens = tokenize_string(string)
159
159
  content = contentize_string(string)
@@ -177,12 +177,12 @@ describe Prawn::Icon::Parser do
177
177
  context 'with color attribute' do
178
178
  let(:icons) do
179
179
  [
180
- { set: :fa, color: 'CCCCCC', content: "\uf001" }
180
+ { set: :far, color: 'CCCCCC', content: '' }
181
181
  ]
182
182
  end
183
183
 
184
184
  it 'should return valid input as prawn formatted text tags wrapping color tags' do
185
- match = "<font name=\"fa\"><color rgb=\"CCCCCC\">\uf001</color></font>"
185
+ match = '<font name="far"><color rgb="CCCCCC"></color></font>'
186
186
 
187
187
  expect(tags).to eq([match])
188
188
  end
@@ -191,12 +191,12 @@ describe Prawn::Icon::Parser do
191
191
  context 'without the color attribute' do
192
192
  let(:icons) do
193
193
  [
194
- { set: :fa, content: "\uf001" }
194
+ { set: :far, content: '' }
195
195
  ]
196
196
  end
197
197
 
198
198
  it 'should return valid input as prawn formatted text tags without color' do
199
- match = "<font name=\"fa\">\uf001</font>"
199
+ match = '<font name="far"></font>'
200
200
 
201
201
  expect(tags).to eq([match])
202
202
  end
@@ -205,14 +205,14 @@ describe Prawn::Icon::Parser do
205
205
  context 'with multiple icon fonts' do
206
206
  let(:icons) do
207
207
  [
208
- { set: :fa, content: "\uf001" },
209
- { set: :fi, content: "\uf001" }
208
+ { set: :far, content: '' },
209
+ { set: :fi, content: '\uf001' }
210
210
  ]
211
211
  end
212
212
 
213
213
  it 'should be capable of handling multiple icon fonts' do
214
- match1 = "<font name=\"fa\">\uf001</font>"
215
- match2 = "<font name=\"fi\">\uf001</font>"
214
+ match1 = '<font name="far"></font>'
215
+ match2 = '<font name="fi">\uf001</font>'
216
216
 
217
217
  expect(tags).to eq([match1, match2])
218
218
  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: 1.3.0
4
+ version: 2.0.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: 2016-10-15 00:00:00.000000000 Z
11
+ date: 2018-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn
@@ -34,28 +34,28 @@ dependencies:
34
34
  name: pdf-inspector
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - "~>"
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: 1.2.1
40
40
  type: :development
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - "~>"
44
+ - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: 1.2.1
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - "~>"
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: 3.5.0
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - "~>"
58
+ - - ">="
59
59
  - !ruby/object:Gem::Version
60
60
  version: 3.5.0
61
61
  - !ruby/object:Gem::Dependency
@@ -64,14 +64,14 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: 0.44.1
67
+ version: 0.49.1
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: 0.44.1
74
+ version: 0.49.1
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: rake
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -90,33 +90,33 @@ dependencies:
90
90
  name: pdf-reader
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
- - - "~>"
93
+ - - ">="
94
94
  - !ruby/object:Gem::Version
95
95
  version: '1.4'
96
96
  type: :development
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
- - - "~>"
100
+ - - ">="
101
101
  - !ruby/object:Gem::Version
102
102
  version: '1.4'
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: simplecov
105
105
  requirement: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - "~>"
107
+ - - ">="
108
108
  - !ruby/object:Gem::Version
109
- version: '0.12'
109
+ version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
112
  version_requirements: !ruby/object:Gem::Requirement
113
113
  requirements:
114
- - - "~>"
114
+ - - ">="
115
115
  - !ruby/object:Gem::Version
116
- version: '0.12'
116
+ version: '0'
117
117
  description: |2
118
118
  Prawn::Icon provides various icon fonts including
119
- FontAwesome, Foundation Icons and GitHub Octicons
119
+ FontAwesome, PaymentFont and Foundation Icons
120
120
  for use with the Prawn PDF toolkit.
121
121
  email:
122
122
  - jdoyle@ualberta.ca
@@ -133,24 +133,26 @@ files:
133
133
  - README.md
134
134
  - Rakefile
135
135
  - data/fonts/DejaVuSans.ttf
136
- - data/fonts/fa/LICENSE
137
- - data/fonts/fa/fa.yml
138
- - data/fonts/fa/fontawesome.ttf
136
+ - data/fonts/fab/LICENSE
137
+ - data/fonts/fab/fa-brands.ttf
138
+ - data/fonts/fab/fab.yml
139
+ - data/fonts/far/LICENSE
140
+ - data/fonts/far/fa-regular.ttf
141
+ - data/fonts/far/far.yml
142
+ - data/fonts/fas/LICENSE
143
+ - data/fonts/fas/fa-solid.ttf
144
+ - data/fonts/fas/fas.yml
139
145
  - data/fonts/fi/LICENSE
140
146
  - data/fonts/fi/fi.yml
141
147
  - data/fonts/fi/foundation-icons.ttf
142
- - data/fonts/octicon/LICENSE
143
- - data/fonts/octicon/octicon.yml
144
- - data/fonts/octicon/octicons.ttf
145
148
  - data/fonts/pf/LICENSE
146
149
  - data/fonts/pf/paymentfont-webfont.ttf
147
150
  - data/fonts/pf/pf.yml
148
151
  - examples/example_helper.rb
149
- - examples/fa-beer-inline.png
150
- - examples/fa-beer.png
152
+ - examples/fas-beer-inline.png
153
+ - examples/fas-beer.png
151
154
  - examples/fontawesome.rb
152
155
  - examples/foundation_icons.rb
153
- - examples/octicons.rb
154
156
  - examples/paymentfont.rb
155
157
  - lib/prawn/icon.rb
156
158
  - lib/prawn/icon/base.rb
@@ -192,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
194
  version: 1.3.6
193
195
  requirements: []
194
196
  rubyforge_project:
195
- rubygems_version: 2.5.2
197
+ rubygems_version: 2.5.1
196
198
  signing_key:
197
199
  specification_version: 4
198
200
  summary: Provides icon fonts for PrawnPDF