gem-patch 0.1.4 → 0.1.5
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/README.md +2 -0
 - data/lib/rubygems/patcher.rb +7 -3
 - data/rakefile.rb +1 -1
 - data/test/rubygems/test_gem_patch.rb +78 -8
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 5669ae6006115b0c89acbbc4f98c9e761f041bd9
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 19f8c702ec9ff3b55fc7c2da9a26b3ad53b9707e
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: bffd06b0d82ecf682c0ad35f9bd91d2dbbb419d8f9600ee1bfb1c63baa335173cc07cc3e4d636217948c481199b3a80f69aeb3b6b86f743401e84d31fd28c1d0
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 240d800db645308f36b8eeb37d7c7947c0701276bb353087813aecf0953ef29bcb3b1be5fd0966038adf221c5cdca0da081c79ce9ec6d3748e8283966829433e
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -30,6 +30,8 @@ On Fedora you can use YUM: 
     | 
|
| 
       30 
30 
     | 
    
         
             
            | --dry-run | | Print the results from patching, but do not change any files. |
         
     | 
| 
       31 
31 
     | 
    
         
             
            | --verbose | | Print additional info and STDOUT from `patch` command. |
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
      
 33 
     | 
    
         
            +
            For versions higher than 0.1.4 `--dry-run` switch behaviour has been changed and it's not the same as in original `patch` command. Instead, `gem-patch` lets `patch` command modify files, but doesn't override the gem to be patched nor the output file at the end. This way we can easily use dry run also for patches involving more diffs changing each other.
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
       33 
35 
     | 
    
         
             
            ## Requirements
         
     | 
| 
       34 
36 
     | 
    
         | 
| 
       35 
37 
     | 
    
         
             
            This version is build for both RubyGems 1.8  and RubyGems 2.0.
         
     | 
    
        data/lib/rubygems/patcher.rb
    CHANGED
    
    | 
         @@ -39,7 +39,7 @@ class Gem::Patcher 
     | 
|
| 
       39 
39 
     | 
    
         
             
                build_patched_gem
         
     | 
| 
       40 
40 
     | 
    
         | 
| 
       41 
41 
     | 
    
         
             
                options[:outfile] ||= File.join(@output_dir, @package.spec.file_name)
         
     | 
| 
       42 
     | 
    
         
            -
                FileUtils.mv((File.join @target_dir, @package.spec.file_name), options[:outfile])
         
     | 
| 
      
 42 
     | 
    
         
            +
                FileUtils.mv((File.join @target_dir, @package.spec.file_name), options[:outfile]) unless options[:dry_run]
         
     | 
| 
       43 
43 
     | 
    
         | 
| 
       44 
44 
     | 
    
         
             
                # Return the path to the patched gem
         
     | 
| 
       45 
45 
     | 
    
         
             
                options[:outfile]
         
     | 
| 
         @@ -48,14 +48,13 @@ class Gem::Patcher 
     | 
|
| 
       48 
48 
     | 
    
         
             
              def apply_patch(patch, options)
         
     | 
| 
       49 
49 
     | 
    
         
             
                options[:strip] ||= 1
         
     | 
| 
       50 
50 
     | 
    
         
             
                options[:fuzz]  ||= 2
         
     | 
| 
       51 
     | 
    
         
            -
                dry_run = '--dry-run' if options[:dry_run]
         
     | 
| 
       52 
51 
     | 
    
         | 
| 
       53 
52 
     | 
    
         
             
                patch_path = File.expand_path(patch)
         
     | 
| 
       54 
53 
     | 
    
         
             
                info 'Path to the patch to apply: ' + patch_path
         
     | 
| 
       55 
54 
     | 
    
         | 
| 
       56 
55 
     | 
    
         
             
                # Apply the patch by calling 'patch -pNUMBER < patch'
         
     | 
| 
       57 
56 
     | 
    
         
             
                Dir.chdir @target_dir do
         
     | 
