Skip to content

Commit

Permalink
Fix for ruby 1.9
Browse files Browse the repository at this point in the history
Fixed ruby-riff version to >= 0.3.0, v0.3.1 seems to be broken.
Fixed incompatibility with IO.getc (in ruby-riff).
Fixed incompatibility with Pathname/String concatenation.
Fixed incompatibility with an error type thrown by frozen object.
  • Loading branch information
ucnv authored and youpy committed May 18, 2010
1 parent 4eb1b57 commit c04bf14
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -59,7 +59,7 @@ spec = Gem::Specification.new do |s|

s.add_dependency('open4')
s.add_dependency('ruby-mp3info')
s.add_dependency('riff')
s.add_dependency('riff', '<= 0.3.0')
s.add_dependency('tempdir')
#s.required_ruby_version = '>= 1.8.2'

Expand Down
16 changes: 16 additions & 0 deletions lib/scissor.rb
Expand Up @@ -53,3 +53,19 @@ def mix(scissor_array, filename, options = {})
end
end
end

# for ruby 1.9
if IO.instance_methods.include? :getbyte
class << Riff::Reader::Chunk
alias :read_bytes_to_int_original :read_bytes_to_int
def read_bytes_to_int file, bytes
require 'delegate'
file_delegate = SimpleDelegator.new(file)
def file_delegate.getc
getbyte
end
read_bytes_to_int_original file_delegate, bytes
end
end
end

2 changes: 1 addition & 1 deletion lib/scissor/writer.rb
Expand Up @@ -38,7 +38,7 @@ def fragments_to_file(fragments, outfile, tmpdir)

fragment_outfile =
fragment_filename.extname.downcase == '.wav' ? fragment_filename :
tmpdir + (Digest::MD5.hexdigest(fragment_filename) + '.wav')
tmpdir + (Digest::MD5.hexdigest(fragment_filename.to_s) + '.wav')

unless fragment_outfile.exist?
run_command("ffmpeg -i \"#{fragment_filename}\" \"#{fragment_outfile}\"")
Expand Down
2 changes: 1 addition & 1 deletion spec/fragment_spec.rb
Expand Up @@ -27,7 +27,7 @@
it "should freezed" do
lambda {
@fragment.instance_eval { @duration = 1 }
}.should raise_error(TypeError)
}.should raise_error(StandardError, "can't modify frozen object")
end

it "should have a pitch" do
Expand Down

0 comments on commit c04bf14

Please sign in to comment.