pdf-core 0.7.0 → 0.8.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: b927f3fa2dd24b6cdb4985d8b0d72f6b753cc3d1
4
- data.tar.gz: 51de8ad704088ef8738768969444443379b57bcc
3
+ metadata.gz: 72b9c9e3df4caa328d5e4166d6843e77d4eb2ca8
4
+ data.tar.gz: 7833e82447f0f3ae5f25a0c9c5ad3f973442944b
5
5
  SHA512:
6
- metadata.gz: 589610d88baa8f03bbe3b4532cef5d780e0264d021933622d816c7b87b34ae8df06b5cd4e4276a2b159bcf6bbb1ae2ff0710d2cbe8cf37e44ce4c12ab7e04007
7
- data.tar.gz: 525447dd1ed202a7880bbac27a7acc4cda730eae17b726c5ef2b3c46ec777dbdd8d794db8e36207d6a764b6e45caf007e628e76b139fc93d1f5c2ec8cb0f181d
6
+ metadata.gz: 1240f1c5ff136fb1df4ca8a34a1cc1461fea31b672ae9340385ed0e8d7c61d300259e4ffa7eabee3362969de5de70d234604dac376e0b9ed822cffaece07931b
7
+ data.tar.gz: dcd7098604c252a3cb8315a02ba58ceabca12de4fa51319ecb2ed4a1f4bf3054d79f1defdea0085a32743d8eb3daf9265f1f305c480511fa8d23f56f8f3b02cd
Binary file
data.tar.gz.sig CHANGED
Binary file
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
2
4
 
3
5
  gemspec
data/Rakefile CHANGED
@@ -1,10 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler'
2
4
  Bundler.setup
3
5
 
4
6
  require 'rake'
5
7
  require 'rspec/core/rake_task'
6
8
 
7
- task default: [:spec, :rubocop]
9
+ task default: %i[spec rubocop]
8
10
 
9
11
  desc 'Run all rspec files'
10
12
  RSpec::Core::RakeTask.new('spec') do |c|
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative 'core/pdf_object'
2
4
  require_relative 'core/annotations'
3
5
  require_relative 'core/byte_string'
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  # annotations.rb : Implements low-level annotation support for PDF
4
4
  #
@@ -1,4 +1,6 @@
1
- # encoding: utf-8
1
+
2
+ # frozen_string_literal: true
3
+
2
4
  module PDF
3
5
  module Core
4
6
  # This is used to differentiate strings that must be encoded as
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  # Implements destination support for PDF
4
4
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PDF
2
4
  module Core
3
5
  class DocumentState #:nodoc:
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PDF
2
4
  module Core
3
5
  class FilterList
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  # prawn/core/filters.rb : Implements stream filters
4
4
  #
@@ -1,4 +1,6 @@
1
- # encoding: utf-8
1
+
2
+ # frozen_string_literal: true
3
+
2
4
  #
3
5
  # Implements graphics state saving and restoring
4
6
  #
@@ -1,4 +1,6 @@
1
- # encoding: utf-8
1
+
2
+ # frozen_string_literal: true
3
+
2
4
  module PDF
3
5
  module Core
4
6
  # This is used to differentiate strings that must be encoded as
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  require 'pdf/core/utils'
4
4
 
@@ -79,7 +79,7 @@ module PDF
79
79
  split! if children.length > limit
80
80
  else
81
81
  fit = children.detect { |child| child >= value }
82
- fit = children.last unless fit
82
+ fit ||= children.last
83
83
  fit << value
84
84
  end
85
85
 
@@ -1,4 +1,4 @@
1
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
2
 
3
3
  # Implements PDF object repository
4
4
  #
@@ -91,10 +91,10 @@ module PDF
91
91
  # object_id_for_page(-11)
92
92
  # => 17
93
93
  #
94
- def object_id_for_page(k)
95
- k -= 1 if k > 0
94
+ def object_id_for_page(page)
95
+ page -= 1 if page.positive?
96
96
  flat_page_ids = get_page_objects(pages).flatten
97
- flat_page_ids[k]
97
+ flat_page_ids[page]
98
98
  end
99
99
  end
100
100
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PDF
2
4
  module Core
3
5
  class OutlineItem #:nodoc:
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PDF
2
4
  module Core
3
5
  class OutlineRoot #:nodoc:
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # prawn/core/page.rb : Implements low-level representation of a PDF page
2
4
  #
3
5
  # Copyright February 2010, Gregory Brown. All Rights Reserved.
@@ -51,7 +53,7 @@ module PDF
51
53
  Contents: content
52
54
  )
53
55
 
