sequencer 1.0.2 → 1.0.3
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.
- data/History.txt +4 -0
- data/Manifest.txt +1 -0
- data/bin/rseqpad +38 -0
- data/lib/sequencer.rb +29 -2
- metadata +38 -14
    
        data/History.txt
    CHANGED
    
    
    
        data/Manifest.txt
    CHANGED
    
    
    
        data/bin/rseqpad
    ADDED
    
    | @@ -0,0 +1,38 @@ | |
| 1 | 
            +
            #!/usr/bin/env ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require File.dirname(__FILE__) + "/../lib/sequencer"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            d = ARGV.shift || Dir.pwd
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            renames = []
         | 
| 8 | 
            +
            Sequencer.entries(d).each do | e |
         | 
| 9 | 
            +
              next if e.length < 2
         | 
| 10 | 
            +
              
         | 
| 11 | 
            +
              padz = e.length.to_s.length
         | 
| 12 | 
            +
              
         | 
| 13 | 
            +
              puts "Repadding sequence #{e} with #{padz} zeroes"
         | 
| 14 | 
            +
              
         | 
| 15 | 
            +
              e.each do | f |
         | 
| 16 | 
            +
                rep_name = f.gsub(/([\.\-\_]?)(\d+)\.(\w+)$/) do
         | 
| 17 | 
            +
                  ".%0#{padz}d.%s" % [$2.to_i, $3]
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
                # Now this is a replaced name
         | 
| 20 | 
            +
                from_to =  [File.join(e.directory, f), File.join(e.directory, rep_name)]
         | 
| 21 | 
            +
                renames.push(from_to)
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
            end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            # Check for dupes
         | 
| 26 | 
            +
            destinations = renames.map{|e| e[1] }
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            if (destinations.uniq.length != destinations.length)
         | 
| 29 | 
            +
              twice = destinations.length - destinations.uniq.length
         | 
| 30 | 
            +
              $stderr.puts "Cannot rename - #{twice} files will overwrite each other or files will be renamed twice"
         | 
| 31 | 
            +
              twice.each {|e| $stderr.puts e }
         | 
| 32 | 
            +
              exit -1
         | 
| 33 | 
            +
            end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
            # And do the job
         | 
| 36 | 
            +
            renames.each do | from, to |
         | 
| 37 | 
            +
              File.rename(from, to)
         | 
| 38 | 
            +
            end
         | 
    
        data/lib/sequencer.rb
    CHANGED
    
    | @@ -1,5 +1,5 @@ | |
| 1 1 | 
             
            module Sequencer
         | 
| 2 | 
            -
              VERSION = '1.0. | 
| 2 | 
            +
              VERSION = '1.0.3'
         | 
| 3 3 | 
             
              NUMBERS_AT_END = /(\d+)([^\d]+)?$/
         | 
| 4 4 |  | 
| 5 5 | 
             
              extend self
         | 
| @@ -171,7 +171,7 @@ module Sequencer | |
| 171 171 | 
             
                  @filenames.include?(base_filename)
         | 
| 172 172 | 
             
                end
         | 
| 173 173 |  | 
| 174 | 
            -
                #  | 
| 174 | 
            +
                # Yields the filename of each file to the block
         | 
| 175 175 | 
             
                def each
         | 
| 176 176 | 
             
                  @filenames.each {|f| yield(f) }
         | 
| 177 177 | 
             
                end
         | 
| @@ -201,6 +201,33 @@ module Sequencer | |
| 201 201 | 
             
                  @ranges[-1].end
         | 
| 202 202 | 
             
                end
         | 
| 203 203 |  | 
| 204 | 
            +
                # Apply a bulk rename
         | 
| 205 | 
            +
                def bulk_rename(with_pattern)
         | 
| 206 | 
            +
                  rename_map = filenames.inject({}) do | filename, map |
         | 
| 207 | 
            +
                    frame_no = filename.scan(NUMBERS_AT_END).flatten.shift.to_i
         | 
| 208 | 
            +
                    map.merge(filename => (with_pattern % frame_no))
         | 
| 209 | 
            +
                  end
         | 
| 210 | 
            +
                  
         | 
| 211 | 
            +
                  # Ensure we will not produce dupes
         | 
| 212 | 
            +
                  if (rename_map.values.uniq.length != rename_map.length)
         | 
| 213 | 
            +
                    raise "This would would produce non-unique files"
         | 
| 214 | 
            +
                  end
         | 
| 215 | 
            +
                  
         | 
| 216 | 
            +
                  if (error = (rename_map.keys & rename_map.values)).any?
         | 
| 217 | 
            +
                    raise "This would overwrite old files with the renamed ones (#{error[0..1]}.join(',')..)"
         | 
| 218 | 
            +
                  end
         | 
| 219 | 
            +
                  
         | 
| 220 | 
            +
                  if (error = (Dir.entries(@directory) % rename_map.values)).any?
         | 
| 221 | 
            +
                    raise "Files that will be created by the rename are already in place (#{error[0..1]}.join(',')..)"
         | 
| 222 | 
            +
                  end
         | 
| 223 | 
            +
                  
         | 
| 224 | 
            +
                  
         | 
| 225 | 
            +
                end
         | 
| 226 | 
            +
                
         | 
| 227 | 
            +
                def bulk_rename!(with_pattern)
         | 
| 228 | 
            +
                  replace(bulk_rename(with_pattern))
         | 
| 229 | 
            +
                end
         | 
| 230 | 
            +
                
         | 
| 204 231 | 
             
                private
         | 
| 205 232 |  | 
| 206 233 | 
             
                def natural_sort(ar)
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: sequencer
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
               | 
