standard-procedure-consolidate 0.4.3 → 0.4.4

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: c3a7f02d5159a44a47af30100fe1743b2b5bff5ab845a0da2170ffaf44302f03
4
- data.tar.gz: b041806b3d682a4c5ccc0011025a1d3d5b25a7c1a65fda56e9b3fcce34b364a9
3
+ metadata.gz: f54b1e9134c3e9ec1a9a87ba47dd0a0842e430f9bc2ad2801fdaaecb6d4784c1
4
+ data.tar.gz: 881e583371a1cc58b7742ea74cb90e47b934198d03a6d76d538a7c48330378cf
5
5
  SHA512:
6
- metadata.gz: 2bc84355758ef68cd525c684fe1ef6973858eb3ba360f4a37a026cc54a11c9eb143cc364bd034cdd4452bec75a91a768b7f96ccbb727039da5e6ba727fb643bd
7
- data.tar.gz: b8061eb3ff1a61deb3c1b153be11d9c5b416be6a576d559c0846236a1e8dabdf9dcf339f33479e39589d3c247930cb28d437a360becbe5e498e90b99eb26ffea
6
+ metadata.gz: a48b68b17ba644b23b4bd81ff30a195260a00343aeba22cfcfd77151e1d22f4d13dff7b54409d87737b9610f888fd574b624a4aac5bcd3c114500be3626f9267
7
+ data.tar.gz: 14acf38a2067475f7a5cd25e2783aed5f2299d764b051906c833dba4d1ae4f515ab2929606990bdb87da74a139aa587ef23682d5297d896a6f9293d6c16dcdd1
@@ -0,0 +1 @@
1
+ c1a13d3d2b2c50741b839e2ca20c730b2689fac090e9c67660950a506ce83b3b9e07e31f3de205ec67dcbf4b1eff462f8fc507468fdb378e864e9a5952b9decf
@@ -18,15 +18,16 @@ module Consolidate
18
18
  # Convert height from pixels to EMU
19
19
  def height = super * emu_per_height_pixel
20
20
 
21
- # Get the width of this image in EMU up to a maximum page width (also in EMU)
22
- def clamped_width(maximum = 7_772_400) = [width, maximum].min
21
+ def emu_per_width_pixel = EMU_PER_PIXEL * 72 / dpi[:x]
23
22
 
24
- # Get the height of this image in EMU adjusted for a maximum page width (also in EMU)
25
- def clamped_height(maximum = 7_772_400) = (height * clamped_width(maximum).to_f / width.to_f).to_i
23
+ def emu_per_height_pixel = EMU_PER_PIXEL * 72 / dpi[:y]
26
24
 
27
- def emu_per_width_pixel = 914_400 / dpi[:x]
28
-
29
- def emu_per_height_pixel = 914_400 / dpi[:y]
25
+ DEFAULT_PAGE_WIDTH = 12_240
26
+ TWENTIETHS_OF_A_POINT_TO_EMU = 635
27
+ DEFAULT_PAGE_WIDTH_IN_EMU = DEFAULT_PAGE_WIDTH * TWENTIETHS_OF_A_POINT_TO_EMU
28
+ EMU_PER_PIXEL = 9525
29
+ DEFAULT_PAGE_HEIGHT = DEFAULT_PAGE_WIDTH * 11 / 8.5 # Assuming US Letter size
30
+ DEFAULT_PAGE_HEIGHT_IN_EMU = DEFAULT_PAGE_HEIGHT * TWENTIETHS_OF_A_POINT_TO_EMU
30
31
  end
31
32
  end
32
33
  end
@@ -116,24 +116,17 @@ module Consolidate
116
116
  end
117
117
  end
118
118
 
119
- DEFAULT_PAGE_WIDTH = 12_240
120
- TWENTIETHS_OF_A_POINT_TO_EMU = 635
121
- DEFAULT_PAGE_WIDTH_IN_EMU = DEFAULT_PAGE_WIDTH * TWENTIETHS_OF_A_POINT_TO_EMU
122
- EMU_PER_PIXEL = 9525
123
- DEFAULT_PAGE_HEIGHT = DEFAULT_PAGE_WIDTH * 11 / 8.5 # Assuming standard page ratio
124
- DEFAULT_PAGE_HEIGHT_IN_EMU = DEFAULT_PAGE_HEIGHT * TWENTIETHS_OF_A_POINT_TO_EMU
125
-
126
119
  private def max_width_from document
127
- page_width = (document.at_xpath("//w:sectPr/w:pgSz/@w:w")&.value || DEFAULT_PAGE_WIDTH).to_i
128
- page_width * TWENTIETHS_OF_A_POINT_TO_EMU
120
+ page_width = (document.at_xpath("//w:sectPr/w:pgSz/@w:w")&.value || Image::DEFAULT_PAGE_WIDTH).to_i
121
+ page_width * Image::TWENTIETHS_OF_A_POINT_TO_EMU
129
122
  end
130
123
 
131
124
  private def max_dimensions_from(document)
132
- page_width = (document.at_xpath("//w:sectPr/w:pgSz/@w:w")&.value || DEFAULT_PAGE_WIDTH).to_i
133
- page_height = (document.at_xpath("//w:sectPr/w:pgSz/@w:h")&.value || DEFAULT_PAGE_HEIGHT).to_i
125
+ page_width = (document.at_xpath("//w:sectPr/w:pgSz/@w:w")&.value || Image::DEFAULT_PAGE_WIDTH).to_i
126
+ page_height = (document.at_xpath("//w:sectPr/w:pgSz/@w:h")&.value || Image::DEFAULT_PAGE_HEIGHT).to_i
134
127
 
135
- width_emu = page_width * TWENTIETHS_OF_A_POINT_TO_EMU
136
- height_emu = page_height * TWENTIETHS_OF_A_POINT_TO_EMU
128
+ width_emu = page_width * Image::TWENTIETHS_OF_A_POINT_TO_EMU
129
+ height_emu = page_height * Image::TWENTIETHS_OF_A_POINT_TO_EMU
137
130
 
138
131
  [width_emu, height_emu]
139
132
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Consolidate
4
- VERSION = "0.4.3"
4
+ VERSION = "0.4.4"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: standard-procedure-consolidate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rahoul Baruah
@@ -67,6 +67,7 @@ files:
67
67
  - checksums/standard-procedure-consolidate-0.4.1.gem.sha512
68
68
  - checksums/standard-procedure-consolidate-0.4.2.gem.sha512
69
69
  - checksums/standard-procedure-consolidate-0.4.3.gem.sha512
70
+ - checksums/standard-procedure-consolidate-0.4.4.gem.sha512
70
71
  - exe/consolidate
71
72
  - exe/examine
72
73
  - lib/consolidate.rb