aviglitch 0.1.0 → 0.1.1
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/ChangeLog +5 -0
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/lib/aviglitch.rb +2 -1
- data/lib/aviglitch/base.rb +7 -5
- data/lib/aviglitch/frames.rb +7 -7
- data/lib/aviglitch/tempfile.rb +8 -0
- metadata +4 -6
    
        data/ChangeLog
    CHANGED
    
    
    
        data/README.rdoc
    CHANGED
    
    
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            0.1. | 
| 1 | 
            +
            0.1.1
         | 
    
        data/lib/aviglitch.rb
    CHANGED
    
    | @@ -6,6 +6,7 @@ require 'stringio' | |
| 6 6 | 
             
            require 'aviglitch/base'
         | 
| 7 7 | 
             
            require 'aviglitch/frame'
         | 
| 8 8 | 
             
            require 'aviglitch/frames'
         | 
| 9 | 
            +
            require 'aviglitch/tempfile'
         | 
| 9 10 |  | 
| 10 11 | 
             
            # AviGlitch provides the ways to glitch AVI formatted video files.
         | 
| 11 12 | 
             
            #
         | 
| @@ -34,7 +35,7 @@ require 'aviglitch/frames' | |
| 34 35 | 
             
            #
         | 
| 35 36 | 
             
            module AviGlitch
         | 
| 36 37 |  | 
| 37 | 
            -
              VERSION = '0.1. | 
| 38 | 
            +
              VERSION = '0.1.1'
         | 
| 38 39 |  | 
| 39 40 | 
             
              class << self
         | 
| 40 41 | 
             
                ##
         | 
    
        data/lib/aviglitch/base.rb
    CHANGED
    
    | @@ -1,8 +1,10 @@ | |
| 1 1 | 
             
            module AviGlitch
         | 
| 2 | 
            +
             | 
| 2 3 | 
             
              # Base is the object that provides interfaces mainly used.
         | 
| 3 | 
            -
              # To glitch, and save file. The instance returned through AviGlitch#open.
         | 
| 4 | 
            +
              # To glitch, and save file. The instance is returned through AviGlitch#open.
         | 
| 4 5 | 
             
              #
         | 
| 5 6 | 
             
              class Base
         | 
| 7 | 
            +
             | 
| 6 8 | 
             
                # AviGlitch::Frames object generated from the +file+.
         | 
| 7 9 | 
             
                attr_reader :frames
         | 
| 8 10 | 
             
                # The input file (copied tempfile).
         | 
| @@ -13,7 +15,7 @@ module AviGlitch | |
| 13 15 | 
             
                # make it ready to manipulate.
         | 
| 14 16 | 
             
                # It requires +path+ as Pathname.
         | 
| 15 17 | 
             
                def initialize path
         | 
| 16 | 
            -
                  File.open(path) do |f|
         | 
| 18 | 
            +
                  File.open(path, 'rb') do |f|
         | 
| 17 19 | 
             
                    # copy as tempfile
         | 
| 18 20 | 
             
                    @file = Tempfile.open 'aviglitch'
         | 
| 19 21 | 
             
                    f.rewind
         | 
| @@ -44,7 +46,7 @@ module AviGlitch | |
| 44 46 |  | 
| 45 47 | 
             
                ##
         | 
| 46 48 | 
             
                # Glitches each frame data.
         | 
| 47 | 
            -
                # It is a  | 
| 49 | 
            +
                # It is a convenient method to iterate each frame.
         | 
| 48 50 | 
             
                #
         | 
| 49 51 | 
             
                # The argument +target+ takes symbols listed below:
         | 
| 50 52 | 
             
                # [<tt>:keyframe</tt> or <tt>:iframe</tt>]   select video key frames (aka I-frame)
         | 
| @@ -89,7 +91,7 @@ module AviGlitch | |
| 89 91 | 
             
                  @frames.concat other
         | 
| 90 92 | 
             
                end
         | 
| 91 93 |  | 
| 92 | 
            -
                def valid_target? target, frame  | 
| 94 | 
            +
                def valid_target? target, frame #:nodoc:
         | 
| 93 95 | 
             
                  return true if target == :all
         | 
| 94 96 | 
             
                  begin
         | 
| 95 97 | 
             
                    frame.send "is_#{target.to_s.sub(/frames$/, 'frame')}?"
         | 
| @@ -107,7 +109,7 @@ module AviGlitch | |
| 107 109 | 
             
                  def surely_formatted? file, debug = false
         | 
| 108 110 | 
             
                    answer = true
         | 
| 109 111 | 
             
                    is_io = file.respond_to?(:seek)  # Probably IO.
         | 
| 110 | 
            -
                    file = File.open(file) unless is_io
         | 
| 112 | 
            +
                    file = File.open(file, 'rb') unless is_io
         | 
| 111 113 | 
             
                    begin
         | 
| 112 114 | 
             
                      file.seek 0, IO::SEEK_END
         | 
| 113 115 | 
             
                      eof = file.pos
         | 
    
        data/lib/aviglitch/frames.rb
    CHANGED
    
    | @@ -8,7 +8,7 @@ module AviGlitch | |
| 8 8 | 
             
              #   avi = AviGlitch.new '/path/to/your.avi'
         | 
| 9 9 | 
             
              #   frames = avi.frames
         | 
| 10 10 | 
             
              #   frames.each do |frame|
         | 
| 11 | 
            -
              #     ## frame is a reference of  | 
| 11 | 
            +
              #     ## frame is a reference of an AviGlitch::Frame object
         | 
| 12 12 | 
             
              #     frame.data = frame.data.gsub(/\d/, '0')
         | 
| 13 13 | 
             
              #   end
         | 
