dragonfly_pdf 2.2.1 → 2.2.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c3befda2f4836c64afe15ce4f326e59f2de98d07c1d6ebfe40537d06a86068a
4
- data.tar.gz: 074a8cb3cde1158b8729cbf6545f43ad81734b9d2b7dc3e7dd44b70ac94a624d
3
+ metadata.gz: 82ce144970343c6de53384e1b1cf1a6c1844d25007c9afda222fcdc1105db747
4
+ data.tar.gz: 5467a0f818a38d111edd3045e5a6d7b022f1c6926d540b30fbc1b2a2fa1efae2
5
5
  SHA512:
6
- metadata.gz: d79bd5c7f0e5f9607659b23524e68048b81bc2bb9577b8423fe3886ad2bb82d93e212259940da23e2610d7ebd4919cfc2f7e25f3709a9e05cc0bb182ed3a729e
7
- data.tar.gz: 0a3e896ecb9bb5c6c2001f4c59587274f16595130c52dea6c24e166d0688d1d05c5ffe2366dbcac5e2b850c2ebf1aaa8f4a01938a057310a589a18d060b7fd0f
6
+ metadata.gz: b55595af48d2d58bff454245b96c3c0362388c26ec902603e31189444339f95d5ecf7d3b5d3f3c9d8163913080b02fa9c2b71c5e4468a5e228da5624df94b279
7
+ data.tar.gz: 8c744fca929302ca9c7a8d592a8c9faff67de7fee5af373ad40650f8e1e37d7e142201ff53bb5ee90add7339eba67f00c0a7d6c294a08cbd5dee40b7dee183f8
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## Next
4
+
5
+ ## 2.2.2
6
+
7
+ * removed `tga` from `SUPPORTED_OUTPUT_FORMATS`
8
+ * fixed `page_dimensions` calculation for sizes larger than 1000 pts
9
+
3
10
  ## 2.2.1
4
11
 
5
12
  * all paths in quotes
@@ -1,35 +1,63 @@
1
1
  module DragonflyPdf
2
2
  module Analysers
3
3
  class PdfProperties
4
+ NUMBER_OF_PAGES_REGEX = /NumberOfPages:\s*(\d+)/
5
+ PAGE_MEDIA_NUMBER_REGEX = /PageMediaNumber:\s*(\d+)/
6
+ PAGE_MEDIA_DIMENSIONS_REGEX = /PageMediaDimensions:\s*(\d+\,?\d+\.?\d+)\s*(\d+\,?\d+\.?\d+)/
7
+ PAGE_MEDIA_ROTATIONS_REGEX = /PageMediaRotation:\s*(\d+)/
8
+
4
9
  def call(content, options = {})
5
10
  return {} unless content.ext
6
11
  return {} unless SUPPORTED_FORMATS.include?(content.ext.downcase)
7
12
 
8
13
  data = `pdftk "#{content.path}" dump_data`
9
14
 
10
- page_count = data.scan(/NumberOfPages: (\d+)/).flatten.first.to_i
11
- page_numbers = data.scan(/PageMediaNumber: (\d+)/).flatten.map(&:to_i)
12
- page_dimensions = data.scan(/PageMediaDimensions:\s*(\d+\.?\d+)\s*(\d+\.?\d+)/).map do |width_height|
13
- width_height.map(&:to_f).map { |dim| pt2mm(dim) }
14
- end
15
- page_rotations = data.scan(/PageMediaRotation: (\d+)/).flatten.map(&:to_f)
16
- aspect_ratios = page_dimensions.inject([]) { |res, page| res << (page.first / page.last) }
15
+ page_count = extract_page_count(data)
16
+ page_numbers = extract_page_numbers(data)
17
+ page_dimensions = extract_page_dimensions(data)
18
+ page_rotations = extract_page_rotations(data)
19
+ aspect_ratios = calculate_aspect_ratios(page_dimensions)
17
20
 
