Permalink
Browse files

expand given path

  • Loading branch information...
1 parent 72c07c1 commit a3ac2c32783408674fb18a946497a9702abbb5d4 @youpy committed Jan 2, 2012
Showing with 18 additions and 2 deletions.
  1. +1 −1 lib/scissor.rb
  2. +2 −1 lib/scissor/tape.rb
  3. +15 −0 spec/scissor_spec.rb
View
@@ -9,7 +9,7 @@ def Scissor(filename_or_url = nil)
if filename_or_url && filename_or_url.to_s =~ /^http/
Scissor::Tape.new_from_url(filename_or_url)
else
- Scissor::Tape.new(filename_or_url && Pathname(filename_or_url).expand_path)
+ Scissor::Tape.new(filename_or_url)
end
end
View
@@ -13,6 +13,7 @@ def initialize(filename = nil)
@fragments = []
if filename
+ filename = Pathname(filename).expand_path
@fragments << Fragment.new(
filename,
0,
@@ -205,7 +206,7 @@ def to_file(filename, options = {})
alias > to_file
def >>(filename)
- to_file(Pathname(filename).expand_path, :overwrite => true)
+ to_file(filename, :overwrite => true)
end
def silence
View
@@ -30,6 +30,14 @@
mp3.duration.should be_close(178.1, 0.1)
end
+ it "should expand given path" do
+ cp fixture('sample.mp3'), '/tmp/scissor-test'
+
+ mp3 = Scissor('~/../../../../../../../../../../tmp/scissor-test/sample.mp3')
+ mp3.should be_an_instance_of(Scissor::Tape)
+ mp3.duration.should be_close(178.1, 0.1)
+ end
+
it "should get duration" do
@mp3.should respond_to(:duration)
@mp3.duration.should be_close(178.1, 0.1)
@@ -238,6 +246,13 @@
result.duration.should be_close(140, 0.1)
end
+ it "should write to expanded path" do
+ @mp3.to_file('~/../../../../../../../../../../tmp/scissor-test/sample.mp3')
+
+ mp3 = Scissor('/tmp/scissor-test/sample.mp3')
+ mp3.should be_an_instance_of(Scissor::Tape)
+ end
+
it "should write to wav file" do
scissor = @mp3.slice(0, 120) + @mp3.slice(150, 20)
result = scissor.to_file('/tmp/scissor-test/out.wav')

0 comments on commit a3ac2c3

Please sign in to comment.