mojo_magick 0.5.6 → 0.6.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 +5 -5
 - data/.circleci/config.yml +25 -0
 - data/.github/dependabot.yml +8 -0
 - data/.rubocop-common.yml +99 -0
 - data/.rubocop-performance.yml +2 -0
 - data/.rubocop.yml +11 -0
 - data/.ruby-version +1 -1
 - data/Gemfile +6 -1
 - data/Gemfile.lock +53 -11
 - data/README.md +35 -4
 - data/Rakefile +14 -12
 - data/examples/animated_gif.rb +11 -14
 - data/examples/composite.rb +11 -14
 - data/init.rb +1 -3
 - data/lib/image_magick/fonts.rb +4 -11
 - data/lib/mojo_magick.rb +115 -106
 - data/lib/mojo_magick/command_status.rb +3 -2
 - data/lib/mojo_magick/commands.rb +32 -0
 - data/lib/mojo_magick/errors.rb +1 -1
 - data/lib/mojo_magick/font.rb +4 -7
 - data/lib/mojo_magick/opt_builder.rb +24 -35
 - data/lib/mojo_magick/util/font_parser.rb +43 -0
 - data/lib/mojo_magick/util/parser.rb +11 -60
 - data/lib/mojo_magick/version.rb +1 -1
 - data/mojo_magick.gemspec +19 -15
 - data/test/fixtures/roll with it.jpg +0 -0
 - data/test/font_parser_test.rb +29 -0
 - data/test/font_test.rb +22 -28
 - data/test/mojo_magick_test.rb +288 -283
 - data/test/opt_builder_test.rb +105 -89
 - data/test/test_helper.rb +6 -5
 - metadata +63 -18
 - data/lib/image_magick/resource_limits.rb +0 -96
 - data/lib/initializers/hash.rb +0 -8
 - data/test/fonts_test.rb +0 -12
 - data/test/parser_test.rb +0 -30
 - data/test/resource_limits_test.rb +0 -51
 
    
        data/test/opt_builder_test.rb
    CHANGED
    
    | 
         @@ -1,7 +1,6 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            class MojoMagickOptBuilderTest < MiniTest::Unit::TestCase
         
     | 
| 
      
 1 
     | 
    
         
            +
            require_relative "test_helper"
         
     | 
| 
       4 
2 
     | 
    
         | 
| 
      
 3 
     | 
    
         
            +
            class MojoMagickOptBuilderTest < MiniTest::Test
         
     | 
| 
       5 
4 
     | 
    
         
             
              # These tests make the assumption that if we call #raw_command with the
         
     | 
| 
       6 
5 
     | 
    
         
             
              # correct strings, ImageMagick itself will operate correctly. We're only
         
     | 
| 
       7 
6 
     | 
    
         
             
              # verifying that the option builder produces the correct strings
         
     | 
| 
         @@ -11,122 +10,139 @@ class MojoMagickOptBuilderTest < MiniTest::Unit::TestCase 
     | 
|
| 
       11 
10 
     | 
    
         
             
              end
         
     | 
| 
       12 
11 
     | 
    
         | 
| 
       13 
12 
     | 
    
         
             
              def test_annotate
         
     | 
| 
       14 
     | 
    
         
            -
                @builder.annotate  
     | 
| 
       15 
     | 
    
         
            -
                assert_equal 
     | 
| 
      
 13 
     | 
    
         
            +
                @builder.annotate "blah"
         
     | 
| 
      
 14 
     | 
    
         
            +
                assert_equal %w[-annotate 0 blah], @builder.to_a
         
     | 
| 
       16 
15 
     | 
    
         
             
              end
         
     | 
| 
       17 
16 
     | 
    
         | 
| 
       18 
17 
     | 
    
         
             
              def test_annotate_with_escapeable_string
         
     | 
| 
       19 
     | 
    
         
            -
                @builder.annotate  
     | 
| 
       20 
     | 
    
         
            -
                assert_equal  
     | 
| 
      
 18 
     | 
    
         
            +
                @builder.annotate "it's"
         
     | 
