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 CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.1.1 / 2010-09-09
2
+
3
+ * Fixed a bug with windows.
4
+ * Some tiny fixes.
5
+
1
6
  == 0.1.0 / 2010-07-09
2
7
 
3
8
  * Minor version up.
@@ -1,6 +1,6 @@
1
1
  = AviGlitch
2
2
 
3
- * http://github.com/ucnv/aviglitch
3
+ * http://ucnv.github.com/aviglitch/
4
4
 
5
5
  == Description
6
6
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.1
@@ -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.0'
38
+ VERSION = '0.1.1'
38
39
 
39
40
  class << self
40
41
  ##
@@ -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 convent method to iterate each frame.
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 # :nodoc:
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
@@ -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 a AviGlitch::Frame object
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 # :nodoc:
22
- @@warn_if_frames_are_too_large = true # :nodoc:
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(io = nil, block = nil) #:nodoc:
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
- # Insert the given Frame objects into the given index.
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
- # Generate new AviGlitch::Base instance using self.
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 # :nodoc:
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
@@ -0,0 +1,8 @@
1
+ module AviGlitch
2
+ class Tempfile < Tempfile
3
+ def initialize *args
4
+ super *args
5
+ self.binmode
6
+ end
7
+ end
8
+ end
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
- - 0
10
- version: 0.1.0
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-07-09 00:00:00 +09:00
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"