| 
       58 
     | 
    
         
            -
                  IO.popen("patch --verbose -p#{options[:strip]} --fuzz=#{options[:fuzz]}  
     | 
| 
      
 57 
     | 
    
         
            +
                  IO.popen("patch --verbose -p#{options[:strip]} --fuzz=#{options[:fuzz]} < #{patch_path} 2>&1") do |out|
         
     | 
| 
       59 
58 
     | 
    
         
             
                    std = out.readlines
         
     | 
| 
       60 
59 
     | 
    
         
             
                    out.close
         
     | 
| 
       61 
60 
     | 
    
         
             
                    info std
         
     | 
| 
         @@ -81,6 +80,11 @@ class Gem::Patcher 
     | 
|
| 
       81 
80 
     | 
    
         
             
                end
         
     | 
| 
       82 
81 
     | 
    
         
             
              end
         
     | 
| 
       83 
82 
     | 
    
         | 
| 
      
 83 
     | 
    
         
            +
              # Return output lines
         
     | 
| 
      
 84 
     | 
    
         
            +
              def output
         
     | 
| 
      
 85 
     | 
    
         
            +
                @output
         
     | 
| 
      
 86 
     | 
    
         
            +
              end
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
       84 
88 
     | 
    
         
             
              private
         
     | 
| 
       85 
89 
     | 
    
         | 
| 
       86 
90 
     | 
    
         
             
              def extract_gem
         
     | 
    
        data/rakefile.rb
    CHANGED
    
    
| 
         @@ -20,7 +20,7 @@ class TestGemPatch < Gem::TestCase 
     | 
|
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
              def test_dry_run
         
     | 
| 
       22 
22 
     | 
    
         
             
                @options[:dry_run] = true
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
       24 
24 
     | 
    
         
             
                gemfile = bake_testing_gem
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
26 
     | 
    
         
             
                patches = []
         
     | 
| 
         @@ -37,6 +37,25 @@ class TestGemPatch < Gem::TestCase 
     | 
|
| 
       37 
37 
     | 
    
         
             
                # Still the same
         
     | 
| 
       38 
38 
     | 
    
         
             
                assert_equal original_file, file_contents('foo.rb')
         
     | 
| 
       39 
39 
     | 
    
         
             
              end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
              ##
         
     | 
| 
      
 42 
     | 
    
         
            +
              # Test dry run should allow modification of the same file
         
     | 
| 
      
 43 
     | 
    
         
            +
              # unlike original --dry-run switch in system patch command
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
              def test_dry_run
         
     | 
| 
      
 46 
     | 
    
         
            +
                @options[:dry_run] = true
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                gemfile = bake_testing_gem
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                patches = []
         
     | 
| 
      
 51 
     | 
    
         
            +
                patches << bake_change_same_file_patch
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                # Creates new patched gem in @gems_dir
         
     | 
| 
      
 54 
     | 
    
         
            +
                patcher = Gem::Patcher.new(gemfile, @gems_dir)
         
     | 
| 
      
 55 
     | 
    
         
            +
                patched_gem = patcher.patch_with(patches, @options)
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                assert_equal 0, /\ASuccesfully patched with.*/ =~ patcher.output.join(' ')
         
     | 
| 
      
 58 
     | 
    
         
            +
              end
         
     | 
| 
       40 
59 
     | 
    
         | 
| 
       41 
60 
     | 
    
         
             
              ##
         
     | 
| 
       42 
61 
     | 
    
         
             
              # Test using outfile for output
         
     | 
| 
         @@ -103,7 +122,7 @@ class TestGemPatch < Gem::TestCase 
     | 
|
| 
       103 
122 
     | 
    
         
             
                package = Gem::Package.new patched_gem
         
     | 
| 
       104 
123 
     | 
    
         
             
                package.extract_files @gems_dir
         
     | 
| 
       105 
124 
     | 
    
         | 
| 
       106 
     | 
    
         
            -
                assert_equal  
     | 
| 
      
 125 
     | 
    
         
            +
                assert_equal patched_file_with_fuzz, file_contents('foo.rb')
         
     | 
| 
       107 
126 
     | 
    
         
             
              end
         
     | 
| 
       108 
127 
     | 
    
         | 
| 
       109 
128 
     | 
    
         
             
              ##
         
     | 
| 
         @@ -204,12 +223,22 @@ class TestGemPatch < Gem::TestCase 
     | 
|
| 
       204 
223 
     | 
    
         | 
| 
       205 
224 
     | 
    
         
             
                patch_path
         
     | 
| 
       206 
225 
     | 
    
         
             
              end
         
     | 
| 
      
 226 
     | 
    
         
            +
             
     | 
| 
      
 227 
     | 
    
         
            +
              def bake_change_same_file_patch
         
     | 
| 
      
 228 
     | 
    
         
            +
                patch_path = File.join(@gems_dir, 'change_same_file.patch')
         
     | 
| 
      
 229 
     | 
    
         
            +
             
     | 
| 
      
 230 
     | 
    
         
            +
                File.open(patch_path, 'w') do |f|
         
     | 
| 
      
 231 
     | 
    
         
            +
                  f.write change_same_file_patch
         
     | 
| 
      
 232 
     | 
    
         
            +
                end
         
     | 
| 
      
 233 
     | 
    
         
            +
             
     | 
| 
      
 234 
     | 
    
         
            +
                patch_path
         
     | 
| 
      
 235 
     | 
    
         
            +
              end
         
     | 
| 
       207 
236 
     | 
    
         | 
| 
       208 
237 
     | 
    
         
             
              def bake_change_file_with_fuzz_patch
         
     | 
| 
       209 
238 
     | 
    
         
             
                patch_path = File.join(@gems_dir, 'change_file_with_fuzz.patch')
         
     | 
| 
       210 
239 
     | 
    
         | 
| 
       211 
240 
     | 
    
         
             
                File.open(patch_path, 'w') do |f|
         
     | 
| 
       212 
     | 
    
         
            -
                  f.write  
     | 
| 
      
 241 
     | 
    
         
            +
                  f.write change_file_with_fuzz_patch
         
     | 
| 
       213 
242 
     | 
    
         
             
                end
         
     | 
| 
       214 
243 
     | 
    
         | 
| 
       215 
244 
     | 
    
         
             
                patch_path
         
     | 
| 
         @@ -334,6 +363,16 @@ class TestGemPatch < Gem::TestCase 
     | 
|
| 
       334 
363 
     | 
    
         
             
                EOF
         
     | 
| 
       335 
364 
     | 
    
         
             
              end
         
     | 
| 
       336 
365 
     | 
    
         | 
| 
      
 366 
     | 
    
         
            +
              def patched_file_with_fuzz
         
     | 
| 
      
 367 
     | 
    
         
            +
                <<-EOF
         
     | 
| 
      
 368 
     | 
    
         
            +
                  module Foo
         
     | 
| 
      
 369 
     | 
    
         
            +
                    def bar
         
     | 
| 
      
 370 
     | 
    
         
            +
                      'Patched'
         
     | 
| 
      
 371 
     | 
    
         
            +
                    end
         
     | 
| 
      
 372 
     | 
    
         
            +
                  end
         
     | 
| 
      
 373 
     | 
    
         
            +
                EOF
         
     | 
| 
      
 374 
     | 
    
         
            +
              end
         
     | 
| 
      
 375 
     | 
    
         
            +
             
     | 
| 
       337 
376 
     | 
    
         
             
              def change_file_patch
         
     | 
| 
       338 
377 
     | 
    
         
             
                <<-EOF
         
     | 
| 
       339 
378 
     | 
    
         
             
                  diff -u a/lib/foo.rb b/lib/foo.rb
         
     | 
| 
         @@ -351,14 +390,14 @@ class TestGemPatch < Gem::TestCase 
     | 
|
| 
       351 
390 
     | 
    
         
             
                        end
         
     | 
| 
       352 
391 
     | 
    
         
             
                EOF
         
     | 
| 
       353 
392 
     | 
    
         
             
              end
         
     | 
| 
       354 
     | 
    
         
            -
             
     | 
| 
       355 
     | 
    
         
            -
              def  
     | 
| 
      
 393 
     | 
    
         
            +
             
     | 
| 
      
 394 
     | 
    
         
            +
              def change_same_file_patch
         
     | 
| 
       356 
395 
     | 
    
         
             
                <<-EOF
         
     | 
| 
       357 
396 
     | 
    
         
             
                  diff -u a/lib/foo.rb b/lib/foo.rb
         
     | 
| 
       358 
     | 
    
         
            -
                  --- a/lib/foo.rb 
     | 
| 
      
 397 
     | 
    
         
            +
                  --- a/lib/foo.rb
         
     | 
| 
       359 
398 
     | 
    
         
             
                  +++ b/lib/foo.rb
         
     | 
| 
       360 
399 
     | 
    
         
             
                  @@ -1,6 +1,8 @@
         
     | 
| 
       361 
     | 
    
         
            -
                         module  
     | 
| 
      
 400 
     | 
    
         
            +
                         module Foo
         
     | 
| 
       362 
401 
     | 
    
         
             
                  -        def bar
         
     | 
| 
       363 
402 
     | 
    
         
             
                  -          'Original'
         
     | 
| 
       364 
403 
     | 
    
         
             
                  +        class Bar
         
     | 
| 
         @@ -367,6 +406,37 @@ class TestGemPatch < Gem::TestCase 
     | 
|
| 
       367 
406 
     | 
    
         
             
                  +          end
         
     | 
| 
       368 
407 
     | 
    
         
             
                           end
         
     | 
| 
       369 
408 
     | 
    
         
             
                        end
         
     | 
| 
      
 409 
     | 
    
         
            +
             
     | 
| 
      
 410 
     | 
    
         
            +
                  diff -u a/lib/foo.rb b/lib/foo.rb
         
     | 
| 
      
 411 
     | 
    
         
            +
                  --- a/lib/foo.rb
         
     | 
| 
      
 412 
     | 
    
         
            +
                  +++ b/lib/foo.rb
         
     | 
| 
      
 413 
     | 
    
         
            +
                  @@ -1,8 +1,8 @@
         
     | 
| 
      
 414 
     | 
    
         
            +
                         module Foo
         
     | 
| 
      
 415 
     | 
    
         
            +
                  -        class Bar
         
     | 
| 
      
 416 
     | 
    
         
            +
                  -          def foo_bar
         
     | 
| 
      
 417 
     | 
    
         
            +
                  -            'Patched'
         
     | 
| 
      
 418 
     | 
    
         
            +
                  -          end
         
     | 
| 
      
 419 
     | 
    
         
            +
                  +        class NewBar
         
     | 
| 
      
 420 
     | 
    
         
            +
                  +          def new_foo_bar
         
     | 
| 
      
 421 
     | 
    
         
            +
                  +            'Patched'
         
     | 
| 
      
 422 
     | 
    
         
            +
                  +          end
         
     | 
| 
      
 423 
     | 
    
         
            +
                           end
         
     | 
| 
      
 424 
     | 
    
         
            +
                        end
         
     | 
| 
      
 425 
     | 
    
         
            +
                EOF
         
     | 
| 
      
 426 
     | 
    
         
            +
              end
         
     | 
| 
      
 427 
     | 
    
         
            +
              
         
     | 
| 
      
 428 
     | 
    
         
            +
              def change_file_with_fuzz_patch
         
     | 
| 
      
 429 
     | 
    
         
            +
                <<-EOF
         
     | 
| 
      
 430 
     | 
    
         
            +
                  diff -u a/lib/foo.rb b/lib/foo.rb
         
     | 
| 
      
 431 
     | 
    
         
            +
                  --- a/lib/foo.rb 
         
     | 
| 
      
 432 
     | 
    
         
            +
                  +++ b/lib/foo.rb
         
     | 
| 
      
 433 
     | 
    
         
            +
                  @@ -100,5 +100,5 @@
         
     | 
| 
      
 434 
     | 
    
         
            +
                         module Foo
         
     | 
| 
      
 435 
     | 
    
         
            +
                           def bar_bar
         
     | 
| 
      
 436 
     | 
    
         
            +
                  -          'Original'
         
     | 
| 
      
 437 
     | 
    
         
            +
                  +          'Patched'
         
     | 
| 
      
 438 
     | 
    
         
            +
                           end
         
     | 
| 
      
 439 
     | 
    
         
            +
                         end
         
     | 
| 
       370 
440 
     | 
    
         
             
                EOF
         
     | 
| 
       371 
441 
     | 
    
         
             
              end
         
     | 
| 
       372 
442 
     | 
    
         | 
| 
         @@ -410,4 +480,4 @@ class TestGemPatch < Gem::TestCase 
     | 
|
| 
       410 
480 
     | 
    
         
             
                  -      end
         
     | 
| 
       411 
481 
     | 
    
         
             
                EOF
         
     | 
| 
       412 
482 
     | 
    
         
             
              end
         
     | 
| 
       413 
     | 
    
         
            -
            end
         
     | 
| 
      
 483 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: gem-patch
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.5
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Josef Stribny
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2013- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2013-11-06 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       13 
13 
     | 
    
         
             
            description: |2
         
     | 
| 
       14 
14 
     | 
    
         
             
                                  `gem-patch` is a RubyGems plugin that helps to patch gems without manually opening and rebuilding them.
         
     | 
| 
         @@ -48,7 +48,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       48 
48 
     | 
    
         
             
                  version: 1.8.0
         
     | 
| 
       49 
49 
     | 
    
         
             
            requirements: []
         
     | 
| 
       50 
50 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       51 
     | 
    
         
            -
            rubygems_version: 2. 
     | 
| 
      
 51 
     | 
    
         
            +
            rubygems_version: 2.1.9
         
     | 
| 
       52 
52 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       53 
53 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       54 
54 
     | 
    
         
             
            summary: RubyGems plugin for patching gems.
         
     |