18
21
  {
19
- 'format' => content.ext.downcase,
20
22
  'aspect_ratios' => aspect_ratios,
23
+ 'format' => content.ext.downcase,
21
24
  'page_count' => page_count,
22
25
  'page_dimensions' => page_dimensions,
23
26
  'page_numbers' => page_numbers,
24
- 'page_rotations' => page_rotations
27
+ 'page_rotations' => page_rotations,
25
28
  }
26
29
  end
27
30
 
28
31
  private
29
32
 
30
- def pt2mm(pt)
33
+ def extract_page_count(data)
34
+ data.scan(NUMBER_OF_PAGES_REGEX).flatten.first.to_i
35
+ end
36
+
37
+ def extract_page_numbers(data)
38
+ data.scan(PAGE_MEDIA_NUMBER_REGEX).flatten.map(&:to_i)
39
+ end
40
+
41
+ def extract_page_dimensions(data)
42
+ data.scan(PAGE_MEDIA_DIMENSIONS_REGEX).map do |width, height|
43
+ [pt_to_mm(width), pt_to_mm(height)]
44
+ end
45
+ end
46
+
47
+ def pt_to_mm(length)
48
+ pt = length.gsub(",", "").to_f
31
49
  (pt / 72.0) * 25.4
32
50
  end
51
+
52
+ def extract_page_rotations(data)
53
+ data.scan(PAGE_MEDIA_ROTATIONS_REGEX).flatten.map(&:to_f)
54
+ end
55
+
56
+ def calculate_aspect_ratios(page_dimensions)
57
+ page_dimensions.map do |width, height|
58
+ width / height.to_f
59
+ end
60
+ end
33
61
  end
34
62
  end
35
63
  end
@@ -1,3 +1,3 @@
1
1
  module DragonflyPdf
2
- VERSION = '2.2.1'.freeze
2
+ VERSION = '2.2.2'.freeze
3
3
  end
data/lib/dragonfly_pdf.rb CHANGED
@@ -8,7 +8,7 @@ module DragonflyPdf
8
8
  class UnsupportedFormat < RuntimeError; end
9
9
 
10
10
  SUPPORTED_FORMATS = %w[pdf].freeze
11
- SUPPORTED_OUTPUT_FORMATS = %w[png pam pbm pkm pnm pdf tga svg].uniq.sort
11
+ SUPPORTED_OUTPUT_FORMATS = %w[png pam pbm pkm pnm pdf svg].uniq.sort
12
12
 
13
13
  private
14
14
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dragonfly_pdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Celizna
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-15 00:00:00.000000000 Z
11
+ date: 2022-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dragonfly
@@ -143,16 +143,9 @@ executables: []
143
143
  extensions: []
144
144
  extra_rdoc_files: []
145
145
  files:
146
- - ".gitignore"
147
- - ".tool-versions"
148
- - ".travis.yml"
149
146
  - CHANGELOG.md
150
- - Gemfile
151
- - Guardfile
152
- - LICENSE
153
147
  - README.md
154
148
  - Rakefile
155
- - dragonfly_pdf.gemspec
156
149
  - lib/dragonfly_pdf.rb
157
150
  - lib/dragonfly_pdf/analysers/pdf_properties.rb
158
151
  - lib/dragonfly_pdf/plugin.rb
@@ -165,27 +158,11 @@ files:
165
158
  - lib/dragonfly_pdf/processors/stamp.rb
166
159
  - lib/dragonfly_pdf/processors/subset_fonts.rb
167
160
  - lib/dragonfly_pdf/version.rb
