standard-procedure-consolidate 0.4.1 → 0.4.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cbb574bced054ba32f67038b7f91eed28836470eb0d40e7bbbbcaefdca41142
|
4
|
+
data.tar.gz: 64438e3b31ea879c4c10d42afa08873a44528ec89ba60d3e248c07baf1bd028b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 947a488ad5d98514589cbaa9495cd7970e7821832a05f74719821d9423785fc9e04f2563b7c4c4c34e5c5c25c32c6a1fd175cbd862e247cdfc2e8612663412b4
|
7
|
+
data.tar.gz: cc6e12303d7abea0be365df9c443d868d18bc658f3696488a6826ce83b93cfd17e588aecc6f3af94a9ac46e9621bc483800effd44e37b550dc752767757fe9fc
|
@@ -2,7 +2,7 @@
|
|
2
2
|
// README at: https://github.com/devcontainers/templates/tree/main/src/ruby
|
3
3
|
{
|
4
4
|
"name": "Ruby",
|
5
|
-
"image": "
|
5
|
+
"image": "ghcr.io/rails/devcontainer/images/ruby:3.3.5",
|
6
6
|
"postCreateCommand": "bundle install",
|
7
7
|
"customizations": {
|
8
8
|
"vscode": {
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.3.5
|
@@ -0,0 +1 @@
|
|
1
|
+
391a0d85024adf2a5866f0dabab3d601e6865c482e4fff5e780af0a6dc6ca36aade243a9e97cdb68552b00fce51d763ed94e89a701ce466428a64df9f4d574a0
|
@@ -7,6 +7,9 @@ module Consolidate
|
|
7
7
|
module Docx
|
8
8
|
class ImageReferenceNodeBuilder < Data.define(:field_name, :image, :node_id, :image_number, :document)
|
9
9
|
def call
|
10
|
+
max_width, max_height = max_dimensions_from(document)
|
11
|
+
scaled_width, scaled_height = scale_dimensions(image.width, image.height, max_width, max_height)
|
12
|
+
|
10
13
|
Nokogiri::XML::Node.new("w:drawing", document).tap do |drawing|
|
11
14
|
drawing["xmlns:a"] = "http://schemas.openxmlformats.org/drawingml/2006/main"
|
12
15
|
drawing << Nokogiri::XML::Node.new("wp:inline", document).tap do |inline|
|
@@ -15,8 +18,8 @@ module Consolidate
|
|
15
18
|
inline["distL"] = "0"
|
16
19
|
inline["distR"] = "0"
|
17
20
|
inline << Nokogiri::XML::Node.new("wp:extent", document).tap do |extent|
|
18
|
-
extent["cx"] =
|
19
|
-
extent["cy"] =
|
21
|
+
extent["cx"] = scaled_width
|
22
|
+
extent["cy"] = scaled_height
|
20
23
|
end
|
21
24
|
inline << Nokogiri::XML::Node.new("wp:effectExtent", document).tap do |effect_extent|
|
22
25
|
effect_extent["l"] = "0"
|
@@ -59,8 +62,8 @@ module Consolidate
|
|
59
62
|
off["y"] = "0"
|
60
63
|
end
|
61
64
|
xfrm << Nokogiri::XML::Node.new("a:ext", document).tap do |ext|
|
62
|
-
ext["cx"] =
|
63
|
-
ext["cy"] =
|
65
|
+
ext["cx"] = scaled_width
|
66
|
+
ext["cy"] = scaled_height
|
64
67
|
end
|
65
68
|
end
|
66
69
|
sp_pr << Nokogiri::XML::Node.new("a:prstGeom", document).tap do |prst_geom|
|
@@ -78,11 +81,32 @@ module Consolidate
|
|
78
81
|
DEFAULT_PAGE_WIDTH = 12_240
|
79
82
|
TWENTIETHS_OF_A_POINT_TO_EMU = 635
|
80
83
|
DEFAULT_PAGE_WIDTH_IN_EMU = DEFAULT_PAGE_WIDTH * TWENTIETHS_OF_A_POINT_TO_EMU
|
84
|
+
EMU_PER_PIXEL = 9525
|
85
|
+
DEFAULT_PAGE_HEIGHT = DEFAULT_PAGE_WIDTH * 11 / 8.5 # Assuming standard page ratio
|
86
|
+
DEFAULT_PAGE_HEIGHT_IN_EMU = DEFAULT_PAGE_HEIGHT * TWENTIETHS_OF_A_POINT_TO_EMU
|
81
87
|
|
82
88
|
private def max_width_from document
|
83
89
|
page_width = (document.at_xpath("//w:sectPr/w:pgSz/@w:w")&.value || DEFAULT_PAGE_WIDTH).to_i
|
84
90
|
page_width * TWENTIETHS_OF_A_POINT_TO_EMU
|
85
91
|
end
|
92
|
+
|
93
|
+
private def max_dimensions_from(document)
|
94
|
+
page_width = (document.at_xpath("//w:sectPr/w:pgSz/@w:w")&.value || DEFAULT_PAGE_WIDTH).to_i
|
95
|
+
page_height = (document.at_xpath("//w:sectPr/w:pgSz/@w:h")&.value || DEFAULT_PAGE_HEIGHT).to_i
|
96
|
+
|
97
|
+
width_emu = page_width * TWENTIETHS_OF_A_POINT_TO_EMU
|
98
|
+
height_emu = page_height * TWENTIETHS_OF_A_POINT_TO_EMU
|
99
|
+
|
100
|
+
[width_emu, height_emu]
|
101
|
+
end
|
102
|
+
|
103
|
+
private def scale_dimensions(width, height, max_width, max_height)
|
104
|
+
width_ratio = max_width.to_f / width
|
105
|
+
height_ratio = max_height.to_f / height
|
106
|
+
scale = [width_ratio, height_ratio, 1.0].min # Never scale up
|
107
|
+
|
108
|
+
[(width * scale).to_i, (height * scale).to_i]
|
109
|
+
end
|
86
110
|
end
|
87
111
|
end
|
88
112
|
end
|
data/lib/consolidate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: standard-procedure-consolidate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rahoul Baruah
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-02-20 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rubyzip
|
@@ -66,6 +65,7 @@ files:
|
|
66
65
|
- checksums/standard-procedure-consolidate-0.3.9.gem.sha512
|
67
66
|
- checksums/standard-procedure-consolidate-0.4.0.gem.sha512
|
68
67
|
- checksums/standard-procedure-consolidate-0.4.1.gem.sha512
|
68
|
+
- checksums/standard-procedure-consolidate-0.4.2.gem.sha512
|
69
69
|
- exe/consolidate
|
70
70
|
- exe/examine
|
71
71
|
- lib/consolidate.rb
|
@@ -84,7 +84,6 @@ metadata:
|
|
84
84
|
homepage_uri: https://github.com/standard-procedure/standard-procedure-consolidate
|
85
85
|
source_code_uri: https://github.com/standard-procedure/standard-procedure-consolidate
|
86
86
|
changelog_uri: https://github.com/standard-procedure/standard-procedure-consolidate/blob/main/CHANGELOG.md
|
87
|
-
post_install_message:
|
88
87
|
rdoc_options: []
|
89
88
|
require_paths:
|
90
89
|
- lib
|
@@ -99,8 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
98
|
- !ruby/object:Gem::Version
|
100
99
|
version: '0'
|
101
100
|
requirements: []
|
102
|
-
rubygems_version: 3.
|
103
|
-
signing_key:
|
101
|
+
rubygems_version: 3.6.2
|
104
102
|
specification_version: 4
|
105
103
|
summary: Simple ruby mailmerge for Microsoft Word .docx files.
|
106
104
|
test_files: []
|