54
- resources[:ProcSet] = [:PDF, :Text, :ImageB, :ImageC, :ImageI]
56
+ resources[:ProcSet] = %i[PDF Text ImageB ImageC ImageI]
55
57
  end
56
58
 
57
59
  def graphic_state
@@ -78,8 +80,8 @@ module PDF
78
80
  end
79
81
 
80
82
  def stamp_stream(dictionary)
81
- @stamp_stream = ''
82
83
  @stamp_dictionary = dictionary
84
+ @stamp_stream = @stamp_dictionary.stream
83
85
  graphic_stack_size = stack.stack.size
84
86
 
85
87
  document.save_graphics_state
@@ -90,8 +92,6 @@ module PDF
90
92
  document.restore_graphics_state
91
93
  end
92
94
 
93
- @stamp_dictionary << @stamp_stream
94
-
95
95
  @stamp_stream = nil
96
96
  @stamp_dictionary = nil
97
97
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Describes PDF page geometries
2
4
  #
3
5
  # Copyright April 2008, Gregory Brown. All Rights Reserved.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # pdf_object.rb : Handles Ruby to PDF object serialization
2
4
  #
3
5
  # Copyright April 2008, Gregory Brown. All Rights Reserved.
@@ -19,7 +21,7 @@ module PDF
19
21
  end
20
22
 
21
23
  def utf8_to_utf16(str)
22
- "\xFE\xFF".force_encoding(::Encoding::UTF_16BE) +
24
+ (+"\xFE\xFF").force_encoding(::Encoding::UTF_16BE) +
23
25
  str.encode(::Encoding::UTF_16BE)
24
26
  end
25
27
 
@@ -54,9 +56,12 @@ module PDF
54
56
 
55
57
  # NOTE: this can fail on huge floating point numbers, but it seems
56
58
  # unlikely to ever happen in practice.
57
- String(obj)
59
+ num_string = String(obj)
60
+
61
+ # Truncate trailing fraction zeroes
62
+ num_string.sub(/(\d*)((\.0*$)|(\.0*[1-9]*)0*$)/, '\1\4')
58
63
  when Array
59
- '[' << obj.map { |e| pdf_object(e, in_content_stream) }.join(' ') << ']'
64
+ '[' + obj.map { |e| pdf_object(e, in_content_stream) }.join(' ') + ']'
60
65
  when PDF::Core::LiteralString
61
66
  obj = obj.gsub(/[\\\n\r\t\b\f\(\)]/) { |m| "\\#{m}" }
62
67
  "(#{obj})"
@@ -65,10 +70,10 @@ module PDF
65
70
  obj = obj.gsub(/[\\\n\r\t\b\f\(\)]/) { |m| "\\#{m}" }
66
71
  "(#{obj})"
67
72
  when PDF::Core::ByteString
68
- '<' << obj.unpack('H*').first << '>'
73
+ "<#{obj.unpack('H*').first}>"
69
74
  when String
70
75
  obj = utf8_to_utf16(obj) unless in_content_stream
71
- '<' << string_to_hex(obj) << '>'
76
+ "<#{string_to_hex(obj)}>"
72
77
  when Symbol
73
78
  '/' + obj.to_s.unpack('C*').map do |n|
74
79
  if n < 33 || n > 126 || [35, 40, 41, 47, 60, 62].include?(n)
@@ -78,7 +83,7 @@ module PDF
78
83
  end
79
84
  end.join
80
85
  when ::Hash
81
- output = '<< '
86
+ output = +'<< '
82
87
  obj.each do |k, v|
83
88
  unless k.is_a?(String) || k.is_a?(Symbol)
84
89
  raise PDF::Core::Errors::FailedObjectConversion,
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # reference.rb : Implementation of PDF indirect objects
2
4
  #
3
5
  # Copyright April 2008, Gregory Brown. All Rights Reserved.
@@ -19,7 +21,7 @@ module PDF
19
21
  end
20
22
 
21
23
  def object
22
- output = "#{@identifier} #{gen} obj\n"
24
+ output = +"#{@identifier} #{gen} obj\n"
23
25
  if @stream.empty?
24
26
  output << PDF::Core.pdf_object(data) << "\n"
25
27
  else
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'stringio'
2
4
 
3
5
  module PDF
@@ -129,9 +131,9 @@ module PDF
129
131
  #
130
132
  # See Prawn::Document#number_pages for a sample usage of this capability.
131
133
 
132
- def go_to_page(k)
133
- @page_number = k
134
- state.page = state.pages[k - 1]
134
+ def go_to_page(page_number)
135
+ @page_number = page_number
136
+ state.page = state.pages[page_number - 1]
135
137
  end
136
138
 
137
139
  def finalize_all_page_contents
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # prawn/core/stream.rb : Implements Stream objects
2
4
  #