168
- - samples/sample_pages.pdf
169
- - samples/sample_pages_rotated.pdf
170
- - samples/sample_pages_with_bleed.pdf
171
- - samples/sample_pages_with_password.pdf
172
- - samples/sample_stamp.pdf
173
- - test/dragonfly_pdf/analysers/pdf_properties_test.rb
174
- - test/dragonfly_pdf/plugin_test.rb
175
- - test/dragonfly_pdf/processors/append_test.rb
176
- - test/dragonfly_pdf/processors/convert_test.rb
177
- - test/dragonfly_pdf/processors/page_test.rb
178
- - test/dragonfly_pdf/processors/page_thumb_test.rb
179
- - test/dragonfly_pdf/processors/remove_password_test.rb
180
- - test/dragonfly_pdf/processors/rotate_test.rb
181
- - test/dragonfly_pdf/processors/stamp_test.rb
182
- - test/dragonfly_pdf/processors/subset_fonts_test.rb
183
- - test/test_helper.rb
184
161
  homepage: https://github.com/tomasc/dragonfly_pdf
185
162
  licenses:
186
163
  - MIT
187
164
  metadata: {}
188
- post_install_message:
165
+ post_install_message:
189
166
  rdoc_options: []
190
167
  require_paths:
191
168
  - lib
@@ -200,19 +177,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
177
  - !ruby/object:Gem::Version
201
178
  version: '0'
202
179
  requirements: []
203
- rubygems_version: 3.0.3
204
- signing_key:
180
+ rubygems_version: 3.1.6
181
+ signing_key:
205
182
  specification_version: 4
206
183
  summary: Dragonfly PDF analysers and processors.
