prawn-icon 2.1.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,12 +4,31 @@
4
4
  #
5
5
  # This is free software. Please see the LICENSE and COPYING files for details.
6
6
 
7
- describe Prawn::Icon::Base do
8
- describe 'FONTDIR' do
9
- it 'returns the data/fonts directory' do
10
- path = File.expand_path '../../..', __FILE__
11
- path = File.join path, 'data/fonts'
12
- expect(Prawn::Icon::Base::FONTDIR).to eq(path)
7
+ describe Prawn::Icon do
8
+ describe '#configuration' do
9
+ it 'returns an instance of Prawn::Icon::Configuration' do
10
+ expect(described_class.configuration).to be_a(Prawn::Icon::Configuration)
11
+ end
12
+ end
13
+
14
+ describe '#configure' do
15
+ around(:each) do |example|
16
+ old = described_class.configuration.dup
17
+ described_class.configure do |config|
18
+ config.font_directory = '/tmp/fonts'
19
+ end
20
+ example.run
21
+ described_class.configuration = old
22
+ end
23
+
24
+ it 'yields control' do
25
+ expect { |b| described_class.configure(&b) }.to yield_control
26
+ end
27
+
28
+ it 'configures properties' do
29
+ expect(described_class.configuration.font_directory).to eq(
30
+ Pathname.new('/tmp/fonts')
31
+ )
13
32
  end
14
33
  end
15
34
  end
@@ -0,0 +1,21 @@
1
+ # encoding: utf-8
2
+ #
3
+ # Copyright October 2020, Jesse Doyle. All rights reserved.
4
+ #
5
+ # This is free software. Please see the LICENSE and COPYING files for details.
6
+
7
+ describe Prawn::Icon::Configuration do
8
+ describe '#font_directory' do
9
+ before(:each) do
10
+ subject.font_directory = '/tmp/fakedir'
11
+ end
12
+
13
+ it 'returns a Pathname' do
14
+ expect(subject.font_directory).to be_a(Pathname)
15
+ end
16
+
17
+ it 'returns the configured path' do
18
+ expect(subject.font_directory.to_s).to eq('/tmp/fakedir')
19
+ end
20
+ end
21
+ end
@@ -12,8 +12,6 @@ describe Prawn::Icon::Errors::IconKeyEmpty do
12
12
  end
13
13
 
14
14
  it 'is thrown on a missing icon key' do
15
- proc = Proc.new { pdf.icon '' }
16
-
17
- expect(proc).to raise_error(described_class)
15
+ expect { pdf.icon('') }.to raise_error(described_class)
18
16
  end
19
17
  end
@@ -12,8 +12,6 @@ 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 'far-an invalid key' }
16
-
17
- expect(proc).to raise_error(described_class)
15
+ expect { pdf.icon('far-an invalid key') }.to raise_error(described_class)
18
16
  end
19
17
  end
@@ -72,15 +72,15 @@ describe Prawn::Icon::FontData do
72
72
  end
73
73
 
74
74
  it 'should error when key is nil' do
75
- proc = Proc.new { Prawn::Icon::FontData.specifier_from_key nil }
76
-
77
- expect(proc).to raise_error(Prawn::Icon::Errors::IconKeyEmpty)
75
+ expect { Prawn::Icon::FontData.specifier_from_key(nil) }.to raise_error(
76
+ Prawn::Icon::Errors::IconKeyEmpty
77
+ )
78
78
  end
79
79
 
80
80
  it 'should error when key is an empty string' do
81
- proc = Proc.new { Prawn::Icon::FontData.specifier_from_key '' }
82
-
83
- expect(proc).to raise_error(Prawn::Icon::Errors::IconKeyEmpty)
81
+ expect { Prawn::Icon::FontData.specifier_from_key('') }.to raise_error(
82
+ Prawn::Icon::Errors::IconKeyEmpty
83
+ )
84
84
  end
85
85
 
86
86
  it 'should handle strings without any dashes properly' do
@@ -141,9 +141,9 @@ describe Prawn::Icon::FontData do
141
141
  end
142
142
 
143
143
  it 'should raise an error if unable to match a key' do
144
- proc = Proc.new { fontawesome.unicode('an invalid sequence') }
145
-
146
- expect(proc).to raise_error(Prawn::Icon::Errors::IconNotFound)
144
+ expect { fontawesome.unicode('an invalid sequence') }.to raise_error(
145
+ Prawn::Icon::Errors::IconNotFound
146
+ )
147
147
  end
148
148
  end
149
149
 
@@ -19,25 +19,25 @@ describe Prawn::Icon do
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 'far-__INVALID__', pdf }
23
-
24
- expect(proc).to raise_error(errors::IconNotFound)
22
+ expect { Prawn::Icon.new('far-__INVALID__', pdf) }.to raise_error(
23
+ errors::IconNotFound
24
+ )
25
25
  end
26
26
  end
27
27
 