| 4 | 
            +
              hash: 17
         | 
| 5 | 
            +
              prerelease: false
         | 
| 6 | 
            +
              segments: 
         | 
| 7 | 
            +
              - 1
         | 
| 8 | 
            +
              - 0
         | 
| 9 | 
            +
              - 3
         | 
| 10 | 
            +
              version: 1.0.3
         | 
| 5 11 | 
             
            platform: ruby
         | 
| 6 12 | 
             
            authors: 
         | 
| 7 13 | 
             
            - Julik Tarkhanov
         | 
| @@ -9,34 +15,45 @@ autorequire: | |
| 9 15 | 
             
            bindir: bin
         | 
| 10 16 | 
             
            cert_chain: []
         | 
| 11 17 |  | 
| 12 | 
            -
            date: 2010- | 
| 18 | 
            +
            date: 2010-10-26 00:00:00 +02:00
         | 
| 13 19 | 
             
            default_executable: 
         | 
| 14 20 | 
             
            dependencies: 
         | 
| 15 21 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 16 22 | 
             
              name: test-spec
         | 
| 17 | 
            -
               | 
| 18 | 
            -
               | 
| 19 | 
            -
             | 
| 23 | 
            +
              prerelease: false
         | 
| 24 | 
            +
              requirement: &id001 !ruby/object:Gem::Requirement 
         | 
| 25 | 
            +
                none: false
         | 
| 20 26 | 
             
                requirements: 
         | 
| 21 27 | 
             
                - - ">="
         | 
| 22 28 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 29 | 
            +
                    hash: 3
         | 
| 30 | 
            +
                    segments: 
         | 
| 31 | 
            +
                    - 0
         | 
| 23 32 | 
             
                    version: "0"
         | 
| 24 | 
            -
             | 
| 33 | 
            +
              type: :development
         | 
| 34 | 
            +
              version_requirements: *id001
         | 
| 25 35 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 26 36 | 
             
              name: hoe
         | 
| 27 | 
            -
               | 
| 28 | 
            -
               | 
| 29 | 
            -
             | 
| 37 | 
            +
              prerelease: false
         | 
| 38 | 
            +
              requirement: &id002 !ruby/object:Gem::Requirement 
         | 
| 39 | 
            +
                none: false
         | 
| 30 40 | 
             
                requirements: 
         | 
| 31 41 | 
             
                - - ">="
         | 
| 32 42 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 33 | 
            -
                     | 
| 34 | 
            -
             | 
| 43 | 
            +
                    hash: 21
         | 
| 44 | 
            +
                    segments: 
         | 
| 45 | 
            +
                    - 2
         | 
| 46 | 
            +
                    - 6
         | 
| 47 | 
            +
                    - 1
         | 
| 48 | 
            +
                    version: 2.6.1
         | 
| 49 | 
            +
              type: :development
         | 
| 50 | 
            +
              version_requirements: *id002
         | 
| 35 51 | 
             
            description: Simplifies working with image sequences
         | 
| 36 52 | 
             
            email: 
         | 
| 37 53 | 
             
            - me@julik.nl
         | 
| 38 54 | 
             
            executables: 
         | 
| 39 55 | 
             
            - rseqls
         | 
| 56 | 
            +
            - rseqpad
         | 
| 40 57 | 
             
            extensions: []
         | 
| 41 58 |  | 
| 42 59 | 
             
            extra_rdoc_files: 
         | 
| @@ -50,6 +67,7 @@ files: | |
| 50 67 | 
             
            - README.txt
         | 
| 51 68 | 
             
            - Rakefile
         | 
| 52 69 | 
             
            - bin/rseqls
         | 
| 70 | 
            +
            - bin/rseqpad
         | 
| 53 71 | 
             
            - lib/sequencer.rb
         | 
| 54 72 | 
             
            - test/test_sequencer.rb
         | 
| 55 73 | 
             
            has_rdoc: true
         | 
| @@ -63,21 +81,27 @@ rdoc_options: | |
| 63 81 | 
             
            require_paths: 
         | 
| 64 82 | 
             
            - lib
         | 
| 65 83 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| 84 | 
            +
              none: false
         | 
| 66 85 | 
             
              requirements: 
         | 
| 67 86 | 
             
              - - ">="
         | 
| 68 87 | 
             
                - !ruby/object:Gem::Version 
         | 
| 88 | 
            +
                  hash: 3
         | 
| 89 | 
            +
                  segments: 
         | 
| 90 | 
            +
                  - 0
         | 
| 69 91 | 
             
                  version: "0"
         | 
| 70 | 
            -
              version: 
         | 
| 71 92 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 93 | 
            +
              none: false
         | 
| 72 94 | 
             
              requirements: 
         | 
| 73 95 | 
             
              - - ">="
         | 
| 74 96 | 
             
                - !ruby/object:Gem::Version 
         | 
| 97 | 
            +
                  hash: 3
         | 
| 98 | 
            +
                  segments: 
         | 
| 99 | 
            +
                  - 0
         | 
| 75 100 | 
             
                  version: "0"
         | 
| 76 | 
            -
              version: 
         | 
| 77 101 | 
             
            requirements: []
         | 
| 78 102 |  | 
| 79 103 | 
             
            rubyforge_project: sequencer
         | 
| 80 | 
            -
            rubygems_version: 1.3. | 
| 104 | 
            +
            rubygems_version: 1.3.7
         | 
| 81 105 | 
             
            signing_key: 
         | 
| 82 106 | 
             
            specification_version: 3
         | 
| 83 107 | 
             
            summary: Simplifies working with image sequences
         |