| 14 14 | 
             
              #
         | 
| @@ -18,8 +18,8 @@ module AviGlitch | |
| 18 18 | 
             
              class Frames
         | 
| 19 19 | 
             
                include Enumerable
         | 
| 20 20 |  | 
| 21 | 
            -
                SAFE_FRAMES_COUNT = 150000               | 
| 22 | 
            -
                @@warn_if_frames_are_too_large = true    | 
| 21 | 
            +
                SAFE_FRAMES_COUNT = 150000              #:nodoc:
         | 
| 22 | 
            +
                @@warn_if_frames_are_too_large = true   #:nodoc:
         | 
| 23 23 |  | 
| 24 24 | 
             
                attr_reader :meta
         | 
| 25 25 |  | 
| @@ -68,7 +68,7 @@ module AviGlitch | |
| 68 68 | 
             
                  @meta.size
         | 
| 69 69 | 
             
                end
         | 
| 70 70 |  | 
| 71 | 
            -
                def frames_data_as_io | 
| 71 | 
            +
                def frames_data_as_io io = nil, block = nil  #:nodoc:
         | 
| 72 72 | 
             
                  io = Tempfile.new('tmep') if io.nil?
         | 
| 73 73 | 
             
                  @meta = @meta.select do |m|
         | 
| 74 74 | 
             
                    @io.pos = @pos_of_movi + m[:offset] + 8   # 8 for id and size
         | 
| @@ -301,7 +301,7 @@ module AviGlitch | |
| 301 301 | 
             
                alias_method :<<, :push
         | 
| 302 302 |  | 
| 303 303 | 
             
                ##
         | 
| 304 | 
            -
                #  | 
| 304 | 
            +
                # Inserts the given Frame objects into the given index.
         | 
| 305 305 | 
             
                def insert n, *args
         | 
| 306 306 | 
             
                  new_frames = self.slice(0, n)
         | 
| 307 307 | 
             
                  args.each do |f|
         | 
| @@ -327,7 +327,7 @@ module AviGlitch | |
| 327 327 | 
             
                end
         | 
| 328 328 |  | 
| 329 329 | 
             
                ##
         | 
| 330 | 
            -
                #  | 
| 330 | 
            +
                # Generates new AviGlitch::Base instance using self.
         | 
| 331 331 | 
             
                def to_avi
         | 
| 332 332 | 
             
                  AviGlitch.open @io.path
         | 
| 333 333 | 
             
                end
         | 
| @@ -344,7 +344,7 @@ module AviGlitch | |
| 344 344 | 
             
                  [b, l]
         | 
| 345 345 | 
             
                end
         | 
| 346 346 |  | 
| 347 | 
            -
                def safe_frames_count? count  | 
| 347 | 
            +
                def safe_frames_count? count #:nodoc:
         | 
| 348 348 | 
             
                  r = true
         | 
| 349 349 | 
             
                  if @@warn_if_frames_are_too_large && count >= SAFE_FRAMES_COUNT
         | 
| 350 350 | 
             
                    trap(:INT) do
         | 
    
        metadata
    CHANGED
    
    | @@ -1,13 +1,12 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: aviglitch
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash: 27
         | 
| 5 4 | 
             
              prerelease: false
         | 
| 6 5 | 
             
              segments: 
         | 
| 7 6 | 
             
              - 0
         | 
| 8 7 | 
             
              - 1
         | 
| 9 | 
            -
              -  | 
| 10 | 
            -
              version: 0.1. | 
| 8 | 
            +
              - 1
         | 
| 9 | 
            +
              version: 0.1.1
         | 
| 11 10 | 
             
            platform: ruby
         | 
| 12 11 | 
             
            authors: 
         | 
| 13 12 | 
             
            - ucnv
         | 
| @@ -15,7 +14,7 @@ autorequire: | |
| 15 14 | 
             
            bindir: bin
         | 
| 16 15 | 
             
            cert_chain: []
         | 
| 17 16 |  | 
| 18 | 
            -
            date: 2010- | 
| 17 | 
            +
            date: 2010-09-09 00:00:00 +09:00
         | 
| 19 18 | 
             
            default_executable: datamosh
         | 
| 20 19 | 
             
            dependencies: []
         | 
| 21 20 |  | 
| @@ -39,6 +38,7 @@ files: | |
| 39 38 | 
             
            - lib/aviglitch/base.rb
         | 
| 40 39 | 
             
            - lib/aviglitch/frame.rb
         | 
| 41 40 | 
             
            - lib/aviglitch/frames.rb
         | 
| 41 | 
            +
            - lib/aviglitch/tempfile.rb
         | 
| 42 42 | 
             
            - spec/aviglitch_spec.rb
         | 
| 43 43 | 
             
            - spec/datamosh_spec.rb
         | 
| 44 44 | 
             
            - spec/files/sample.avi
         | 
| @@ -60,7 +60,6 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 60 60 | 
             
              requirements: 
         | 
| 61 61 | 
             
              - - ">="
         | 
| 62 62 | 
             
                - !ruby/object:Gem::Version 
         | 
| 63 | 
            -
                  hash: 3
         | 
| 64 63 | 
             
                  segments: 
         | 
| 65 64 | 
             
                  - 0
         | 
| 66 65 | 
             
                  version: "0"
         | 
| @@ -69,7 +68,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 69 68 | 
             
              requirements: 
         | 
| 70 69 | 
             
              - - ">="
         | 
| 71 70 | 
             
                - !ruby/object:Gem::Version 
         | 
| 72 | 
            -
                  hash: 3
         | 
| 73 71 | 
             
                  segments: 
         | 
| 74 72 | 
             
                  - 0
         | 
| 75 73 | 
             
                  version: "0"
         |