28
28
  context 'invalid icon specifier' do
29
29
  it 'should raise an error' do
30
- proc = Proc.new { pdf.icon '__INVALID__ some text' }
31
-
32
- expect(proc).to raise_error(Prawn::Errors::UnknownFont)
30
+ expect { pdf.icon('__INVALID__ some text') }.to raise_error(
31
+ Prawn::Errors::UnknownFont
32
+ )
33
33
  end
34
34
  end
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('far-address-book') }
39
-
40
- expect(proc).to raise_error(ArgumentError)
38
+ expect { Prawn::Icon.new('far-address-book') }.to raise_error(
39
+ ArgumentError
40
+ )
41
41
  end
42
42
  end
43
43
  end
@@ -80,9 +80,9 @@ describe Prawn::Icon do
80
80
 
81
81
  context 'without dashes in key' do
82
82
  it 'raise an error about invalid keys' do
83
- proc = Proc.new { Prawn::Icon.new 'some invalid key', pdf }
84
-
85
- expect(proc).to raise_error(Prawn::Errors::UnknownFont)
83
+ expect { Prawn::Icon.new('some invalid key', pdf) }.to raise_error(
84
+ Prawn::Errors::UnknownFont
85
+ )
86
86
  end
87
87
  end
88
88
  end
@@ -98,9 +98,9 @@ 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 'far-__INVALID__', pdf }
102
-
103
- expect(proc).to raise_error(errors::IconNotFound)
101
+ expect { Prawn::Icon.new('far-__INVALID__', pdf) }.to raise_error(
102
+ errors::IconNotFound
103
+ )
104
104
  end
105
105
  end
106
106
  end
@@ -38,16 +38,18 @@ describe Prawn::Icon::Parser do
38
38
 
39
39
  it 'should raise an error when an icon key is invalid' do
40
40
  string = '<icon>an invalid key</icon>'
41
- proc = Proc.new { Prawn::Icon::Parser.format(pdf, string) }
42
41
 
43
- expect(proc).to raise_error(Prawn::Errors::UnknownFont)
42
+ expect { Prawn::Icon::Parser.format(pdf, string) }.to raise_error(
43
+ Prawn::Errors::UnknownFont
44
+ )
44
45
  end
45
46
 
46
47
  it 'should raise an error when an icon is not found for valid set' do
47
48
  string = '<icon>far-__INVALID__</icon>'
48
- proc = Proc.new { Prawn::Icon::Parser.format(pdf, string) }
49
49
 
50
- expect(proc).to raise_error(Prawn::Icon::Errors::IconNotFound)
50
+ expect { Prawn::Icon::Parser.format(pdf, string) }.to raise_error(
51
+ Prawn::Icon::Errors::IconNotFound
52
+ )
51
53
  end
52
54
  end
53
55
 
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: 2.1.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jesse Doyle
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-02 00:00:00.000000000 Z
11
+ date: 2020-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn
@@ -133,6 +133,7 @@ files:
133
133
  - README.md
134
134
  - Rakefile
135
135
  - data/fonts/DejaVuSans.ttf
136
+ - data/fonts/fa4/shims.yml
136
137
  - data/fonts/fab/LICENSE
137
138
  - data/fonts/fab/fa-brands.ttf
138
139
  - data/fonts/fab/fab.yml
@@ -157,6 +158,7 @@ files:
157
158
  - lib/prawn/icon.rb
158
159
  - lib/prawn/icon/base.rb
159
160
  - lib/prawn/icon/compatibility.rb
161
+ - lib/prawn/icon/configuration.rb
160
162
  - lib/prawn/icon/errors.rb
161
163
  - lib/prawn/icon/font_data.rb
162
164
  - lib/prawn/icon/interface.rb
@@ -169,6 +171,7 @@ files:
169
171
  - spec/support/pdf_helper.rb
170
172
  - spec/unit/base_spec.rb
171
173
  - spec/unit/compatibility_spec.rb
174
+ - spec/unit/configuration_spec.rb
172
175
  - spec/unit/errors/icon_key_empty_spec.rb
173
176
  - spec/unit/errors/icon_not_found_spec.rb
174
177
  - spec/unit/font_data_spec.rb
@@ -180,7 +183,7 @@ licenses:
180
183
  - GPL-2
181
184
  - GPL-3
182
185
  metadata: {}
183
- post_install_message:
186
+ post_install_message:
184
187
  rdoc_options: []
185
188
  require_paths:
186
189
  - lib
@@ -195,9 +198,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
198
  - !ruby/object:Gem::Version
196
199
  version: 1.3.6
197
200
  requirements: []
198
- rubyforge_project:
199
- rubygems_version: 2.5.1
200
- signing_key:
201
+ rubygems_version: 3.1.2
202
+ signing_key:
201
203
  specification_version: 4
202
204
  summary: Provides icon fonts for PrawnPDF
203
205
  test_files: []