| 
      
 19 
     | 
    
         
            +
                assert_equal %w[-annotate 0 it's], @builder.to_a
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              def test_annotate_with_multiple_args
         
     | 
| 
      
 23 
     | 
    
         
            +
                @builder.annotate "5 it's"
         
     | 
| 
      
 24 
     | 
    
         
            +
                assert_equal ["-annotate", "0", "5 it's"], @builder.to_a
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              def test_annotate_with_geometry_args
         
     | 
| 
      
 28 
     | 
    
         
            +
                @builder.annotate "this thing", geometry: 3
         
     | 
| 
      
 29 
     | 
    
         
            +
                assert_equal ["-annotate", "3", "this thing"], @builder.to_a
         
     | 
| 
       21 
30 
     | 
    
         
             
              end
         
     | 
| 
       22 
31 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
              def  
     | 
| 
       24 
     | 
    
         
            -
                @builder.annotate  
     | 
| 
       25 
     | 
    
         
            -
                assert_equal  
     | 
| 
      
 32 
     | 
    
         
            +
              def test_annotate_with_full_array_args
         
     | 
| 
      
 33 
     | 
    
         
            +
                @builder.annotate "this", "thing", geometry: 3
         
     | 
| 
      
 34 
     | 
    
         
            +
                assert_equal ["-annotate", "3", "thisthing"], @builder.to_a
         
     | 
| 
       26 
35 
     | 
    
         
             
              end
         
     | 
| 
       27 
36 
     | 
    
         | 
| 
       28 
37 
     | 
    
         
             
              def test_option_builder_with_blocks
         
     | 
| 
       29 
38 
     | 
    
         
             
                # Passing in basic commands produces a string
         
     | 
| 
       30 
     | 
    
         
            -
                 
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
                  b.background 'red'
         
     | 
| 
      
 39 
     | 
    
         
            +
                @builder.image_block do
         
     | 
| 
      
 40 
     | 
    
         
            +
                  @builder.background "red"
         
     | 
| 
       33 
41 
     | 
    
         
             
                end
         
     | 
| 
       34 
     | 
    
         
            -
                 
     | 
| 
       35 
     | 
    
         
            -
                   
     | 
| 
      
 42 
     | 
    
         
            +
                @builder.image_block do
         
     | 
| 
      
 43 
     | 
    
         
            +
                  @builder.background "blue"
         
     | 
| 
       36 
44 
     | 
    
         
             
                end
         
     | 
| 
       37 
     | 
    
         
            -
                assert_equal '\( -background red \) \( -background blue \)',  
     | 
| 
      
 45 
     | 
    
         
            +
                assert_equal ['\(', "-background", "red", '\)', '\(', "-background", "blue", '\)'], @builder.to_a
         
     | 
| 
       38 
46 
     | 
    
         
             
              end
         
     | 
| 
       39 
47 
     | 
    
         | 
| 
       40 
     | 
    
         
            -
              def test_option_builder_with_hex_colors 
     | 
| 
       41 
     | 
    
         
            -
                 
     | 
| 
       42 
     | 
    
         
            -
                 
     | 
| 
       43 
     | 
    
         
            -
                assert_equal '-background "#000000"', b.to_s
         
     | 
| 
      
 48 
     | 
    
         
            +
              def test_option_builder_with_hex_colors
         
     | 
| 
      
 49 
     | 
    
         
            +
                @builder.background "#000000"
         
     | 
| 
      
 50 
     | 
    
         
            +
                assert_equal %w[-background #000000], @builder.to_a
         
     | 
| 
       44 
51 
     | 
    
         
             
              end
         
     | 
| 
       45 
52 
     | 
    
         | 
| 
       46 
53 
     | 
    
         
             
              def test_option_builder
         
     | 
| 
       47 
     | 
    
         
            -
                 
     | 
| 
       48 
     | 
    
         
            -
                 
     | 
| 
       49 
     | 
    
         
            -
                 
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
                assert_equal '-strip -repage', b.to_s
         
     | 
| 
      
 54 
     | 
    
         
            +
                @builder.strip
         
     | 
| 
      
 55 
     | 
    
         
            +
                @builder.repage
         
     | 
| 
      
 56 
     | 
    
         
            +
                assert_equal %w[-strip -repage], @builder.to_a
         
     | 
| 
      
 57 
     | 
    
         
            +
              end
         
     | 
| 
       52 
58 
     | 
    
         | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
                 
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
      
 59 
     | 
    
         
            +
              def test_opt_builder_chaining_commands
         
     | 
| 
      
 60 
     | 
    
         
            +
                assert_equal %w[-strip -repage], @builder.strip.repage.to_a
         
     | 
| 
      
 61 
     | 
    
         
            +
              end
         
     | 
| 
       56 
62 
     | 
    
         | 
| 
      
 63 
     | 
    
         
            +
              def test_opt_builder_interpreting_bang_suffix
         
     | 
| 
       57 
64 
     | 
    
         
             
                # Bang (!) indicates the plus version of commands
         
     | 
| 
       58 
     | 
    
         
            -
                b = MojoMagick::OptBuilder.new
         
     | 
| 
       59 
     | 
    
         
            -
                b.repage
         
     | 
| 
       60 
     | 
    
         
            -
                b.repage!
         
     | 
| 
       61 
     | 
    
         
            -
                assert_equal '-repage +repage', b.to_s
         
     | 
| 
       62 
65 
     | 
    
         | 
| 
       63 
     | 
    
         
            -
                 
     | 
| 
       64 
     | 
    
         
            -
                 
     | 
| 
       65 
     | 
    
         
            -
                 
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
                b.opt2
         
     | 
| 
       68 
     | 
    
         
            -
                assert_equal '-opt1 a ! b ! -opt2', b.to_s
         
     | 
| 
      
 66 
     | 
    
         
            +
                @builder.repage
         
     | 
| 
      
 67 
     | 
    
         
            +
                @builder.repage!
         
     | 
| 
      
 68 
     | 
    
         
            +
                assert_equal %w[-repage +repage], @builder.to_a
         
     | 
| 
      
 69 
     | 
    
         
            +
              end
         
     | 
| 
       69 
70 
     | 
    
         | 
| 
      
 71 
     | 
    
         
            +
              def test_opt_builder_pushing_raw_data
         
     | 
| 
       70 
72 
     | 
    
         
             
                # Treats an array of raw data as different arguments
         
     | 
| 
       71 
     | 
    
         
            -
                b = MojoMagick::OptBuilder.new
         
     | 
| 
       72 
     | 
    
         
            -
                b << ['leave this data','alone']
         
     | 
| 
       73 
     | 
    
         
            -
                assert_equal 'leave this data alone', b.to_s
         
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
                # String includes command arguments
         
     | 
| 
       76 
     | 
    
         
            -
                b = MojoMagick::OptBuilder.new
         
     | 
| 
       77 
     | 
    
         
            -
                b.extent '256x256+0+0'
         
     | 
| 
       78 
     | 
    
         
            -
                b.crop '64x64'
         
     | 
| 
       79 
     | 
    
         
            -
                assert_equal '-extent 256x256+0+0 -crop 64x64', b.to_s
         
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
                # Arguments are quoted (doublequote) if appropriate
         
     | 
| 
       82 
     | 
    
         
            -
                b = MojoMagick::OptBuilder.new
         
     | 
| 
       83 
     | 
    
         
            -
                b.comment 'white space'
         
     | 
| 
       84 
     | 
    
         
            -
                b.comment 'w&b'
         
     | 
| 
       85 
     | 
    
         
            -
                b.crop '6x6^'
         
     | 
| 
       86 
     | 
    
         
            -
                assert_equal '-comment "white space" -comment "w&b" -crop "6x6^"', b.to_s
         
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
                # Existing doublequotes are escaped
         
     | 
| 
       89 
     | 
    
         
            -
                b = MojoMagick::OptBuilder.new
         
     | 
| 
       90 
     | 
    
         
            -
                b.comment 'Fred "Woot" Rook'
         
     | 
| 
       91 
     | 
    
         
            -
                assert_equal '-comment "Fred \"Woot\" Rook"', b.to_s
         
     | 
| 
       92 
73 
     | 
    
         | 
| 
      
 74 
     | 
    
         
            +
                @builder << ["leave this data", "alone"]
         
     | 
| 
      
 75 
     | 
    
         
            +
                assert_equal ["leave this data", "alone"], @builder.to_a
         
     | 
| 
      
 76 
     | 
    
         
            +
              end
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
              def test_opt_builder_complex_command_arg
         
     | 
| 
      
 79 
     | 
    
         
            +
                @builder.extent "256x256+0+0"
         
     | 
| 
      
 80 
     | 
    
         
            +
                @builder.crop "64x64"
         
     | 
| 
      
 81 
     | 
    
         
            +
                assert_equal %w[-extent 256x256+0+0 -crop 64x64], @builder.to_a
         
     | 
| 
      
 82 
     | 
    
         
            +
              end
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
              def test_opt_builder_multi_arg_command_quoting
         
     | 
| 
       93 
85 
     | 
    
         
             
                # Multi-argument commands should not be quoted together
         
     | 
| 
       94 
     | 
    
         
            -
                b = MojoMagick::OptBuilder.new
         
     | 
| 
       95 
     | 
    
         
            -
                b.set 'comment', 'the "best" comment'
         
     | 
| 
       96 
     | 
    
         
            -
                assert_equal '-set comment "the \"best\" comment"', b.to_s
         
     | 
| 
       97 
86 
     | 
    
         | 
| 
      
 87 
     | 
    
         
            +
                @builder.set "comment", 'the "best" comment'
         
     | 
| 
      
 88 
     | 
    
         
            +
                assert_equal ["-set", "comment", "the \"best\" comment"], @builder.to_a
         
     | 
| 
      
 89 
     | 
    
         
            +
              end
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
              def test_opt_builder_with_custom_commands_and_raw_data
         
     | 
| 
      
 92 
     | 
    
         
            +
                # Accepts raw data as-is
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
                @builder.opt1
         
     | 
| 
      
 95 
     | 
    
         
            +
                @builder << "a ! b !"
         
     | 
| 
      
 96 
     | 
    
         
            +
                @builder.opt2
         
     | 
| 
      
 97 
     | 
    
         
            +
                assert_equal ["-opt1", "a ! b !", "-opt2"], @builder.to_a
         
     | 
| 
      
 98 
     | 
    
         
            +
              end
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
              def test_opt_builder_file_and_files
         
     | 
| 
       98 
101 
     | 
    
         
             
                # File and files are helper methods
         
     | 
| 
       99 
     | 
    
         
            -
                b = MojoMagick::OptBuilder.new
         
     | 
| 
       100 
     | 
    
         
            -
                b.files 'source.jpg', 'source2.jpg'
         
     | 
| 
       101 
     | 
    
         
            -
                b.append
         
     | 
| 
       102 
     | 
    
         
            -
                b.crop '64x64'
         
     | 
| 
       103 
     | 
    
         
            -
                b.file 'dest%d.jpg'
         
     | 
| 
       104 
     | 
    
         
            -
                assert_equal 'source.jpg source2.jpg -append -crop 64x64 dest%d.jpg', b.to_s
         
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
                # Files are quoted (doublequote) if appropriate
         
     | 
| 
       107 
     | 
    
         
            -
                b = MojoMagick::OptBuilder.new
         
     | 
| 
       108 
     | 
    
         
            -
                b.file 'probably on windows.jpg'
         
     | 
| 
       109 
     | 
    
         
            -
                assert_equal '"probably on windows.jpg"', b.to_s
         
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
       111 
     | 
    
         
            -
                # Blob is a shortcut for the #tempfile helper method
         
     | 
| 
       112 
     | 
    
         
            -
                b = MojoMagick::OptBuilder.new
         
     | 
| 
       113 
     | 
    
         
            -
                b.blob 'binary data'
         
     | 
| 
       114 
     | 
    
         
            -
                filename = b.to_s
         
     | 
| 
       115 
     | 
    
         
            -
                File.open(filename, 'rb') do |f|
         
     | 
| 
       116 
     | 
    
         
            -
                  assert_equal 'binary data', f.read
         
     | 
| 
       117 
     | 
    
         
            -
                end
         
     | 
| 
       118 
102 
     | 
    
         | 
| 
       119 
     | 
    
         
            -
                 
     | 
| 
       120 
     | 
    
         
            -
                 
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
      
 103 
     | 
    
         
            +
                @builder.files "source.jpg", "source2.jpg"
         
     | 
| 
      
 104 
     | 
    
         
            +
                @builder.append
         
     | 
| 
      
 105 
     | 
    
         
            +
                @builder.crop "64x64"
         
     | 
| 
      
 106 
     | 
    
         
            +
                @builder.file "dest%d.jpg"
         
     | 
| 
      
 107 
     | 
    
         
            +
                assert_equal %w[source.jpg source2.jpg -append -crop 64x64 dest%d.jpg], @builder.to_a
         
     | 
| 
      
 108 
     | 
    
         
            +
              end
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
              def test_opt_builder_file_preserves_whitespace
         
     | 
| 
      
 111 
     | 
    
         
            +
                @builder.file "probably on windows.jpg"
         
     | 
| 
      
 112 
     | 
    
         
            +
                assert_equal ["probably on windows.jpg"], @builder.to_a
         
     | 
| 
      
 113 
     | 
    
         
            +
              end
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
              def test_opt_builder_comment
         
     | 
| 
      
 116 
     | 
    
         
            +
                @builder.comment "white space"
         
     | 
| 
      
 117 
     | 
    
         
            +
                @builder.comment "w&b"
         
     | 
| 
      
 118 
     | 
    
         
            +
                @builder.crop "6x6^"
         
     | 
| 
      
 119 
     | 
    
         
            +
                assert_equal ["-comment", "white space", "-comment", "w&b", "-crop", "6x6^"], @builder.to_a
         
     | 
| 
      
 120 
     | 
    
         
            +
              end
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
              def test_opt_builder_comment_with_quoted_elements
         
     | 
| 
      
 123 
     | 
    
         
            +
                @builder.comment 'Fred "Woot" Rook'
         
     | 
| 
      
 124 
     | 
    
         
            +
                assert_equal ["-comment", "Fred \"Woot\" Rook"], @builder.to_a
         
     | 
| 
      
 125 
     | 
    
         
            +
              end
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
              def test_opt_builder_blob_writes_data_to_temp_file
         
     | 
| 
      
 128 
     | 
    
         
            +
                @builder.blob "binary data"
         
     | 
| 
       125 
129 
     | 
    
         | 
| 
      
 130 
     | 
    
         
            +
                filename = @builder.to_a.first
         
     | 
| 
      
 131 
     | 
    
         
            +
                File.open(filename, "rb") do |f|
         
     | 
| 
      
 132 
     | 
    
         
            +
                  assert_equal "binary data", f.read
         
     | 
| 
      
 133 
     | 
    
         
            +
                end
         
     | 
| 
      
 134 
     | 
    
         
            +
              end
         
     | 
| 
      
 135 
     | 
    
         
            +
             
     | 
| 
      
 136 
     | 
    
         
            +
              def test_opt_builder_label
         
     | 
| 
      
 137 
     | 
    
         
            +
                # label for text should use 'label:"the string"' if specified
         
     | 
| 
      
 138 
     | 
    
         
            +
                [%w[mylabel mylabel],
         
     | 
| 
      
 139 
     | 
    
         
            +
                 ['my " label', '"my \" label"'],
         
     | 
| 
      
 140 
     | 
    
         
            +
                 ["Rock it, cuz i said so!", '"Rock it, cuz i said so!"'],
         
     | 
| 
      
 141 
     | 
    
         
            +
                 ["it's like this", '"it\'s like this"'],
         
     | 
| 
      
 142 
     | 
    
         
            +
                 ["\#$%^&*", '"#$%^&*"']].each do |labels|
         
     | 
| 
       126 
143 
     | 
    
         
             
                  b = MojoMagick::OptBuilder.new
         
     | 
| 
       127 
144 
     | 
    
         
             
                  b.label labels[0]
         
     | 
| 
       128 
     | 
    
         
            -
                  assert_equal "label:#{labels[1]}", b. 
     | 
| 
      
 145 
     | 
    
         
            +
                  assert_equal ["label:#{labels[1]}"], b.to_a
         
     | 
| 
       129 
146 
     | 
    
         
             
                end
         
     | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
       131 
147 
     | 
    
         
             
              end
         
     | 
| 
       132 
148 
     | 
    
         
             
            end
         
     | 
    
        data/test/test_helper.rb
    CHANGED
    
    | 
         @@ -1,6 +1,7 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require  
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            require 'fileutils'
         
     | 
| 
       4 
     | 
    
         
            -
            require 'tempfile'
         
     | 
| 
       5 
     | 
    
         
            -
            require 'rspec/expectations'
         
     | 
| 
      
 1 
     | 
    
         
            +
            require "simplecov"
         
     | 
| 
      
 2 
     | 
    
         
            +
            SimpleCov.start
         
     | 
| 
       6 
3 
     | 
    
         | 
| 
      
 4 
     | 
    
         
            +
            require "minitest/autorun"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require File.expand_path(File.join(File.dirname(__FILE__), "..", "init"))
         
     | 
| 
      
 6 
     | 
    
         
            +
            require "fileutils"
         
     | 
| 
      
 7 
     | 
    
         
            +
            require "tempfile"
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,17 +1,59 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: mojo_magick
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.6.4
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Steve Midgley
         
     | 
| 
       8 
8 
     | 
    
         
             
            - Elliot Nelson
         
     | 
| 
       9 
9 
     | 
    
         
             
            - Jon Rogers
         
     | 
| 
       10 
     | 
    
         
            -
            autorequire: 
     | 
| 
      
 10 
     | 
    
         
            +
            autorequire:
         
     | 
| 
       11 
11 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       12 
12 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       13 
     | 
    
         
            -
            date:  
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2021-01-24 00:00:00.000000000 Z
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies:
         
     | 
| 
      
 15 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 16 
     | 
    
         
            +
              name: bundle-audit
         
     | 
| 
      
 17 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 18 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 19 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 20 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 21 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 22 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 23 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 24 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 25 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 26 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 27 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 28 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 29 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 30 
     | 
    
         
            +
              name: bundler
         
     | 
| 
      
 31 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 32 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 33 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 34 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 35 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 36 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 37 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 38 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 39 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 40 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 41 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 42 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 43 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 44 
     | 
    
         
            +
              name: minitest
         
     | 
| 
      
 45 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 46 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 47 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 48 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 49 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 50 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 51 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 52 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 53 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 54 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 55 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 56 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
       15 
57 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       16 
58 
     | 
    
         
             
              name: rake
         
     | 
| 
       17 
59 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
         @@ -27,7 +69,7 @@ dependencies: 
     | 
|
| 
       27 
69 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       28 
70 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       29 
71 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       30 
     | 
    
         
            -
              name:  
     | 
| 
      
 72 
     | 
    
         
            +
              name: rubocop
         
     | 
| 
       31 
73 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       32 
74 
     | 
    
         
             
                requirements:
         
     | 
| 
       33 
75 
     | 
    
         
             
                - - ">="
         
     | 
| 
         @@ -41,7 +83,7 @@ dependencies: 
     | 
|
| 
       41 
83 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       42 
84 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       43 
85 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       44 
     | 
    
         
            -
              name:  
     | 
| 
      
 86 
     | 
    
         
            +
              name: rubocop-performance
         
     | 
| 
       45 
87 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       46 
88 
     | 
    
         
             
                requirements:
         
     | 
| 
       47 
89 
     | 
    
         
             
                - - ">="
         
     | 
| 
         @@ -62,7 +104,12 @@ executables: [] 
     | 
|
| 
       62 
104 
     | 
    
         
             
            extensions: []
         
     | 
| 
       63 
105 
     | 
    
         
             
            extra_rdoc_files: []
         
     | 
| 
       64 
106 
     | 
    
         
             
            files:
         
     | 
| 
      
 107 
     | 
    
         
            +
            - ".circleci/config.yml"
         
     | 
| 
      
 108 
     | 
    
         
            +
            - ".github/dependabot.yml"
         
     | 
| 
       65 
109 
     | 
    
         
             
            - ".gitignore"
         
     | 
| 
      
 110 
     | 
    
         
            +
            - ".rubocop-common.yml"
         
     | 
| 
      
 111 
     | 
    
         
            +
            - ".rubocop-performance.yml"
         
     | 
| 
      
 112 
     | 
    
         
            +
            - ".rubocop.yml"
         
     | 
| 
       66 
113 
     | 
    
         
             
            - ".ruby-version"
         
     | 
| 
       67 
114 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       68 
115 
     | 
    
         
             
            - Gemfile.lock
         
     | 
| 
         @@ -73,25 +120,24 @@ files: 
     | 
|
| 
       73 
120 
     | 
    
         
             
            - examples/composite.rb
         
     | 
| 
       74 
121 
     | 
    
         
             
            - init.rb
         
     | 
| 
       75 
122 
     | 
    
         
             
            - lib/image_magick/fonts.rb
         
     | 
| 
       76 
     | 
    
         
            -
            - lib/image_magick/resource_limits.rb
         
     | 
| 
       77 
     | 
    
         
            -
            - lib/initializers/hash.rb
         
     | 
| 
       78 
123 
     | 
    
         
             
            - lib/mojo_magick.rb
         
     | 
| 
       79 
124 
     | 
    
         
             
            - lib/mojo_magick/command_status.rb
         
     | 
| 
      
 125 
     | 
    
         
            +
            - lib/mojo_magick/commands.rb
         
     | 
| 
       80 
126 
     | 
    
         
             
            - lib/mojo_magick/errors.rb
         
     | 
| 
       81 
127 
     | 
    
         
             
            - lib/mojo_magick/font.rb
         
     | 
| 
       82 
128 
     | 
    
         
             
            - lib/mojo_magick/opt_builder.rb
         
     | 
| 
      
 129 
     | 
    
         
            +
            - lib/mojo_magick/util/font_parser.rb
         
     | 
| 
       83 
130 
     | 
    
         
             
            - lib/mojo_magick/util/parser.rb
         
     | 
| 
       84 
131 
     | 
    
         
             
            - lib/mojo_magick/version.rb
         
     | 
| 
       85 
132 
     | 
    
         
             
            - mojo_magick.gemspec
         
     | 
| 
       86 
133 
     | 
    
         
             
            - test/fixtures/5742.jpg
         
     | 
| 
       87 
134 
     | 
    
         
             
            - test/fixtures/not_an_image.jpg
         
     | 
| 
      
 135 
     | 
    
         
            +
            - test/fixtures/roll with it.jpg
         
     | 
| 
       88 
136 
     | 
    
         
             
            - test/fixtures/zero_byte_image.jpg
         
     | 
| 
      
 137 
     | 
    
         
            +
            - test/font_parser_test.rb
         
     | 
| 
       89 
138 
     | 
    
         
             
            - test/font_test.rb
         
     | 
| 
       90 
     | 
    
         
            -
            - test/fonts_test.rb
         
     | 
| 
       91 
139 
     | 
    
         
             
            - test/mojo_magick_test.rb
         
     | 
| 
       92 
140 
     | 
    
         
             
            - test/opt_builder_test.rb
         
     | 
| 
       93 
     | 
    
         
            -
            - test/parser_test.rb
         
     | 
| 
       94 
     | 
    
         
            -
            - test/resource_limits_test.rb
         
     | 
| 
       95 
141 
     | 
    
         
             
            - test/test_helper.rb
         
     | 
| 
       96 
142 
     | 
    
         
             
            homepage: http://github.com/rcode5/mojo_magick
         
     | 
| 
       97 
143 
     | 
    
         
             
            licenses:
         
     | 
| 
         @@ -113,26 +159,25 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       113 
159 
     | 
    
         
             
              requirements:
         
     | 
| 
       114 
160 
     | 
    
         
             
              - - ">="
         
     | 
| 
       115 
161 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       116 
     | 
    
         
            -
                  version:  
     | 
| 
      
 162 
     | 
    
         
            +
                  version: 2.6.0
         
     | 
| 
       117 
163 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       118 
164 
     | 
    
         
             
              requirements:
         
     | 
| 
       119 
165 
     | 
    
         
             
              - - ">="
         
     | 
| 
       120 
166 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       121 
167 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       122 
168 
     | 
    
         
             
            requirements: []
         
     | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
            signing_key: 
         
     | 
| 
      
 169 
     | 
    
         
            +
            rubygems_version: 3.0.3
         
     | 
| 
      
 170 
     | 
    
         
            +
            signing_key:
         
     | 
| 
       126 
171 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       127 
     | 
    
         
            -
            summary: mojo_magick-0. 
     | 
| 
      
 172 
     | 
    
         
            +
            summary: mojo_magick-0.6.4
         
     | 
| 
       128 
173 
     | 
    
         
             
            test_files:
         
     | 
| 
       129 
174 
     | 
    
         
             
            - test/fixtures/5742.jpg
         
     | 
| 
       130 
175 
     | 
    
         
             
            - test/fixtures/not_an_image.jpg
         
     | 
| 
      
 176 
     | 
    
         
            +
            - test/fixtures/roll with it.jpg
         
     | 
| 
       131 
177 
     | 
    
         
             
            - test/fixtures/zero_byte_image.jpg
         
     | 
| 
      
 178 
     | 
    
         
            +
            - test/font_parser_test.rb
         
     | 
| 
       132 
179 
     | 
    
         
             
            - test/font_test.rb
         
     | 
| 
       133 
     | 
    
         
            -
            - test/fonts_test.rb
         
     | 
| 
       134 
180 
     | 
    
         
             
            - test/mojo_magick_test.rb
         
     | 
| 
       135 
181 
     | 
    
         
             
            - test/opt_builder_test.rb
         
     | 
| 
       136 
     | 
    
         
            -
            - test/parser_test.rb
         
     | 
| 
       137 
     | 
    
         
            -
            - test/resource_limits_test.rb
         
     | 
| 
       138 
182 
     | 
    
         
             
            - test/test_helper.rb
         
     | 
| 
      
 183 
     | 
    
         
            +
            ...
         
     | 
| 
         @@ -1,96 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # This module provides some mix-in methods to permit resource limitation commands in MojoMagick
         
     | 
| 
       2 
     | 
    
         
            -
            module ImageMagick
         
     | 
| 
       3 
     | 
    
         
            -
              module ResourceLimits
         
     | 
| 
       4 
     | 
    
         
            -
                @@resource_limits = {}
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
                # controls limits on memory and other resources for imagemagick.
         
     | 
| 
       7 
     | 
    
         
            -
                # possible values for type can include:
         
     | 
| 
       8 
     | 
    
         
            -
                #    Area, Disk, File, Map, or Memory
         
     | 
| 
       9 
     | 
    
         
            -
                # value is byte size for everything but Disk, where it's number of files
         
     | 
| 
       10 
     | 
    
         
            -
                # type can be string or symbol.
         
     | 
| 
       11 
     | 
    
         
            -
                # Just limiting Memory will not solve problems with imagemagick going out of
         
     | 
| 
       12 
     | 
    
         
            -
                # control with resource consumption on certain bad files. You have to set disk,
         
     | 
| 
       13 
     | 
    
         
            -
                # area and map limits too. Read up on imagemagick website for more.
         
     | 
| 
       14 
     | 
    
         
            -
                # Different options have different units
         
     | 
| 
       15 
     | 
    
         
            -
                #   DISK: N GB
         
     | 
| 
       16 
     | 
    
         
            -
                #   AREA, MAP, MEMORY: N MB
         
     | 
| 
       17 
     | 
    
         
            -
                #   FILE: N num file handles
         
     | 
| 
       18 
     | 
    
         
            -
                # Examples:
         
     | 
| 
       19 
     | 
    
         
            -
                #   # set disk to 5 gigabytes limit
         
     | 
| 
       20 
     | 
    
         
            -
                #   MiniMagick::Image::set_limit(:disk => 5)
         
     | 
| 
       21 
     | 
    
         
            -
                #   # set memory to 32mb, map to 64mb and disk to 0
         
     | 
| 
       22 
     | 
    
         
            -
                #   MiniMagick::Image::set_limit(:memory => 32, 'map' => 64, 'disk' => 0)
         
     | 
| 
       23 
     | 
    
         
            -
                  def set_limits(options)
         
     | 
| 
       24 
     | 
    
         
            -
                    mem_fix = 1
         
     | 
| 
       25 
     | 
    
         
            -
                    options.each do |resource, value|
         
     | 
| 
       26 
     | 
    
         
            -
                      @@resource_limits[resource.to_s.downcase.to_sym] = value.to_s
         
     | 
| 
       27 
     | 
    
         
            -
                    end
         
     | 
| 
       28 
     | 
    
         
            -
                  end
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
                  # remove a limit
         
     | 
| 
       31 
     | 
    
         
            -
                  def remove_limits(*options)
         
     | 
| 
       32 
     | 
    
         
            -
                    mem_fix = 1
         
     | 
| 
       33 
     | 
    
         
            -
                    @@resource_limits.delete_if do |resource, value|
         
     | 
| 
       34 
     | 
    
         
            -
                      idx = options.index(resource)
         
     | 
| 
       35 
     | 
    
         
            -
                      resource == options.values_at(idx)[0].to_s.downcase.to_sym if idx
         
     | 
| 
       36 
     | 
    
         
            -
                    end
         
     | 
| 
       37 
     | 
    
         
            -
                  end
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
                  # remove limits from resources
         
     | 
| 
       40 
     | 
    
         
            -
                  def unset_limits(options = {})
         
     | 
| 
       41 
     | 
    
         
            -
                    mem_fix = 1
         
     | 
| 
       42 
     | 
    
         
            -
                    @@resource_limits = {}
         
     | 
| 
       43 
     | 
    
         
            -
                    if options[:unset_env]
         
     | 
| 
       44 
     | 
    
         
            -
                      ENV["MAGICK_AREA_LIMIT"]=nil
         
     | 
| 
       45 
     | 
    
         
            -
                      ENV["MAGICK_MAP_LIMIT"]=nil
         
     | 
| 
       46 
     | 
    
         
            -
                      ENV["MAGICK_MEMORY_LIMIT"]=nil
         
     | 
| 
       47 
     | 
    
         
            -
                      ENV["MAGICK_DISK_LIMIT"]=nil
         
     | 
| 
       48 
     | 
    
         
            -
                    end
         
     | 
| 
       49 
     | 
    
         
            -
                  end
         
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
                  # returns the default limits that imagemagick is using, when run with no "-limit" parameters
         
     | 
| 
       52 
     | 
    
         
            -
                # options:
         
     | 
| 
       53 
     | 
    
         
            -
                #   :show_actual_values => true (default false) - will return integers instead of readable values
         
     | 
| 
       54 
     | 
    
         
            -
                  def get_default_limits(options = {})
         
     | 
| 
       55 
     | 
    
         
            -
                    mem_fix = 1
         
     | 
| 
       56 
     | 
    
         
            -
                    parse_limits(options.merge(:get_current_limits => false))
         
     | 
| 
       57 
     | 
    
         
            -
                  end
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
                  # returns the limits that imagemagick is running based on any "set_limits" calls
         
     | 
| 
       60 
     | 
    
         
            -
                  def get_current_limits(options = {})
         
     | 
| 
       61 
     | 
    
         
            -
                    mem_fix = 1
         
     | 
| 
       62 
     | 
    
         
            -
                    parse_limits(options.merge(:get_current_limits => true))
         
     | 
| 
       63 
     | 
    
         
            -
                  end
         
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
                  alias :get_limits :get_current_limits
         
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
                  def parse_limits(options)
         
     | 
| 
       68 
     | 
    
         
            -
                    show_actual_values = options[:show_actual_values]
         
     | 
| 
       69 
     | 
    
         
            -
                    if options[:get_current_limits]
         
     | 
| 
       70 
     | 
    
         
            -
                      status = self.execute('identify', '-list resource')
         
     | 
| 
       71 
     | 
    
         
            -
                      raw_limits = status.return_value
         
     | 
| 
       72 
     | 
    
         
            -
                    else
         
     | 
| 
       73 
     | 
    
         
            -
                      # we run a raw shell command here to obtain
         
     | 
| 
       74 
     | 
    
         
            -
                      # limits without applying command line limit params
         
     | 
| 
       75 
     | 
    
         
            -
                      raw_limits = `identify -list resource`
         
     | 
| 
       76 
     | 
    
         
            -
                    end
         
     | 
| 
       77 
     | 
    
         
            -
                    actual_values, readable_values = parser.parse_limits(raw_limits)
         
     | 
| 
       78 
     | 
    
         
            -
                    show_actual_values ? actual_values : readable_values
         
     | 
| 
       79 
     | 
    
         
            -
                  end # parse_limits
         
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
                  # returns a string suitable for passing as a set of imagemagick params
         
     | 
| 
       82 
     | 
    
         
            -
                # that contains all the limit constraints
         
     | 
| 
       83 
     | 
    
         
            -
                def get_limits_as_params
         
     | 
| 
       84 
     | 
    
         
            -
                  retval = ''
         
     | 
| 
       85 
     | 
    
         
            -
                  # we upcase the value here for newer versions of ImageMagick (>=6.8.x)
         
     | 
| 
       86 
     | 
    
         
            -
                  @@resource_limits.each do |type, value|
         
     | 
| 
       87 
     | 
    
         
            -
                    retval += " -limit #{type.to_s} #{value.upcase} "
         
     | 
| 
       88 
     | 
    
         
            -
                  end
         
     | 
| 
       89 
     | 
    
         
            -
                  retval
         
     | 
| 
       90 
     | 
    
         
            -
                end
         
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
       92 
     | 
    
         
            -
                def parser
         
     | 
| 
       93 
     | 
    
         
            -
                  @parser ||= MojoMagick::Util::Parser.new
         
     | 
| 
       94 
     | 
    
         
            -
                end
         
     | 
| 
       95 
     | 
    
         
            -
              end
         
     | 
| 
       96 
     | 
    
         
            -
            end
         
     |