dragonfly_pdf 0.1.1 → 0.1.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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f04eff68ff268fa1e86790e2bc5538476fe0a59e
|
4
|
+
data.tar.gz: 5d497d1d4d46d38592e3ce7d9e726c156f2eab1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 712af7cb0ec0e318c47fb99f9b45d75d8cefc84e51a6c244fd6c2b15d8b4b73cfd0be0f049802449f4a8394fcb17bdef74cf6920d3c1af8056a2e6ece919cce3
|
7
|
+
data.tar.gz: 930512619fed810019beb2f376e35534f3de3a0a19563627ffea9df3fef16e350ced7f09e66076f1df5521223d6c9c26562ceb28e2fadcfd9ff33f1e94fcb5f0
|
@@ -5,11 +5,12 @@ module DragonflyPdf
|
|
5
5
|
@content = content
|
6
6
|
@use_cropbox = options.fetch :use_cropbox, true
|
7
7
|
@use_trimbox = options.fetch :use_trimbox, true
|
8
|
+
@page_dimensions = page_dimensions
|
8
9
|
{
|
9
10
|
aspect_ratios: aspect_ratios,
|
10
11
|
heights: heights,
|
11
12
|
page_count: page_count,
|
12
|
-
page_dimensions: page_dimensions,
|
13
|
+
page_dimensions: @page_dimensions,
|
13
14
|
page_numbers: page_numbers,
|
14
15
|
widths: widths
|
15
16
|
}
|
@@ -18,40 +19,40 @@ module DragonflyPdf
|
|
18
19
|
private # =============================================================
|
19
20
|
|
20
21
|
def page_dimensions
|
21
|
-
@
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
page = page.split(/\s*x\s*/).map(&:to_f).map { |n| pt2mm(n) }
|
27
|
-
end
|
22
|
+
res = @content.shell_eval do |path|
|
23
|
+
"#{identify_command} -format '%Wx%H,' #{path}"
|
24
|
+
end
|
25
|
+
res.to_s.split(/\s*,\s*/).compact.map do |page|
|
26
|
+
page = page.split(/\s*x\s*/).map(&:to_f).map { |n| pt2mm(n) }
|
28
27
|
end
|
29
28
|
end
|
30
29
|
|
30
|
+
# ---------------------------------------------------------------------
|
31
|
+
|
31
32
|
def widths
|
32
|
-
page_dimensions.inject([]) do |res, page|
|
33
|
+
@page_dimensions.inject([]) do |res, page|
|
33
34
|
res << page[0]
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
37
38
|
def heights
|
38
|
-
page_dimensions.inject([]) do |res, page|
|
39
|
+
@page_dimensions.inject([]) do |res, page|
|
39
40
|
res << page[1]
|
40
41
|
end
|
41
42
|
end
|
42
43
|
|
43
44
|
def aspect_ratios
|
44
|
-
page_dimensions.inject([]) do |res, page|
|
45
|
+
@page_dimensions.inject([]) do |res, page|
|
45
46
|
res << page[0] / page[1]
|
46
47
|
end
|
47
48
|
end
|
48
49
|
|
49
|
-
def
|
50
|
-
|
50
|
+
def page_count
|
51
|
+
@page_dimensions.count
|
51
52
|
end
|
52
53
|
|
53
|
-
def
|
54
|
-
|
54
|
+
def page_numbers
|
55
|
+
(1..page_count).to_a
|
55
56
|
end
|
56
57
|
|
57
58
|
# =====================================================================
|
@@ -29,28 +29,28 @@ module DragonflyPdf
|
|
29
29
|
describe '#page_dimensions' do
|
30
30
|
it 'returns widths' do
|
31
31
|
analyser.call(sample_pages)[:page_dimensions].map{ |p| p.map(&:round) }.must_equal [[210, 297]].cycle.take(10)
|
32
|
-
analyser.call(sample_pages_with_bleed)[:page_dimensions].map{ |p| p.map(&:round) }.must_equal [[210, 297]].cycle.take(
|
32
|
+
analyser.call(sample_pages_with_bleed)[:page_dimensions].map{ |p| p.map(&:round) }.must_equal [[210, 297]].cycle.take(1)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
describe '#widths' do
|
37
37
|
it 'returns widths' do
|
38
38
|
analyser.call(sample_pages)[:widths].map(&:round).must_equal [210].cycle.take(10)
|
39
|
-
analyser.call(sample_pages_with_bleed)[:widths].map(&:round).must_equal [210].cycle.take(
|
39
|
+
analyser.call(sample_pages_with_bleed)[:widths].map(&:round).must_equal [210].cycle.take(1)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
describe '#heights' do
|
44
44
|
it 'returns heights' do
|
45
45
|
analyser.call(sample_pages)[:heights].map(&:round).must_equal [297].cycle.take(10)
|
46
|
-
analyser.call(sample_pages_with_bleed)[:heights].map(&:round).must_equal [297].cycle.take(
|
46
|
+
analyser.call(sample_pages_with_bleed)[:heights].map(&:round).must_equal [297].cycle.take(1)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
describe '#aspect_ratios' do
|
51
51
|
it 'returns aspect ratios' do
|
52
52
|
analyser.call(sample_pages)[:aspect_ratios].map{ |i| i.round(2) }.must_equal [0.71].cycle.take(10)
|
53
|
-
analyser.call(sample_pages_with_bleed)[:aspect_ratios].map{ |i| i.round(2) }.must_equal [0.71].cycle.take(
|
53
|
+
analyser.call(sample_pages_with_bleed)[:aspect_ratios].map{ |i| i.round(2) }.must_equal [0.71].cycle.take(1)
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
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: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Celizna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dragonfly
|
@@ -160,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
160
|
version: '0'
|
161
161
|
requirements: []
|
162
162
|
rubyforge_project:
|
163
|
-
rubygems_version: 2.
|
163
|
+
rubygems_version: 2.5.1
|
164
164
|
signing_key:
|
165
165
|
specification_version: 4
|
166
166
|
summary: Dragonfly PDF analysers and processors.
|