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: bbc3a3f1dbb8410a66dde421a0974c6f0be06301
4
- data.tar.gz: ccf356efef9690bf32d4209db9d4f57c41fbed16
3
+ metadata.gz: f04eff68ff268fa1e86790e2bc5538476fe0a59e
4
+ data.tar.gz: 5d497d1d4d46d38592e3ce7d9e726c156f2eab1d
5
5
  SHA512:
6
- metadata.gz: 8a4952a1389bbbfd99f1ac59379b7fd45f98edc98d91984e25ce2adc3b20d8b29d0bc3212e1f05c84e29895f36f6f82d387b53f0cbc81a66bba8a5d9810deee6
7
- data.tar.gz: d443d70008607d0ca33bb27157399c1396ebb3eadcf13f2e858ea07c0758b3edd644b3092ccd63596c14d661dce5e3850ffa03aa7d111b5bece338c7d488aca0
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
- @page_dimensions ||= begin
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) }
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 page_numbers
50
- (1..page_count).to_a
50
+ def page_count
51
+ @page_dimensions.count
51
52
  end
52
53
 
53
- def page_count
54
- page_dimensions.count
54
+ def page_numbers
55
+ (1..page_count).to_a
55
56
  end
56
57
 
57
58
  # =====================================================================
@@ -1,3 +1,3 @@
1
1
  module DragonflyPdf
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -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(10)
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(10)
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(10)
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(10)
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.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-21 00:00:00.000000000 Z
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.4.8
163
+ rubygems_version: 2.5.1
164
164
  signing_key:
165
165
  specification_version: 4
166
166
  summary: Dragonfly PDF analysers and processors.