podoff 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 524a29d94dd28dc3718ba75fb4069ae48aaf92c9155354dd47bea3c0aac3da06
4
+ data.tar.gz: 0eeb72d7886f515b4cc1fa506cb684b1dbc659f417968fa1384f46fa01f8ccd8
5
+ SHA512:
6
+ metadata.gz: a6940fc4156ecc2065d69e9ed07e65e0fba7824992f4203d8c65079425739cc7fa76f0787f42c89512dfef19d7a3b8af1d399c5fb3d947358746c94ee74777b1
7
+ data.tar.gz: 25a8c5f3be8f92241eb4596eb7b0896d222f11e786940b6c23dbe61062ef69b2f627426aa15c62b21f52d07a80ad828459e1ef7395d8f313054f3ce3dbdace15
@@ -0,0 +1,59 @@
1
+
2
+ # podoff CHANGELOG.md
3
+
4
+
5
+ ## podoff 1.2.3 released 2019-03-12
6
+
7
+ * Introduce Stream#rg(red, green, blue)
8
+ * Silence 2 Ruby warnings
9
+
10
+
11
+ ## podoff 1.2.2 released 2017-02-13
12
+
13
+ * Use rb: + enc instead of just r: + enc, should fix issues on Windows
14
+
15
+
16
+ ## podoff 1.2.1 released 2017-02-01
17
+
18
+ * Fail with ArgumentError when pdf not "unpacked"
19
+
20
+
21
+ ## podoff 1.2.0 released 2015-11-11
22
+
23
+ * require encoding upon loading and parsing, introduce Document#encoding
24
+ * drop Podoff::Obj#page_number
25
+ * use /Kids in /Pages to determine pages and page order
26
+
27
+
28
+ ## podoff 1.1.1 released 2015-10-26
29
+
30
+ * reworked xref table output
31
+ * FlateDecode stream if length > 98
32
+
33
+
34
+ ## podoff 1.1.0 released 2015-10-25
35
+
36
+ * more tolerant at parsing (StringScanner)
37
+ * bin/podoff
38
+ * Document#rewrite(path)
39
+
40
+
41
+ ## podoff 1.0.0 released 2015-10-23
42
+
43
+ * leverage incremental updates
44
+
45
+
46
+ ## podoff 0.9.1 not released
47
+
48
+ * ensure Obj#contents accepts arrays
49
+
50
+
51
+ ## podoff 0.9.0 released 2015-10-21
52
+
53
+ * beta release
54
+
55
+
56
+ ## podoff 0.0.1 released 2015-10-20
57
+
58
+ * initial, empty, release
59
+
@@ -1,5 +1,5 @@
1
1
 
2
- Copyright (c) 2015-2017, John Mettraux, jmettraux@gmail.com
2
+ Copyright (c) 2015-2019, John Mettraux, jmettraux@gmail.com
3
3
 
4
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
5
  of this software and associated documentation files (the "Software"), to deal
@@ -19,3 +19,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
19
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
20
  THE SOFTWARE.
21
21
 
22
+
23
+ Made in Japan
24
+
data/Makefile CHANGED
@@ -1,9 +1,15 @@
1
1
 
2
+ ## gem tasks ##
3
+
2
4
  NAME = \
3
5
  $(shell ruby -e "s = eval(File.read(Dir['*.gemspec'][0])); puts s.name")
4
6
  VERSION = \
5
7
  $(shell ruby -e "s = eval(File.read(Dir['*.gemspec'][0])); puts s.version")
6
8
 
9
+ count_lines:
10
+ find lib -name "*.rb" | xargs cat | ruby -e "p STDIN.readlines.count { |l| l = l.strip; l[0, 1] != '#' && l != '' }"
11
+ find spec -name "*_spec.rb" | xargs cat | ruby -e "p STDIN.readlines.count { |l| l = l.strip; l[0, 1] != '#' && l != '' }"
12
+ cl: count_lines
7
13
 
8
14
  gemspec_validate:
9
15
  @echo "---"
@@ -13,6 +19,9 @@ gemspec_validate:
13
19
  name: gemspec_validate
14
20
  @echo "$(NAME) $(VERSION)"
15
21
 
22
+ cw:
23
+ find lib -name "*.rb" -exec ruby -cw {} \;
24
+
16
25
  build: gemspec_validate
17
26
  gem build $(NAME).gemspec
18
27
  mkdir -p pkg
@@ -21,3 +30,6 @@ build: gemspec_validate
21
30
  push: build