207
- test_files:
208
- - test/dragonfly_pdf/analysers/pdf_properties_test.rb
209
- - test/dragonfly_pdf/plugin_test.rb
210
- - test/dragonfly_pdf/processors/append_test.rb
211
- - test/dragonfly_pdf/processors/convert_test.rb
212
- - test/dragonfly_pdf/processors/page_test.rb
213
- - test/dragonfly_pdf/processors/page_thumb_test.rb
214
- - test/dragonfly_pdf/processors/remove_password_test.rb
215
- - test/dragonfly_pdf/processors/rotate_test.rb
216
- - test/dragonfly_pdf/processors/stamp_test.rb
217
- - test/dragonfly_pdf/processors/subset_fonts_test.rb
218
- - test/test_helper.rb
184
+ test_files: []
data/.gitignore DELETED
@@ -1,23 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
18
- *.bundle
19
- *.so
20
- *.o
21
- *.a
22
- mkmf.log
23
- dragonfly.log
data/.tool-versions DELETED
@@ -1 +0,0 @@
1
- ruby 2.6.3
data/.travis.yml DELETED
@@ -1,28 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- script: 'bundle exec rake'
4
- sudo: required
5
- dist: trusty
6
- rvm:
7
- - 2.2.5
8
-
9
- before_install:
10
- - gem update bundler
11
- - sudo add-apt-repository -y ppa:ubuntuhandbook1/apps
12
- - sudo apt-get update
13
- - sudo apt-get install -y pdftk
14
- - sudo apt-get install -y ghostscript
15
- - curl -OL https://mupdf.com/downloads/mupdf-1.13.0-source.tar.gz
16
- - tar zvxf mupdf-1.13.0-source.tar.gz && cd mupdf-1.13.0-source && sudo make HAVE_X11=no HAVE_GLUT=no prefix=/usr/local install
17
- - sudo apt-get install -y gobject-introspection libgirepository1.0-dev libglib2.0-dev libpoppler-glib-dev
18
- - curl -OL https://github.com/jcupitt/libvips/releases/download/v8.5.8/vips-8.5.8.tar.gz
19
- - tar zvxf vips-8.5.8.tar.gz && cd vips-8.5.8 && ./configure && sudo make && sudo make install
20
- - export GI_TYPELIB_PATH=/usr/local/lib/girepository-1.0/
21
- - sudo ldconfig
22
-
23
- notifications:
24
- email:
25
- recipients:
26
- - tomas.celizna@gmail.com
27
- on_failure: change
28
- on_success: never
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in dragonfly_pdf.gemspec
4
- gemspec
data/Guardfile DELETED
@@ -1,8 +0,0 @@
1
- # A sample Guardfile
2
- # More info at https://github.com/guard/guard#readme
3
-
4
- guard :minitest do
5
- watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
6
- watch(%r{^test/.+_test\.rb$})
7
- watch(%r{^test/test_helper\.rb$}) { 'test' }
8
- end
data/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2014 Tomas Celizna
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,31 +0,0 @@
1
-
2
- lib = File.expand_path('lib', __dir__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'dragonfly_pdf/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = 'dragonfly_pdf'
8
- spec.version = DragonflyPdf::VERSION
9
- spec.authors = ['Tomas Celizna']
10
- spec.email = ['tomas.celizna@gmail.com']
11
- spec.summary = 'Dragonfly PDF analysers and processors.'
12
- spec.description = 'Dragonfly PDF analysers and processors.'
13
- spec.homepage = 'https://github.com/tomasc/dragonfly_pdf'
14
- spec.license = 'MIT'
15
-
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ['lib']
20
-
21
- spec.add_dependency 'dragonfly', '~> 1.0'
22
- spec.add_dependency 'dragonfly_libvips', '~> 2.4.0'
23
-
24
- spec.add_development_dependency 'bundler', '~> 1.12'
25
- spec.add_development_dependency 'guard'
26
- spec.add_development_dependency 'guard-minitest'
27
- spec.add_development_dependency 'minitest', '~> 5.0'
28
- spec.add_development_dependency 'minitest-reporters'
29
- spec.add_development_dependency 'rake', '~> 10.0'
30
- spec.add_development_dependency 'pdf-reader'
31
- end
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,16 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe DragonflyPdf::Analysers::PdfProperties do
4
- let(:app) { test_app.configure_with(:pdf) }
5
- let(:analyser) { DragonflyPdf::Analysers::PdfProperties.new }
6
- let(:sample_pages) { app.fetch_file(SAMPLES_DIR.join('sample_pages.pdf')) }
7
- let(:sample_pages_with_bleed) { app.fetch_file(SAMPLES_DIR.join('sample_pages_with_bleed.pdf')) }
8
- let(:sample_pages_rotated) { app.fetch_file(SAMPLES_DIR.join('sample_pages_rotated.pdf')) }
9
-
10
- it { analyser.call(sample_pages).must_be_kind_of Hash }
11
- it { analyser.call(sample_pages)['page_numbers'].must_equal (1..10).to_a }
12
- it { analyser.call(sample_pages)['page_count'].must_equal 10 }
13
- it { analyser.call(sample_pages)['page_dimensions'].map { |p| p.map(&:round) }.must_equal [[210, 297]].cycle.take(10) }
14
- it { analyser.call(sample_pages)['aspect_ratios'].map { |i| i.round(2) }.must_equal [0.71].cycle.take(10) }
15
- it { analyser.call(sample_pages_rotated)['page_rotations'].must_equal [0.0, 90.0, 180.0, 270.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] }
16
- end
@@ -1,30 +0,0 @@
1
- require 'test_helper'
2
-
3
- module DragonflyPdf
4
- describe Plugin do
5
- let(:app) { test_app.configure_with(:pdf) }
6
- let(:content) { app.fetch_file(SAMPLES_DIR.join('sample_pages.pdf')) }
7
-
8
- describe 'analysers' do
9
- it { content.must_respond_to :pdf_properties }
10
- it { content.pdf_properties.must_be_kind_of Hash }
11
- it { content.must_respond_to :page_count }
12
- it { content.must_respond_to :page_numbers }
13
- it { content.must_respond_to :page_dimensions }
14
- it { content.must_respond_to :aspect_ratios }
15
- it { content.must_respond_to :page_rotations }
16
- end
17
-
18
- describe 'processors' do
19
- it { content.must_respond_to :append }
20
- it { content.must_respond_to :convert }
21
- it { content.must_respond_to :encode }
22
- it { content.must_respond_to :page }
23
- it { content.must_respond_to :page_thumb }
24
- it { content.must_respond_to :remove_password }
25
- it { content.must_respond_to :rotate }
26
- it { content.must_respond_to :stamp }
27
- it { content.must_respond_to :subset_fonts }
28
- end
29
- end
30
- end
@@ -1,16 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe DragonflyPdf::Processors::Append do
4
- let(:app) { test_app.configure_with(:pdf) }
5
- let(:processor) { DragonflyPdf::Processors::Append.new }
6
- let(:content_1) { Dragonfly::Content.new(app, SAMPLES_DIR.join('sample_pages.pdf')) }
7
- let(:content_2) { Dragonfly::Content.new(app, SAMPLES_DIR.join('sample_pages_with_bleed.pdf')) }
8
-
9
- before { processor.call(content_1, [content_2]) }
10
-
11
- it { content_1.analyse(:page_count).must_equal 11 }
12
-
13
- describe 'tempfile has extension' do
14
- it { content_1.tempfile.path.must_match /\.pdf\z/ }
15
- end
16
- end
@@ -1,25 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe DragonflyPdf::Processors::Convert do
4
- let(:app) { test_app.configure_with(:pdf) }
5
- let(:processor) { DragonflyPdf::Processors::Convert.new }
6
- let(:content) { app.fetch_file SAMPLES_DIR.join('sample_pages.pdf') }
7
-
8
- describe 'SUPPORTED_OUTPUT_FORMATS' do
9
- DragonflyPdf::SUPPORTED_OUTPUT_FORMATS.each do |format|
10
- it(format) do
11
- result = content.convert(1, '600x', format: format)
12
- result.ext.must_equal format
13
- result.mime_type.must_equal Rack::Mime.mime_type(".#{format}")
14
- result.size.must_be :>, 0
15
- result.tempfile.path.must_match /\.#{format}\z/
16
- end
17
- end
18
- end
19
-
20
- describe 'url' do
21
- let (:url_attributes) { OpenStruct.new }
22
- before { processor.update_url(url_attributes, 1) }
23
- it { url_attributes.ext.must_equal 'png' }
24
- end
25
- end
@@ -1,19 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe DragonflyPdf::Processors::Page do
4
- let(:app) { test_app.configure_with(:pdf) }
5
- let(:content) { Dragonfly::Content.new(app, SAMPLES_DIR.join('sample_pages.pdf')) }
6
- let(:processor) { DragonflyPdf::Processors::Page.new }
7
-
8
- it { proc { processor.call(content, 0) }.must_raise DragonflyPdf::PageNotFound }
9
- it { proc { processor.call(content, 11) }.must_raise DragonflyPdf::PageNotFound }
10
-
11
- describe 'single pages' do
12
- before { processor.call(content, 1) }
13
- it { content.analyse(:page_count).must_equal 1 }
14
- end
15
-
16
- describe 'tempfile has extension' do
17
- it { processor.call(content, 1).tempfile.path.must_match /\.pdf\z/ }
18
- end
19
- end
@@ -1,27 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe DragonflyPdf::Processors::PageThumb do
4
- let(:app) { test_app.configure_with(:pdf) }
5
- let(:content) { Dragonfly::Content.new(app, SAMPLES_DIR.join('sample_pages.pdf')) }
6
- let(:processor) { DragonflyPdf::Processors::PageThumb.new }
7
-
8
- describe 'formats' do
9
- let (:url_attributes) { OpenStruct.new }
10
-
11
- describe 'default' do
12
- before do
13
- processor.call(content, 1, '600x')
14
- processor.update_url(url_attributes, 1)
15
- end
16
-
17
- it { content.ext.must_equal 'jpg' }
18
- it { content.meta['format'].must_equal 'jpg' }
19
- it { url_attributes.ext.must_equal 'jpg' }
20
- end
21
- end
22
-
23
- describe 'tempfile has extension' do
24
- before { processor.call(content, 1, '600x') }
25
- it { content.tempfile.path.must_match /\.jpg\z/ }
26
- end
27
- end
@@ -1,15 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe DragonflyPdf::Processors::RemovePassword do
4
- let(:app) { test_app.configure_with(:pdf) }
5
- let(:content) { Dragonfly::Content.new(app, SAMPLES_DIR.join('sample_pages_with_password.pdf')) }
6
- let(:processor) { DragonflyPdf::Processors::RemovePassword.new }
7
-
8
- before { processor.call(content, 1) }
9
-
10
- it { `pdftk #{content.path} dump_data`.wont_include 'OWNER PASSWORD REQUIRED' }
11
-
12
- describe 'tempfile has extension' do
13
- it { content.tempfile.path.must_match /\.pdf\z/ }
14
- end
15
- end
@@ -1,22 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe DragonflyPdf::Processors::Rotate do
4
- let(:app) { test_app.configure_with(:pdf) }
5
- let(:content) { Dragonfly::Content.new(app, SAMPLES_DIR.join('sample_pages.pdf')) }
6
- let(:processor) { DragonflyPdf::Processors::Rotate.new }
7
-
8
- describe 'String|Symbol' do
9
- before { processor.call(content, :left) }
10
- it { content.analyse(:page_rotations).must_equal [270, 270, 270, 270, 270, 270, 270, 270, 270, 270] }
11
- end
12
-
13
- describe 'arg is Hash' do
14
- before { processor.call(content, 1 => :left, 3 => :right) }
15
- it { content.analyse(:page_rotations).must_equal [270, 0.0, 90, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] }
16
- end
17
-
18
- describe 'tempfile has extension' do
19
- before { processor.call(content, :left) }
20
- it { content.tempfile.path.must_match /\.pdf\z/ }
21
- end
22
- end
@@ -1,18 +0,0 @@
1
- require 'pdf-reader'
2
- require 'test_helper'
3
-
4
- describe DragonflyPdf::Processors::Stamp do
5
- let(:app) { test_app.configure_with(:pdf) }
6
- let(:content) { Dragonfly::Content.new(app, SAMPLES_DIR.join('sample_pages.pdf')) }
7
- let(:content_stamp) { Dragonfly::Content.new(app, SAMPLES_DIR.join('sample_stamp.pdf')) }
8
- let(:processor) { DragonflyPdf::Processors::Stamp.new }
9
-
10
- before { processor.call(content, content_stamp) }
11
-
12
- it { content.analyse(:page_count).must_equal 10 }
13
- it { PDF::Reader.new(content.path).pages.map(&:text).must_equal %w(STAMP).cycle(10).to_a }
14
-
15
- describe 'tempfile has extension' do
16
- it { content.tempfile.path.must_match /\.pdf\z/ }
17
- end
18
- end
@@ -1,17 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe DragonflyPdf::Processors::SubsetFonts do
4
- let(:app) { test_app.configure_with(:pdf) }
5
- let(:content) { Dragonfly::Content.new(app, SAMPLES_DIR.join('sample_pages.pdf')) }
6
- let(:processor) { DragonflyPdf::Processors::SubsetFonts.new }
7
-
8
- it 'returns PDF by default' do
9
- skip 'not sure how to test this'
10
- processor.call(content, 1)
11
- end
12
-
13
- describe 'tempfile has extension' do
14
- before { processor.call(content, 1) }
15
- it { content.tempfile.path.must_match /\.pdf\z/ }
16
- end
17
- end
data/test/test_helper.rb DELETED
@@ -1,20 +0,0 @@
1
- require 'bundler/setup'
2
-
3
- require 'minitest'
4
- require 'minitest/autorun'
5
- require 'minitest/reporters'
6
- require 'minitest/spec'
7
-
8
- require 'dragonfly'
9
- require 'dragonfly_pdf'
10
-
11
- SAMPLES_DIR = Pathname.new(File.expand_path('../../samples', __FILE__))
12
-
13
- Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
14
-
15
- def test_app(name = nil)
16
- app = Dragonfly::App.instance(name).tap do |app|
17
- app.datastore = Dragonfly::MemoryDataStore.new
18
- app.secret = 'test secret'
19
- end
20
- end