3
5
  # Copyright February 2013, Alexander Mankuta. All Rights Reserved.
@@ -16,7 +18,7 @@ module PDF
16
18
  end
17
19
 
18
20
  def <<(io)
19
- (@stream ||= '') << io
21
+ (@stream ||= +'') << io
20
22
  @filtered_stream = nil
21
23
  self
22
24
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # prawn/core/text.rb : Implements low level text helpers for Prawn
2
4
  #
3
5
  # Copyright January 2010, Daniel Nelson. All Rights Reserved.
@@ -9,7 +11,7 @@ module PDF
9
11
  module Text #:nodoc:
10
12
  # These should be used as a base. Extensions may build on this list
11
13
  #
12
- VALID_OPTIONS = [:kerning, :size, :style].freeze
14
+ VALID_OPTIONS = %i[kerning size style].freeze
13
15
  MODES = {
14
16
  fill: 0,
15
17
  stroke: 1,
@@ -260,6 +262,7 @@ module PDF
260
262
  end
261
263
  end
262
264
 
265
+ # rubocop: disable Naming/UncommunicativeMethodParamName
263
266
  def add_text_content(text, x, y, options)
264
267
  chunks = font.encode_text(text, options)
265
268
 
@@ -281,14 +284,19 @@ module PDF
281
284
 
282
285
  chunks.each do |(subset, string)|
283
286
  font.add_to_current_page(subset)
284
- add_content "/#{font.identifier_for(subset)} #{font_size} Tf"
287
+ add_content [
288
+ PDF::Core.pdf_object(font.identifier_for(subset), true),
289
+ PDF::Core.pdf_object(font_size, true),
290
+ 'Tf'
291
+ ].join(' ')
285
292
 
286
293
  operation = options[:kerning] && string.is_a?(Array) ? 'TJ' : 'Tj'
287
- add_content PDF::Core.pdf_object(string, true) << ' ' << operation
294
+ add_content PDF::Core.pdf_object(string, true) + ' ' + operation
288
295
  end
289
296
 
290
297
  add_content "ET\n"
291
298
  end
299
+ # rubocop: enable Naming/UncommunicativeMethodParamName
292
300
  end
293
301
  end
294
302
  end
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PDF
2
4
  module Core
3
5
  module Utils
4
- # rubocop: disable Security/MarshalLoad
5
6
  def deep_clone(object)
6
7
  Marshal.load(Marshal.dump(object))
7
8
  end
8
- # rubocop: enable Security/MarshalLoad
9
9
  module_function :deep_clone
10
10
  end
11
11
  end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Gem::Specification.new do |spec|
2
4
  spec.name = 'pdf-core'
3
- spec.version = '0.7.0'
5
+ spec.version = '0.8.1'
4
6
  spec.platform = Gem::Platform::RUBY
5
7
  spec.summary = 'PDF::Core is used by Prawn to render PDF documents'
6
8
  spec.files = Dir.glob('lib/**/**/*') +
@@ -8,12 +10,12 @@ Gem::Specification.new do |spec|
8
10
  %w[Gemfile Rakefile] +
9
11
  ['pdf-core.gemspec']
10
12
  spec.require_path = 'lib'
11
- spec.required_ruby_version = '>= 1.9.3'
13
+ spec.required_ruby_version = '>= 2.3'
12
14
  spec.required_rubygems_version = '>= 1.3.6'
13
15
 
14
16
  spec.cert_chain = ['certs/pointlessone.pem']
15
17
  if $PROGRAM_NAME.end_with? 'gem'
16
- spec.signing_key = File.expand_path('~/.ssh/gem-private_key.pem')
18
+ spec.signing_key = File.expand_path('~/.gem/gem-private_key.pem')
17
19
  end
18
20
 
19
21
  # spec.extra_rdoc_files = %w{README.md LICENSE COPYING GPLv2 GPLv3}
@@ -30,12 +32,12 @@ Gem::Specification.new do |spec|
30
32
  spec.rubyforge_project = 'prawn'
31
33
  spec.licenses = %w[PRAWN GPL-2.0 GPL-3.0]
32
34
  spec.add_development_dependency('bundler')
33
- spec.add_development_dependency('pdf-reader', '~>1.2')
34
35
  spec.add_development_dependency('pdf-inspector', '~> 1.1.0')
36
+ spec.add_development_dependency('pdf-reader', '~>1.2')
35
37
  spec.add_development_dependency('rake')
36
38
  spec.add_development_dependency('rspec')
37
- spec.add_development_dependency('rubocop', '~> 0.46')
38
- spec.add_development_dependency('rubocop-rspec', '~> 1.9')
39
+ spec.add_development_dependency('rubocop', '~> 0.55')
40
+ spec.add_development_dependency('rubocop-rspec', '~> 1.25')
39
41
  spec.add_development_dependency('simplecov')
40
42
  spec.homepage = 'http://prawn.majesticseacreature.com'
41
43
  spec.description = 'PDF::Core is used by Prawn to render PDF documents'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdf-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gregory Brown
@@ -16,7 +16,7 @@ cert_chain:
16
16
  -----BEGIN CERTIFICATE-----
17
17
  MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MQ0wCwYDVQQDDARhbGV4
18
18
  MRkwFwYKCZImiZPyLGQBGRYJcG9pbnRsZXNzMRMwEQYKCZImiZPyLGQBGRYDb25l
19
- MB4XDTE3MDEwNDExNDAzM1oXDTE4MDEwNDExNDAzM1owPzENMAsGA1UEAwwEYWxl
19
+ MB4XDTE4MDQyNzE5NTkyNloXDTE5MDQyNzE5NTky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4dKC5wOD4gHGnq694kAdY/3rtRvorLtOJm+pHZSKe/9Je
34
+ CWt9UspdQDfg95fK56I9NFeV+LrQ5Cj866DCeH25SFbgK9acS7lw4uOLVu/9QWhZ
35
+ otbeukAemPO8HXWM/JCgkR6BaPE=
36
36
  -----END CERTIFICATE-----
37
- date: 2017-03-11 00:00:00.000000000 Z
37
+ date: 2018-04-28 00:00:00.000000000 Z
38
38
  dependencies:
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: bundler
@@ -51,33 +51,33 @@ dependencies:
51
51
  - !ruby/object:Gem::Version
52
52
  version: '0'
53
53
  - !ruby/object:Gem::Dependency
54
- name: pdf-reader
54
+ name: pdf-inspector
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
- version: '1.2'
59
+ version: 1.1.0
60
60
  type: :development
61
61
  prerelease: false
62
62
  version_requirements: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
- version: '1.2'
66
+ version: 1.1.0
67
67
  - !ruby/object:Gem::Dependency
68
- name: pdf-inspector
68
+ name: pdf-reader
69
69
  requirement: !ruby/object:Gem::Requirement
70
70
  requirements:
71
71
  - - "~>"
72
72
  - !ruby/object:Gem::Version
73
- version: 1.1.0
73
+ version: '1.2'
74
74
  type: :development
75
75
  prerelease: false
76
76
  version_requirements: !ruby/object:Gem::Requirement
77
77
  requirements:
78
78
  - - "~>"
79
79
  - !ruby/object:Gem::Version
80
- version: 1.1.0
80
+ version: '1.2'
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: rake
83
83
  requirement: !ruby/object:Gem::Requirement
@@ -112,28 +112,28 @@ dependencies:
112
112
  requirements:
113
113
  - - "~>"
114
114
  - !ruby/object:Gem::Version
115
- version: '0.46'
115
+ version: '0.55'
116
116
  type: :development
117
117
  prerelease: false
118
118
  version_requirements: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - "~>"
121
121
  - !ruby/object:Gem::Version
122
- version: '0.46'
122
+ version: '0.55'
123
123
  - !ruby/object:Gem::Dependency
124
124
  name: rubocop-rspec
125
125
  requirement: !ruby/object:Gem::Requirement
126
126
  requirements:
127
127
  - - "~>"
128
128
  - !ruby/object:Gem::Version
129
- version: '1.9'
129
+ version: '1.25'
130
130
  type: :development
131
131
  prerelease: false
132
132
  version_requirements: !ruby/object:Gem::Requirement
133
133
  requirements:
134
134
  - - "~>"
135
135
  - !ruby/object:Gem::Version
136
- version: '1.9'
136
+ version: '1.25'
137
137
  - !ruby/object:Gem::Dependency
138
138
  name: simplecov
139
139
  requirement: !ruby/object:Gem::Requirement
@@ -201,7 +201,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
201
201
  requirements:
202
202
  - - ">="
203
203
  - !ruby/object:Gem::Version
204
- version: 1.9.3
204
+ version: '2.3'
205
205
  required_rubygems_version: !ruby/object:Gem::Requirement
206
206
  requirements:
207
207
  - - ">="
@@ -209,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
209
209
  version: 1.3.6
210
210
  requirements: []
211
211
  rubyforge_project: prawn
212
- rubygems_version: 2.6.10
212
+ rubygems_version: 2.6.14
213
213
  signing_key:
214
214
  specification_version: 4
215
215
  summary: PDF::Core is used by Prawn to render PDF documents
metadata.gz.sig CHANGED
Binary file