prawndown-ext 0.1.11 → 0.1.12
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 +4 -4
 - data/lib/prawndown/version.rb +1 -1
 - data/lib/prawndown-ext.rb +44 -5
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 6abd3d5ad775ed05ac8dfbe1fc68283104e63bd64aeadb6254bf31759db1b959
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 555e53c35fbd8380eaaa434d024f0d084efdd222e1a7f1376f50bffbe162abc9
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: c7e6004fe66a36371094bd33532664f17250ad7a877f09fa4b1ed1ec12b810987e79738d1179e50db014c010637d07deb1aba0edcce11ef32cf72887993c6a04
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: bf13a1d81efc3d6239d93b37bf002558cbe7fd5d24571dc3b1691fbf2ed23eb69e1511283131adee052ce6507231f98e59d569738d2f35612c02081d80ff3277
         
     | 
    
        data/lib/prawndown/version.rb
    CHANGED
    
    
    
        data/lib/prawndown-ext.rb
    CHANGED
    
    | 
         @@ -37,7 +37,9 @@ module PrawndownExt 
     | 
|
| 
       37 
37 
     | 
    
         
             
            					args["margin"] = 0
         
     | 
| 
       38 
38 
     | 
    
         
             
            				end
         
     | 
| 
       39 
39 
     | 
    
         | 
| 
       40 
     | 
    
         
            -
            				 
     | 
| 
      
 40 
     | 
    
         
            +
            				half_margin = (args["margin"] * 0.5).floor
         
     | 
| 
      
 41 
     | 
    
         
            +
            			
         
     | 
| 
      
 42 
     | 
    
         
            +
            				pdf.pad half_margin do
         
     | 
| 
       41 
43 
     | 
    
         
             
            					pdf.indent args["margin"], args["margin"] do
         
     | 
| 
       42 
44 
     | 
    
         
             
            						pdf.text args["text"], inline_format: true, leading: options[args["command"] + "_line_spacing"].to_f
         
     | 
| 
       43 
45 
     | 
    
         
             
            					end
         
     | 
| 
         @@ -52,6 +54,25 @@ module PrawndownExt 
     | 
|
| 
       52 
54 
     | 
    
         
             
            					end
         
     | 
| 
       53 
55 
     | 
    
         
             
            				end
         
     | 
| 
       54 
56 
     | 
    
         | 
| 
      
 57 
     | 
    
         
            +
            				width = nil
         
     | 
| 
      
 58 
     | 
    
         
            +
            				height = nil
         
     | 
| 
      
 59 
     | 
    
         
            +
            				
         
     | 
| 
      
 60 
     | 
    
         
            +
            				if options.key?("image_width")
         
     | 
| 
      
 61 
     | 
    
         
            +
            					width = options["image_width"].to_i
         
     | 
| 
      
 62 
     | 
    
         
            +
            				end
         
     | 
| 
      
 63 
     | 
    
         
            +
            				
         
     | 
| 
      
 64 
     | 
    
         
            +
            				if options.key?("image_height")
         
     | 
| 
      
 65 
     | 
    
         
            +
            					height = options["image_height"].to_i
         
     | 
| 
      
 66 
     | 
    
         
            +
            				end
         
     | 
| 
      
 67 
     | 
    
         
            +
            				
         
     | 
| 
      
 68 
     | 
    
         
            +
            				if width.nil? && height.nil?
         
     | 
| 
      
 69 
     | 
    
         
            +
            					width = pdf.bounds.width
         
     | 
| 
      
 70 
     | 
    
         
            +
            				end
         
     | 
| 
      
 71 
     | 
    
         
            +
            				
         
     | 
| 
      
 72 
     | 
    
         
            +
            				if !width.nil?
         
     | 
| 
      
 73 
     | 
    
         
            +
            					width = [pdf.bounds.width, width].min
         
     | 
| 
      
 74 
     | 
    
         
            +
            				end
         
     | 
| 
      
 75 
     | 
    
         
            +
            				
         
     | 
| 
       55 
76 
     | 
    
         
             
            				if args["path"][0] == "/"
         
     | 
| 
       56 
77 
     | 
    
         
             
            					args["path"] = args["path"][1..-1]
         
     | 
| 
       57 
78 
     | 
    
         
             
            				end
         
     | 
| 
         @@ -63,14 +84,32 @@ module PrawndownExt 
     | 
|
| 
       63 
84 
     | 
    
         
             
            				end
         
     | 
| 
       64 
85 
     | 
    
         | 
| 
       65 
86 
     | 
    
         
             
            				if File.extname(file) != ".gif"
         
     | 
| 
       66 
     | 
    
         
            -
            					 
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
      
 87 
     | 
    
         
            +
            					if !(height.nil? && width.nil?)
         
     | 
| 
      
 88 
     | 
    
         
            +
            					
         
     | 
| 
      
 89 
     | 
    
         
            +
            						if height.nil? && !width.nil?
         
     | 
| 
      
 90 
     | 
    
         
            +
            							pdf.image(file,
         
     | 
| 
      
 91 
     | 
    
         
            +
            											width: [pdf.bounds.width, width].min,
         
     | 
| 
      
 92 
     | 
    
         
            +
            											position: :center)
         
     | 
| 
      
 93 
     | 
    
         
            +
            						elsif !height.nil? && width.nil?
         
     | 
| 
      
 94 
     | 
    
         
            +
            							pdf.image(file,
         
     | 
| 
      
 95 
     | 
    
         
            +
            											height: height,
         
     | 
| 
      
 96 
     | 
    
         
            +
            											position: :center)
         
     | 
| 
      
 97 
     | 
    
         
            +
            						else
         
     | 
| 
      
 98 
     | 
    
         
            +
            							pdf.image(file,
         
     | 
| 
      
 99 
     | 
    
         
            +
            											width: [pdf.bounds.width, width].min,
         
     | 
| 
      
 100 
     | 
    
         
            +
            											height: height,
         
     | 
| 
      
 101 
     | 
    
         
            +
            											position: :center)
         
     | 
| 
      
 102 
     | 
    
         
            +
            						end
         
     | 
| 
      
 103 
     | 
    
         
            +
            					end
         
     | 
| 
       69 
104 
     | 
    
         
             
            				end
         
     | 
| 
       70 
105 
     | 
    
         
             
            			end
         
     | 
| 
       71 
106 
     | 
    
         | 
| 
       72 
107 
     | 
    
         
             
            			def self.cl_newline args, pdf, options
         
     | 
| 
       73 
     | 
    
         
            -
            				pdf. 
     | 
| 
      
 108 
     | 
    
         
            +
            				if pdf.bounds.instance_of? Prawn::Document::ColumnBox 
         
     | 
| 
      
 109 
     | 
    
         
            +
            					pdf.bounds.move_past_bottom
         
     | 
| 
      
 110 
     | 
    
         
            +
            				else
         
     | 
| 
      
 111 
     | 
    
         
            +
            					pdf.start_new_page
         
     | 
| 
      
 112 
     | 
    
         
            +
            				end
         
     | 
| 
       74 
113 
     | 
    
         
             
            			end
         
     | 
| 
       75 
114 
     | 
    
         | 
| 
       76 
115 
     | 
    
         |