prawn-icon 1.0.0 → 1.1.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: 8889719da10fa88779b85044ad4e21cefba4b626
4
- data.tar.gz: 538526d331c869244c668b9f4646d16cc8072028
3
+ metadata.gz: 60c827fe1c0063f5a64c2d1a4f19df456880b407
4
+ data.tar.gz: 7e4d155380ff3e6266d78ecb35532b29d05f3afd
5
5
  SHA512:
6
- metadata.gz: 4c8c174bc49dbbb3ab8ca16755b932f483cdbe50539d55b8705c6a79c0ad466bcf6c7a5ef9d61d1aea827bc037e7f2a838e12841a0afb5d3ae2bdc1a6464cf6d
7
- data.tar.gz: d3960939db1027e38f079a31bde2eac6d9d70d4ea05045e2a2e7447cfd1c17c5cb299285d863ae6986dfe4f2c38eb73ac023d5a26dc3374de562f1a276b31b66
6
+ metadata.gz: b27500edce7d1a45e4a51dfd135d3de5212a662509ffaff488aa7a9ec7dd99f7a8643f0da34e272cdb7bd97a6b2c69a14512e628fab6397c0e0bbc6f581529c2
7
+ data.tar.gz: d85b373423054100048ac6e9113f589a13e2de5563d2115a98457fc426206ac07a2b34326c169de4dc1bd40bccb3007400e4429ec2bb1cd10c8c938989debd35
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # 1.1.0 - March 16, 2016
2
+
3
+ - Update FontAwesome from v4.4.0 to v4.5.0. See [changelog](http://fontawesome.io/icons#new).
4
+ - Refactor specs to use `expect(foo).to be true` over `expect(foo).to be_true`.
5
+ - Update development dependencies to latest.
6
+
1
7
  # 1.0.0 - September 9, 2015
2
8
 
3
9
  - *(breaking change)* Updated Octicons from v2.4.1 to v3.1.0.
data/data/fonts/fa/fa.yml CHANGED
@@ -75,6 +75,8 @@ fa:
75
75
  bitbucket-square: "\uf172"
76
76
  bitcoin: "\uf15a"
77
77
  black-tie: "\uf27e"
78
+ bluetooth: "\uf293"
79
+ bluetooth-b: "\uf294"
78
80
  bold: "\uf032"
79
81
  bolt: "\uf0e7"
80
82
  bomb: "\uf1e2"
@@ -153,6 +155,7 @@ fa:
153
155
  code: "\uf121"
154
156
  code-fork: "\uf126"
155
157
  codepen: "\uf1cb"
158
+ codiepie: "\uf284"
156
159
  coffee: "\uf0f4"
157
160
  cog: "\uf013"
158
161
  cogs: "\uf085"
@@ -171,6 +174,7 @@ fa:
171
174
  copyright: "\uf1f9"
172
175
  creative-commons: "\uf25e"
173
176
  credit-card: "\uf09d"
177
+ credit-card-alt: "\uf283"
174
178
  crop: "\uf125"
175
179
  crosshairs: "\uf05b"
176
180
  css3: "\uf13c"
@@ -193,6 +197,7 @@ fa:
193
197
  dribbble: "\uf17d"
194
198
  dropbox: "\uf16b"
195
199
  drupal: "\uf1a9"
200
+ edge: "\uf282"
196
201
  edit: "\uf044"
197
202
  eject: "\uf052"
198
203
  ellipsis-h: "\uf141"
@@ -264,6 +269,7 @@ fa:
264
269
  fonticons: "\uf280"
265
270
  forumbee: "\uf211"
266
271
  forward: "\uf04e"
272
+ fort-awesome: "\uf286"
267
273
  foursquare: "\uf180"
268
274
  frown-o: "\uf119"
269
275
  futbol-o: "\uf1e3"
@@ -308,6 +314,7 @@ fa:
308
314
  hand-scissors-o: "\uf257"
309
315
  hand-spock-o: "\uf259"
310
316
  hand-stop-o: "\uf256"
317
+ hashtag: "\uf292"
311
318
  hdd-o: "\uf0a0"
312
319
  header: "\uf1dc"
313
320
  headphones: "\uf025"
@@ -407,8 +414,10 @@ fa:
407
414
  minus-circle: "\uf056"
408
415
  minus-square: "\uf146"
409
416
  minus-square-o: "\uf147"
417
+ mixcloud: "\uf289"
410
418
  mobile: "\uf10b"
411
419
  mobile-phone: "\uf10b"
420
+ modx: "\uf285"
412
421
  money: "\uf0d6"
413
422
  moon-o: "\uf186"
414
423
  mortar-board: "\uf19d"
@@ -435,11 +444,14 @@ fa:
435
444
  paragraph: "\uf1dd"
436
445
  paste: "\uf0ea"
437
446
  pause: "\uf04c"
447
+ pause-circle: "\uf28b"
448
+ pause-circle-o: "\uf28c"
438
449
  paw: "\uf1b0"
439
450
  paypal: "\uf1ed"
440
451
  pencil: "\uf040"
441
452
  pencil-square: "\uf14b"
442
453
  pencil-square-o: "\uf044"
454
+ percent: "\uf295"
443
455
  phone: "\uf095"
444
456
  phone-square: "\uf098"
445
457
  photo: "\uf03e"
@@ -461,6 +473,7 @@ fa:
461
473
  plus-square-o: "\uf196"
462
474
  power-off: "\uf011"
463
475
  print: "\uf02f"
476
+ product-hunt: "\uf288"
464
477
  puzzle-piece: "\uf12e"
465
478
  qq: "\uf1d6"
466
479
  qrcode: "\uf029"
@@ -473,6 +486,7 @@ fa:
473
486
  rebel: "\uf1d0"
474
487
  recycle: "\uf1b8"
475
488
  reddit: "\uf1a1"
489
+ reddit-alien: "\uf281"
476
490
  reddit-square: "\uf1a2"
477
491
  refresh: "\uf021"
478
492
  registered: "\uf25d"
@@ -497,6 +511,7 @@ fa:
497
511
  safari: "\uf267"
498
512
  save: "\uf0c7"
499
513
  scissors: "\uf0c4"
514
+ scribd: "\uf28a"
500
515
  search: "\uf002"
501
516
  search-minus: "\uf010"
502
517
  search-plus: "\uf00e"
@@ -514,6 +529,8 @@ fa:
514
529
  shield: "\uf132"
515
530
  ship: "\uf21a"
516
531
  shirtsinbulk: "\uf214"
532
+ shopping-bag: "\uf290"
533
+ shopping-basket: "\uf291"
517
534
  shopping-cart: "\uf07a"
518
535
  sign-in: "\uf090"
519
536
  sign-out: "\uf08b"
@@ -561,6 +578,8 @@ fa:
561
578
  sticky-note: "\uf249"
562
579
  sticky-note-o: "\uf24a"
563
580
  stop: "\uf04d"
581
+ stop-circle: "\uf28d"
582
+ stop-circle-o: "\uf28e"
564
583
  street-view: "\uf21d"
565
584
  strikethrough: "\uf0cc"
566
585
  stumbleupon: "\uf1a4"
@@ -631,6 +650,7 @@ fa:
631
650
  unlock-alt: "\uf13e"
632
651
  unsorted: "\uf0dc"
633
652
  upload: "\uf093"
653
+ usb: "\uf287"
634
654
  usd: "\uf155"
635
655
  user: "\uf007"
636
656
  user-md: "\uf0f0"
Binary file
data/lib/prawn/icon.rb CHANGED
@@ -78,9 +78,7 @@ module Prawn
78
78
  # inline_format: true
79
79
  #
80
80
  def icon(key, opts = {})
81
- i = make_icon(key, opts)
82
- i.render
83
- i
81
+ make_icon(key, opts).tap(&:render)
84
82
  end
85
83
 
86
84
  # Initialize a new icon object, but do
@@ -79,14 +79,12 @@ module Prawn
79
79
  end
80
80
 
81
81
  def unicode(key)
82
- char = yaml[specifier][key]
83
-
84
- unless char
85
- raise Prawn::Errors::IconNotFound,
86
- "Key: #{specifier}-#{key} not found"
82
+ yaml[specifier][key].tap do |char|
83
+ unless char
84
+ raise Prawn::Errors::IconNotFound,
85
+ "Key: #{specifier}-#{key} not found"
86
+ end
87
87
  end
88
-
89
- char
90
88
  end
91
89
 
92
90
  def keys
@@ -49,77 +49,69 @@ module Prawn
49
49
  icons = keys_to_unicode(document, content, config)
50
50
  tags = icon_tags(icons)
51
51
 
52
- string.gsub(TAG_REGEX).with_index do |_, i|
53
- tags[i]
54
- end
52
+ string.gsub(TAG_REGEX).with_index { |_, i| tags[i] }
55
53
  end
56
54
 
57
55
  def config_from_tokens(tokens)
58
- array = []
59
-
60
- tokens.each do |token|
61
- # Skip the closing tag
62
- next if token =~ /<\/icon>/i
63
- icon = {}
64
-
65
- # Convert [[1,2], [3,4]] to { :1 => 2, :3 => 4 }
66
- attrs = token.scan(ATTR_REGEX).inject({}) do |k, v|
67
- val = attr_hash(v)
68
- k.merge!(val)
56
+ [].tap do |array|
57
+ tokens.each do |token|
58
+ # Skip the closing tag
59
+ next if token =~ /<\/icon>/i
60
+ icon = {}
61
+
62
+ # Convert [[1,2], [3,4]] to { :1 => 2, :3 => 4 }
63
+ attrs = token.scan(ATTR_REGEX).inject({}) do |k, v|
64
+ val = attr_hash(v)
65
+ k.merge!(val)
66
+ end
67
+
68
+ icon.merge!(attrs)
69
+ array << icon
69
70
  end
70
-
71
- icon.merge!(attrs)
72
- array << icon
73
71
  end
74
-
75
- array
76
72
  end
77
73
 
78
74
  def icon_tags(icons)
79
- tags = []
75
+ [].tap do |tags|
76
+ icons.each do |icon|
77
+ # Mandatory
78
+ content = icon[:content]
79
+ set = icon[:set]
80
80
 
81
- icons.each do |icon|
82
- # Mandatory
83
- content = icon[:content]
84
- set = icon[:set]
81
+ # Optional
82
+ color = icon[:color]
83
+ size = icon[:size]
85
84
 
86
- # Optional
87
- color = icon[:color]
88
- size = icon[:size]
85
+ opening = "<font name=\"#{set}\""
89
86
 
90
- opening = "<font name=\"#{set}\""
87
+ unless color || size
88
+ tags << "#{opening}>#{content}</font>"
89
+ next
90
+ end
91
91
 
92
- unless color || size
93
- tags << "#{opening}>#{content}</font>"
94
- next
95
- end
92
+ opening += " size=\"#{size}\"" if size
93
+ content = "<color rgb=\"#{color}\">#{content}</color>" if color
96
94
 
97
- opening += " size=\"#{size}\"" if size
98
- content = "<color rgb=\"#{color}\">#{content}</color>" if color
99
-
100
- opening += '>'
101
- tags << "#{opening}#{content}</font>"
95
+ opening += '>'
96
+ tags << "#{opening}#{content}</font>"
97
+ end
102
98
  end
103
-
104
- tags
105
99
  end
106
100
 
107
101
  def keys_to_unicode(document, content, config)
108
- icons = []
109
-
110
- content.each_with_index do |icon, index|
111
- options ||= {}
112
- options = config[index] if config.any?
113
- info = {
114
- set: FontData.specifier_from_key(icon),
115
- size: options[:size],
116
- color: options[:color],
117
- content: FontData.unicode_from_key(document, icon)
118
- }
119
- icons << info
102
+ [].tap do |icons|
103
+ content.each_with_index do |icon, index|
104
+ options ||= {}
105
+ options = config[index] if config.any?
106
+ info = {
107
+ set: FontData.specifier_from_key(icon),
108
+ size: options[:size],
109
+ color: options[:color],
110
+ content: FontData.unicode_from_key(document, icon)
111
+ }
112
+ icons << info
113
+ end
120
114
  end
121
-
122
- icons
123
115
  end
124
116
 
125
117
  private
@@ -8,6 +8,6 @@
8
8
 
9
9
  module Prawn
10
10
  class Icon
11
- VERSION = '1.0.0'.freeze
11
+ VERSION = '1.1.0'.freeze
12
12
  end
13
13
  end
data/prawn-icon.gemspec CHANGED
@@ -7,9 +7,9 @@ Gem::Specification.new do |spec|
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.summary = 'Provides icon fonts for PrawnPDF'
9
9
  spec.files = Dir.glob('{lib,spec,data,examples}/**/**/*') +
10
- %w(prawn-icon.gemspec Gemfile Rakefile) +
11
- %w(README.md CHANGELOG.md) +
12
- %w(COPYING LICENSE GPLv2 GPLv3)
10
+ %w(prawn-icon.gemspec Gemfile Rakefile) +
11
+ %w(README.md CHANGELOG.md) +
12
+ %w(COPYING LICENSE GPLv2 GPLv3)
13
13
 
14
14
  spec.require_path = 'lib'
15
15
  spec.required_ruby_version = '>= 1.9.3'
@@ -24,13 +24,13 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_dependency('prawn', '>= 1.1.0', '< 3.0.0')
26
26
 
27
- spec.add_development_dependency('pdf-inspector', '~> 1.1.0')
28
- spec.add_development_dependency('rspec', '~>2.14.1')
29
- spec.add_development_dependency('rubocop', '~>0.27.0')
27
+ spec.add_development_dependency('pdf-inspector', '~> 1.2.1')
28
+ spec.add_development_dependency('rspec', '~> 3.4.0')
29
+ spec.add_development_dependency('rubocop', '~> 0.38.0')
30
30
  spec.add_development_dependency('mocha')
31
31
  spec.add_development_dependency('rake')
32
32
  spec.add_development_dependency('simplecov')
33
- spec.add_development_dependency('pdf-reader', '~>1.2')
33
+ spec.add_development_dependency('pdf-reader', '~> 1.4')
34
34
 
35
35
  spec.description = <<-END_DESC
36
36
  Prawn::Icon provides various icon fonts including
@@ -120,7 +120,7 @@ describe Prawn::Icon::Interface do
120
120
 
121
121
  expect(icon.class).to eq(Hash)
122
122
  expect(icon[:content]).to eq('<font name="fa"></font>')
123
- expect(icon[:inline_format]).to be_true
123
+ expect(icon[:inline_format]).to be true
124
124
  end
125
125
 
126
126
  it 'should ignore all other tags' do
@@ -130,7 +130,7 @@ describe Prawn::Icon::Interface do
130
130
 
131
131
  expect(icon.class).to eq(Hash)
132
132
  expect(icon[:content]).to eq(a[0])
133
- expect(icon[:inline_format]).to be_true
133
+ expect(icon[:inline_format]).to be true
134
134
  end
135
135
 
136
136
  context 'multiple icons' do
@@ -142,7 +142,7 @@ describe Prawn::Icon::Interface do
142
142
 
143
143
  expect(icon.class).to eq(Hash)
144
144
  expect(icon[:content]).to eq(out)
145
- expect(icon[:inline_format]).to be_true
145
+ expect(icon[:inline_format]).to be true
146
146
  end
147
147
  end
148
148
  end
@@ -60,7 +60,7 @@ describe Prawn::Icon::FontData do
60
60
  unicode = Prawn::Icon::FontData.unicode_from_key(pdf, 'fa-arrows')
61
61
  valid = unicode.force_encoding('UTF-8').valid_encoding?
62
62
 
63
- expect(valid).to be_true
63
+ expect(valid).to be true
64
64
  end
65
65
  end
66
66
 
@@ -95,7 +95,7 @@ describe Prawn::Icon::FontData do
95
95
  data = Prawn::Icon::FontData.new(pdf)
96
96
  version = data.font_version
97
97
 
98
- expect(version.is_a? String).to be_true
98
+ expect(version.is_a? String).to be true
99
99
  end
100
100
  end
101
101
 
@@ -116,7 +116,7 @@ describe Prawn::Icon::FontData do
116
116
  data = Prawn::Icon::FontData.new(pdf)
117
117
  ret_val = data.load_fonts(pdf)
118
118
 
119
- expect(ret_val.is_a? Prawn::Icon::FontData).to be_true
119
+ expect(ret_val.is_a? Prawn::Icon::FontData).to be true
120
120
  end
121
121
  end
122
122
 
@@ -148,7 +148,7 @@ describe Prawn::Icon::FontData do
148
148
  unicode = data.unicode('arrows')
149
149
  valid = unicode.force_encoding('UTF-8').valid_encoding?
150
150
 
151
- expect(valid).to be_true
151
+ expect(valid).to be true
152
152
  end
153
153
 
154
154
  it 'should raise an error if unable to match a key' do
@@ -167,7 +167,7 @@ describe Prawn::Icon::FontData do
167
167
  keys = data.keys
168
168
 
169
169
  expect(keys).not_to be_empty
170
- expect(keys.first.is_a? String).to be_true
170
+ expect(keys.first.is_a? String).to be true
171
171
  end
172
172
 
173
173
  it 'should not contain the version as a key' do
@@ -175,7 +175,7 @@ describe Prawn::Icon::FontData do
175
175
  data = Prawn::Icon::FontData.new(pdf, set: :fa)
176
176
  keys = data.keys
177
177
 
178
- expect(keys.include?('__font_version__')).to be_false
178
+ expect(keys.include?('__font_version__')).to be false
179
179
  end
180
180
  end
181
181
 
@@ -190,11 +190,11 @@ describe Prawn::Icon::FontData do
190
190
  inner_value = mapping.values.last
191
191
  proc = Proc.new { inner_value.force_encoding('UTF-8').valid_encoding? }
192
192
 
193
- expect(yaml.is_a? Hash).to be_true
193
+ expect(yaml.is_a? Hash).to be true
194
194
  expect(key).to eq('fa')
195
- expect(inner_key.is_a? String).to be_true
196
- expect(inner_value.is_a? String).to be_true
197
- expect(proc).to be_true
195
+ expect(inner_key.is_a? String).to be true
196
+ expect(inner_value.is_a? String).to be true
197
+ expect(proc.call).to be true
198
198
  end
199
199
  end
200
200
  end
@@ -98,7 +98,7 @@ describe Prawn::Icon do
98
98
  pdf = create_pdf
99
99
  icon = Prawn::Icon.new 'fa-arrows', pdf
100
100
 
101
- expect(valid_unicode?(icon.unicode)).to be_true
101
+ expect(valid_unicode?(icon.unicode)).to be true
102
102
  end
103
103
  end
104
104
 
@@ -137,7 +137,7 @@ describe Prawn::Icon::Parser do
137
137
  icons = Prawn::Icon::Parser.keys_to_unicode(pdf, content, config)
138
138
  icon = icons.first[:content]
139
139
 
140
- expect(valid_unicode?(icon)).to be_true
140
+ expect(valid_unicode?(icon)).to be true
141
141
  end
142
142
 
143
143
  it 'should return a single array containing attr hash of defaults' 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.0.0
4
+ version: 1.1.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-09-10 00:00:00.000000000 Z
11
+ date: 2016-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn
@@ -36,42 +36,42 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 1.1.0
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
- version: 1.1.0
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
- version: 2.14.1
53
+ version: 3.4.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
- version: 2.14.1
60
+ version: 3.4.0
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rubocop
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: 0.27.0
67
+ version: 0.38.0
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.27.0
74
+ version: 0.38.0
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: mocha
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -120,14 +120,14 @@ dependencies:
120
120
  requirements:
121
121
  - - "~>"
122
122
  - !ruby/object:Gem::Version
123
- version: '1.2'
123
+ version: '1.4'
124
124
  type: :development
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
- version: '1.2'
130
+ version: '1.4'
131
131
  description: |2
132
132
  Prawn::Icon provides various icon fonts including
133
133
  FontAwesome, Foundation Icons and GitHub Octicons
@@ -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.8
203
+ rubygems_version: 2.5.2
204
204
  signing_key:
205
205
  specification_version: 4
206
206
  summary: Provides icon fonts for PrawnPDF