22
31
  gem push pkg/$(NAME)-$(VERSION).gem
23
32
 
33
+
34
+ .PHONY: count_lines gemspec_validate name cw build push
35
+
@@ -1,26 +1,3 @@
1
- #--
2
- # Copyright (c) 2015-2017, John Mettraux, jmettraux@gmail.com
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining a copy
5
- # of this software and associated documentation files (the "Software"), to deal
6
- # in the Software without restriction, including without limitation the rights
7
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
- # copies of the Software, and to permit persons to whom the Software is
9
- # furnished to do so, subject to the following conditions:
10
- #
11
- # The above copyright notice and this permission notice shall be included in
12
- # all copies or substantial portions of the Software.
13
- #
14
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
- # THE SOFTWARE.
21
- #
22
- # Made in Japan.
23
- #++
24
1
 
25
2
  require 'zlib'
26
3
  require 'strscan'
@@ -29,7 +6,7 @@ require 'stringio'
29
6
 
30
7
  module Podoff
31
8
 
32
- VERSION = '1.2.2'
9
+ VERSION = '1.2.3'
33
10
 
34
11
  def self.load(path, encoding)
35
12
 
@@ -87,7 +64,7 @@ module Podoff
87
64
 
88
65
  loop do
89
66
 
90
- i = @scanner.skip_until(
67
+ @scanner.skip_until(
91
68
  /(startxref\s+\d+|\d+\s+\d+\s+obj|\/Root\s+\d+\s+\d+\s+R)/)
92
69
 
93
70
  m = @scanner.matched
@@ -107,7 +84,7 @@ module Podoff
107
84
  if @root == nil
108
85
  @scanner.pos = 0
109
86
  loop do
110
- i = @scanner.skip_until(/\/Root\s+\d+\s+\d+\s+R/)
87
+ @scanner.skip_until(/\/Root\s+\d+\s+\d+\s+R/)
111
88
  break unless @scanner.matched
112
89
  @root = extract_ref(@scanner.matched)
113
90
  end
@@ -522,6 +499,7 @@ module Podoff
522
499
 
523
500
  @obj = obj
524
501
  @font = nil
502
+ @color = nil
525
503
  @content = StringIO.new
526
504
  end
527
505
 
@@ -533,11 +511,19 @@ module Podoff
533
511
  end
534
512
  alias :font :tf
535
513
 
514
+ def rg(red, green, blue)
515
+
516
+ @color = "#{red} #{green} #{blue} rg "
517
+ end
518
+ alias :color :rg
519
+ alias :rgb :rg
520
+
536
521
  def bt(x, y, text)
537
522
 
538
523
  @content.write "\n" if @content.size > 0
539
524
  @content.write "BT "
540
525
  @content.write @font if @font
526
+ @content.write @color if @color
541
527
  @content.write "#{x} #{y} Td (#{escape(text)}) Tj"
542
528
  @content.write " ET"
543
529
  end
@@ -11,24 +11,26 @@ Gem::Specification.new do |s|
11
11
  s.authors = [ 'John Mettraux' ]
12
12
  s.email = [ 'jmettraux@gmail.com' ]
13
13
  s.homepage = 'http://github.com/jmettraux/podoff'
14
- s.rubyforge_project = 'rufus'
14
+ #s.rubyforge_project = 'rufus'
15
15
  s.license = 'MIT'
16
16
  s.summary = 'a tool to deface PDF documents'
17
17
 
18
18
  s.description = %{
19
- a tool to deface PDF documents
19
+ A library to write over existing PDF documents
20
20
  }.strip
21
21
 
22
22
  #s.files = `git ls-files`.split("\n")
23
23
  s.files = Dir[
24
+ 'README.{md,txt}',
25
+ 'CHANGELOG.{md,txt}', 'CREDITS.{md,txt}', 'LICENSE.{md,txt}',
24
26
  'Makefile',
25
- 'lib/**/*.rb', 'spec/**/*.rb', 'test/**/*.rb',
26
- '*.gemspec', '*.txt', '*.rdoc', '*.md'
27
+ 'lib/**/*.rb', #'spec/**/*.rb', 'test/**/*.rb',
28
+ "#{s.name}.gemspec",
27
29
  ]
28
30
 
29
31
  #s.add_runtime_dependency 'tzinfo'
30
32
 
31
- s.add_development_dependency 'rspec', '>= 2.13.0'
33
+ s.add_development_dependency 'rspec', '~> 3.7'
32
34
 
33
35
  s.require_path = 'lib'
34
36
  end
metadata CHANGED
@@ -1,77 +1,64 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: podoff
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
5
- prerelease:
4
+ version: 1.2.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - John Mettraux
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2017-02-13 00:00:00.000000000 Z
11
+ date: 2019-03-12 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: 2.13.0
19
+ version: '3.7'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: 2.13.0
30
- description: a tool to deface PDF documents
26
+ version: '3.7'
27
+ description: A library to write over existing PDF documents
31
28
  email:
32
29
  - jmettraux@gmail.com
33
30
  executables: []
34
31
  extensions: []
35
32
  extra_rdoc_files: []
36
33
  files:
34
+ - CHANGELOG.md
35
+ - LICENSE.txt
37
36
  - Makefile
37
+ - README.md
38
38
  - lib/podoff.rb
39
- - spec/alpha_spec.rb
40
- - spec/core_spec.rb
41
- - spec/document_spec.rb
42
- - spec/obj_spec.rb
43
- - spec/spec_helper.rb
44
- - spec/stream_spec.rb
45
- - spec/update_spec.rb
46
39
  - podoff.gemspec
47
- - CHANGELOG.txt
48
- - LICENSE.txt
49
- - out.txt
50
- - todo.txt
51
- - README.md
52
40
  homepage: http://github.com/jmettraux/podoff
53
41
  licenses:
54
42
  - MIT
43
+ metadata: {}
55
44
  post_install_message:
56
45
  rdoc_options: []
57
46
  require_paths:
58
47
  - lib
59
48
  required_ruby_version: !ruby/object:Gem::Requirement
60
- none: false
61
49
  requirements:
62
- - - ! '>='
50
+ - - ">="
63
51
  - !ruby/object:Gem::Version
64
52
  version: '0'
65
53
  required_rubygems_version: !ruby/object:Gem::Requirement
66
- none: false
67
54
  requirements:
68
- - - ! '>='
55
+ - - ">="
69
56
  - !ruby/object:Gem::Version
70
57
  version: '0'
71
58
  requirements: []
72
- rubyforge_project: rufus
73
- rubygems_version: 1.8.23.2
59
+ rubyforge_project:
60
+ rubygems_version: 2.7.6
74
61
  signing_key:
75
- specification_version: 3
62
+ specification_version: 4
76
63
  summary: a tool to deface PDF documents
77
64
  test_files: []
@@ -1,53 +0,0 @@
1
-
2
- = podoff CHANGELOG.txt
3
-
4
-
5
- == podoff 1.2.2 released 2017-02-13
6
-
7
- - Use rb: + enc instead of just r: + enc, should fix issues on Windows
8
-
9
-
10
- == podoff 1.2.1 released 2017-02-01
11
-
12
- - Fail with ArgumentError when pdf not "unpacked"
13
-
14
-
15
- == podoff 1.2.0 released 2015-11-11
16
-
17
- - require encoding upon loading and parsing, introduce Document#encoding
18
- - drop Podoff::Obj#page_number
19
- - use /Kids in /Pages to determine pages and page order
20
-
21
-
22
- == podoff 1.1.1 released 2015-10-26
23
-
24
- - reworked xref table output
25
- - FlateDecode stream if length > 98
26
-
27
-
28
- == podoff 1.1.0 released 2015-10-25
29
-
30
- - more tolerant at parsing (StringScanner)
31
- - bin/podoff
32
- - Document#rewrite(path)
33
-
34
-
35
- == podoff 1.0.0 released 2015-10-23
36
-
37
- - leverage incremental updates
38
-
39
-
40
- == podoff 0.9.1 not released
41
-
42
- - ensure Obj#contents accepts arrays
43
-
44
-
45
- == podoff 0.9.0 released 2015-10-21
46
-
47
- - beta release
48
-
49
-
50
- == podoff 0.0.1 released 2015-10-20
51
-
52
- - initial, empty, release
53
-
data/out.txt DELETED
@@ -1 +0,0 @@
1
- utf-8
@@ -1,40 +0,0 @@
1
-
2
- #
3
- # specifying podoff
4
- #
5
- # Tue Nov 10 21:01:51 JST 2015
6
- #
7
-
8
- require 'spec_helper'
9
-
10
-
11
- describe 'fixtures:' do
12
-
13
- Dir['pdfs/*.pdf'].each do |path|
14
-
15
- describe path do
16
-
17
- it 'is a valid pdf document' do
18
-
19
- expect(path).to be_a_valid_pdf
20
- end
21
- end
22
- end
23
-
24
- describe 'pdfs/t0.pdf' do
25
-
26
- it 'is encoded as UTF-8' do
27
-
28
- expect('pdfs/t0.pdf').to be_encoded_as('utf-8')
29
- end
30
- end
31
-
32
- describe 'pdfs/udocument0.pdf' do
33
-
34
- it 'is encoded as ISO-8859-1' do
35
-
36
- expect('pdfs/udocument0.pdf').to be_encoded_as('latin1')
37
- end
38
- end
39
- end
40
-
@@ -1,99 +0,0 @@
1
-
2
- #
3
- # specifying podoff
4
- #
5
- # Tue Oct 20 13:11:38 JST 2015
6
- #
7
-
8
- require 'spec_helper'
9
-
10
-
11
- describe Podoff do
12
-
13
- describe '.load' do
14
-
15
- it 'loads a PDF document' do
16
-
17
- d = Podoff.load('pdfs/t0.pdf', 'utf-8')
18
-
19
- expect(d.class).to eq(Podoff::Document)
20
- expect(d.objs.keys).to eq([ '1 0', '2 0', '3 0', '4 0', '5 0', '6 0' ])
21
- expect(d.xref).to eq(413)
22
-
23
- #pp d.objs.values.collect(&:to_a)
24
-
25
- expect(d.objs['1 0'].to_a).to eq(
26
- [ '1 0', 9, 54, { type: '/Catalog' } ])
27
- expect(d.objs['3 0'].to_a).to eq(
28
- [ '3 0', 111, 213, { type: '/Page', contents: '6 0 R' } ])
29
-
30
- expect(d.objs.values.first.document).not_to be(nil)
31
-
32
- expect(d.obj_counters.keys).to eq(
33
- [ '1 0', '2 0', '3 0', '4 0', '5 0', '6 0' ])
34
- expect(d.obj_counters.values).to eq(
35
- [ 1, 1, 1, 1, 1, 1 ])
36
-
37
- expect(d.root).to eq('1 0')
38
-
39
- expect(d.pages.size).to eq(1)
40
- end
41
-
42
- it 'loads a PDF document' do
43
-
44
- d = Podoff.load('pdfs/udocument0.pdf', 'iso-8859-1')
45
-
46
- expect(d.class).to eq(Podoff::Document)
47
- expect(d.xref).to eq(1612815)
48
- expect(d.objs.size).to eq(273)
49
- expect(d.objs.keys).to include('1 0')
50
- expect(d.objs.keys).to include('273 0')
51
-
52
- expect(d.root).to eq('1 0')
53
-
54
- expect(d.pages.size).to eq(3)
55
- end
56
-
57
- it 'loads a PDF document with incremental updates' do
58
-
59
- d = Podoff.load('pdfs/t1.pdf', 'utf-8')
60
-
61
- expect(d.class).to eq(Podoff::Document)
62
- expect(d.xref).to eq(704)
63
- expect(d.objs.keys).to eq([ '1 0', '2 0', '3 0', '4 0', '5 0', '6 0' ])
64
-
65
- expect(d.obj_counters.keys).to eq(
66
- [ '1 0', '2 0', '3 0', '4 0', '5 0', '6 0' ])
67
- expect(d.obj_counters.values).to eq(
68
- [ 1, 1, 1, 1, 1, 2 ])
69
-
70
- expect(d.root).to eq('1 0')
71
- end
72
-
73
- it 'loads a [re]compressed PDF documents' do
74
-
75
- d = Podoff.load('pdfs/qdocument0.pdf', 'iso-8859-1')
76
-
77
- expect(d.class).to eq(Podoff::Document)
78
- expect(d.xref).to eq(1612815)
79
- expect(d.objs.size).to eq(273)
80
-
81
- expect(d.root).to eq('1 0')
82
-
83
- #d.objs.each do |ref, o|
84
- # p [ o.ref, o.attributes ]
85
- #end
86
-
87
- expect(d.pages.size).to eq(3)
88
- expect(d.objs['46 0'].attributes[:type]).to eq('/Annot')
89
- end
90
-
91
- it 'rejects items that are not PDF documents' do
92
-
93
- expect {
94
- Podoff.load('spec/spec_helper.rb', 'utf-8')
95
- }.to raise_error(ArgumentError, 'not a PDF file')
96
- end
97
- end
98
- end
99
-