Browse files

General cleanup before 0.2.0 release

  • Loading branch information...
1 parent b38f83c commit a00cee654934af7ef681c10a2b04a659f6d7943b Peter Garbers committed Aug 15, 2012
View
0 bin/voyeur.rb 100644 → 100755
File mode changed.
View
6 lib/Voyeur/converter.rb
@@ -9,7 +9,7 @@ def self.create(options)
klass = if options[:format].is_a?(Symbol)
klass_name = "#{options[:format].capitalize}"
raise Voyeur::Exceptions::InvalidFormat unless constant.const_defined? klass_name
- constant.const_get klass_name
+ constant.const_get(klass_name)
else
options[:format]
end
@@ -21,9 +21,7 @@ def convert(options)
raise Voyeur::Exceptions::NoMediaPresent unless @input_media
@output_media = Media.new(filename: output_file(options[:output_path], options[:output_filename]))
if block_given?
- self.call_external_converter do |time|
- yield time
- end
+ self.call_external_converter{ |time| yield time }
else
self.call_external_converter
end
View
12 lib/Voyeur/media.rb
@@ -2,29 +2,27 @@ module Voyeur
class Media
attr_reader :filename
attr_reader :raw_duration
-
+
def initialize(options)
@filename = options[:filename]
self.get_info
end
-
+
def get_info
output = ''
status = Open4::popen4("ffmpeg -i #{@filename}") do |pid, stdin, stdout, stderr|
output = stderr.read.strip
end
- @raw_duration = $1 if output =~ /Duration: (\d+:\d+:\d+.\d+)/
+ @raw_duration = $1 if output =~ /Duration: (\d+:\d+:\d+.\d+)/
end
def convert(options)
converter = Voyeur::Converter.create(format: options[:to])
-
+
if block_given?
converter.convert(media: self,
output_filename: options[:output_filename],
- output_path: options[:output_path]) do |time|
- yield time
- end
+ output_path: options[:output_path]){ |time| yield time }
else
converter.convert(media: self,
output_filename: options[:output_filename],
View
7 lib/Voyeur/media_time.rb
@@ -2,17 +2,16 @@ module Voyeur
class MediaTime
attr_accessor :raw_time
attr_accessor :hours, :minutes, :seconds
-
+
def initialize(raw_time)
@hours, @minutes, @seconds = raw_time.split(":")
@hours = @hours.to_i
@minutes = @minutes.to_i
@seconds = @seconds.to_i
end
-
+
def to_seconds
- @seconds.to_i + (@minutes.to_i * 60) + (@hours.to_i * 60 *60)
+ @seconds + (@minutes * 60) + (@hours * 60 * 60)
end
-
end
end
View
0 spec/audio_spec.rb
No changes.
View
45 spec/converters/audio_converters/aac_spec.rb
@@ -1,17 +1,15 @@
require 'spec_helper'
describe Voyeur::Aac do
- before :each do
- @converter = Voyeur::Converter.create(format: :aac)
- @audio = Voyeur::Media.new(filename: valid_mpeg_file_path)
- end
+ let(:converter) { Voyeur::Converter.create(format: :aac) }
+ let(:audio) { Voyeur::Media.new(filename: valid_mpeg_file_path) }
it "should use the correct factory" do
- @converter.class.to_s.should == "Voyeur::Aac"
+ converter.class.to_s.should == "Voyeur::Aac"
end
it "default convert string" do
- @converter.convert_options.should == "-acodec libfaac -ac 2 -ar 44100 -ab 128k"
+ converter.convert_options.should == "-acodec libfaac -ac 2 -ar 44100 -ab 128k"
end
context "A valid audio files" do
@@ -20,43 +18,40 @@
end
context "#convert_options: " do
- it "should name the file correctly" do
- @converter.convert(media: @audio)
+ it "names the file correctly" do
+ converter.convert(media: audio)
output_file = valid_mpeg_file_path.gsub(/mpeg/, "aac")
- @converter.output_media.filename.should == output_file
+ converter.output_media.filename.should == output_file
end
- it "should return an audio file" do
- @converter.convert(media: @audio)
- @converter.input_media.should == @audio
+ it "returns an audio file" do
+ converter.convert(media: audio)
+ converter.input_media.should == audio
end
context "audio file - " do
- it "should return conversion status indicating success" do
- result = @converter.convert(media: @audio)
+ it "returns conversion status indicating success" do
+ result = converter.convert(media: audio)
result[:status].should == 0
- result[:media].should == @converter.output_media
+ result[:media].should == converter.output_media
end
- it "should allow it to be named" do
- result = @converter.convert(media: @audio)
+ it "allows it to be named" do
+ result = converter.convert(media: audio)
result[:status].should == 0
- result[:media].should == @converter.output_media
+ result[:media].should == converter.output_media
end
end
end
end
context "An invalid audio file" do
- before :each do
- @converter = Voyeur::Converter.create(format: :aac)
- @audio = Voyeur::Media.new(filename: 'test_media.mpeg')
- end
+ let(:audio) { Voyeur::Media.new(filename: 'test_media.mpeg') }
- it "should return conversion status indicating failure" do
- result = @converter.convert(media: @audio)
+ it "returns conversion status indicating failure" do
+ result = converter.convert(media: audio)
result[:status].should == 1
- result[:media].should == @converter.output_media
+ result[:media].should == converter.output_media
result[:error_message].should match(/test_media.mpeg: No such file or directory/)
result[:stderr].nil?.should == false
end
View
47 spec/converters/audio_converters/ogg_spec.rb
@@ -1,17 +1,15 @@
require 'spec_helper'
describe Voyeur::Ogg do
- before :each do
- @converter = Voyeur::Converter.create(format: :ogg)
- @audio = Voyeur::Media.new(filename: valid_mpeg_file_path)
- end
+ let(:converter) { Voyeur::Converter.create(format: :ogg) }
+ let(:audio) { Voyeur::Media.new(filename: valid_mpeg_file_path) }
- it "should use the correct factory" do
- @converter.class.to_s.should == "Voyeur::Ogg"
+ it "uses the correct factory" do
+ converter.class.to_s.should == "Voyeur::Ogg"
end
it "default convert string" do
- @converter.convert_options.should == "-strict -2 -acodec vorbis -aq 60"
+ converter.convert_options.should == "-strict -2 -acodec vorbis -aq 60"
end
context "A valid audio files" do
@@ -20,43 +18,40 @@
end
context "#convert_options: " do
- it "should name the media correctly" do
- @converter.convert(media: @audio)
+ it "names the media correctly" do
+ converter.convert(media: audio)
output_file = valid_mpeg_file_path.gsub(/mpeg/, "ogg")
- @converter.output_media.filename.should == output_file
+ converter.output_media.filename.should == output_file
end
- it "should return an audio file" do
- @converter.convert(media: @audio)
- @converter.input_media.should == @audio
+ it "returns an audio file" do
+ converter.convert(media: audio)
+ converter.input_media.should == audio
end
context "audio file - " do
- it "should return conversion status indicating success" do
- result = @converter.convert(media: @audio)
+ it "returns conversion status indicating success" do
+ result = converter.convert(media: audio)
result[:status].should == 0
- result[:media].should == @converter.output_media
+ result[:media].should == converter.output_media
end
- it "should allow it to be named" do
- result = @converter.convert(media: @audio)
+ it "allows it to be named" do
+ result = converter.convert(media: audio)
result[:status].should == 0
- result[:media].should == @converter.output_media
+ result[:media].should == converter.output_media
end
end
end
end
context "An invalid audio file" do
- before :each do
- @converter = Voyeur::Converter.create(format: :ogg)
- @audio = Voyeur::Media.new(filename: 'test_media.mpeg')
- end
+ let(:audio) { Voyeur::Media.new(filename: 'test_media.mpeg') }
- it "should return conversion status indicating failure" do
- result = @converter.convert(media: @audio)
+ it "returns conversion status indicating failure" do
+ result = converter.convert(media: audio)
result[:status].should == 1
- result[:media].should == @converter.output_media
+ result[:media].should == converter.output_media
result[:error_message].should match(/test_media.mpeg: No such file or directory/)
result[:stderr].nil?.should == false
end
View
66 spec/converters/mp4_spec.rb
@@ -1,66 +0,0 @@
-require 'spec_helper'
-
-describe Voyeur::Mp4 do
- before :each do
- @converter = Voyeur::Converter.create(format: :mp4)
- @video = Voyeur::Media.new(filename: valid_mpeg_file_path)
- end
-
- it "should use the correct factory" do
- @converter.class.to_s.should == "Voyeur::Mp4"
- end
-
- it "default convert string" do
- @converter.convert_options.should == "-b 1500k -vcodec libx264 -g 30"
- end
-
- context "A valid Video" do
- after :each do
- File.delete(valid_mpeg_file_path.gsub(/mpeg/, "mp4")) if File.exists?(valid_mpeg_file_path.gsub(/mpeg/, "mp4"))
- end
-
- context "#convert_options" do
- it "should name the video correctly" do
- @converter.convert(media: @video)
- output_file = valid_mpeg_file_path.gsub(/mpeg/, "mp4")
- @converter.output_media.filename.should == output_file
- end
-
- it "should return a video" do
- @converter.convert(media: @video)
- @converter.input_media.should == @video
- end
-
- context "real video" do
- it "should return conversion status indicating success" do
- result = @converter.convert(media: @video)
- result[:status].should == 0
- result[:media].should == @converter.output_media
- end
-
- it "should allow them to name the video" do
- result = @converter.convert(media: @video)
- result[:status].should == 0
- result[:media].should == @converter.output_media
- end
- end
- end
- end
-
- context "An invalid Video" do
- before :each do
- @converter = Voyeur::Converter.create(format: :mp4)
- @video = Voyeur::Media.new(filename: 'test_video.mpeg')
- end
-
- context "File does not exist" do
- it "should return conversion status indicating failure" do
- result = @converter.convert(media: @video)
- result[:status].should == 1
- result[:media].should == @converter.output_media
- result[:error_message].should match(/test_video.mpeg: No such file or directory/)
- result[:stderr].nil?.should == false
- end
- end
- end
-end
View
46 spec/converters/ogv_spec.rb
@@ -1,46 +0,0 @@
-require 'spec_helper'
-
-describe Voyeur::Ogv do
- context "New Video" do
- before :each do
- @converter = Voyeur::Converter.create(format: :ogv)
- @video = Voyeur::Media.new(filename: 'test_video.ogv')
- end
-
- it "should use the correct factory" do
- @converter.class.to_s.should == "Voyeur::Ogv"
- end
-
- context "#convert_options" do
- it "default convert string" do
- @converter.convert_options.should == "-b 1500k -vcodec libtheora -acodec libvorbis -ab 160000 -g 30"
- end
-
- it "should raise an exception if no video is passed" do
- @video = nil
- -> { @converter.convert(media: @video) }.should raise_error Voyeur::Exceptions::NoMediaPresent
- end
-
- it "should return a video" do
- @converter.convert(media: @video)
- @converter.input_media.should == @video
- end
- end
- end
-
- context "An invalid Video" do
- before :each do
- @converter = Voyeur::Converter.create(format: :ogv)
- @video = Voyeur::Media.new(filename: 'test_video.mpeg')
- end
- context "File does not exist" do
- it "should return conversion status indicating failure" do
- result = @converter.convert(media: @video)
- result[:status].should == 1
- result[:media].should == @converter.output_media
- result[:error_message].should match(/test_video.mpeg: No such file or directory/)
- result[:stderr].nil?.should == false
- end
- end
- end
-end
View
48 spec/converters/video_converters/iphone_spec.rb
@@ -1,17 +1,15 @@
require 'spec_helper'
describe Voyeur::Iphone do
- before :each do
- @converter = Voyeur::Converter.create(format: :iphone)
- @media = Voyeur::Media.new(filename: valid_mpeg_file_path)
- end
+ let(:converter) { Voyeur::Converter.create(format: :iphone) }
+ let(:media) { Voyeur::Media.new(filename: valid_mpeg_file_path) }
- it "should use the correct factory" do
- @converter.class.to_s.should == "Voyeur::Iphone"
+ it "uses the correct factory" do
+ converter.class.to_s.should == "Voyeur::Iphone"
end
it "default convert string" do
- @converter.convert_options.should == "-s 320x240 -r 30000/1001 -b 200k -bt 240k -vcodec libx264 -vpre ipod320 -acodec libfaac -ac 2 -ar 48000 -ab 192k"
+ converter.convert_options.should == "-s 320x240 -r 30000/1001 -b 200k -bt 240k -vcodec libx264 -vpre ipod320 -acodec libfaac -ac 2 -ar 48000 -ab 192k"
end
context "A valid Media" do
@@ -20,44 +18,42 @@
end
context "#convert_options" do
- it "should name the media correctly" do
- @converter.convert(media: @media)
+ it "names the media correctly" do
+ converter.convert(media: media)
output_file = valid_mpeg_file_path.gsub(/mpeg/, "mp4")
- @converter.output_media.filename.should == output_file
+ converter.output_media.filename.should == output_file
end
- it "should return a media" do
- @converter.convert(media: @media)
- @converter.input_media.should == @media
+ it "returns a media" do
+ converter.convert(media: media)
+ converter.input_media.should == media
end
context "real media" do
- it "should return conversion status indicating success" do
- result = @converter.convert(media: @media)
+ it "returns conversion status indicating success" do
+ result = converter.convert(media: media)
result[:status].should == 0
- result[:media].should == @converter.output_media
+ result[:media].should == converter.output_media
end
- it "should allow them to name the media" do
- result = @converter.convert(media: @media)
+ it "allows them to name the media" do
+ result = converter.convert(media: media)
result[:status].should == 0
- result[:media].should == @converter.output_media
+ result[:media].should == converter.output_media
end
end
end
end
context "An invalid Media" do
- before :each do
- @converter = Voyeur::Converter.create(format: :mp4)
- @media = Voyeur::Media.new(filename: 'test_media.mpeg')
- end
+ let(:converter) { Voyeur::Converter.create(format: :iphone) }
+ let(:media) { Voyeur::Media.new(filename: 'test_media.mpeg') }
context "File does not exist" do
- it "should return conversion status indicating failure" do
- result = @converter.convert(media: @media)
+ it "returns conversion status indicating failure" do
+ result = converter.convert(media: media)
result[:status].should == 1
- result[:media].should == @converter.output_media
+ result[:media].should == converter.output_media
result[:error_message].should match(/test_media.mpeg: No such file or directory/)
result[:stderr].nil?.should == false
end
View
48 spec/converters/video_converters/mp4_spec.rb
@@ -1,17 +1,15 @@
require 'spec_helper'
describe Voyeur::Mp4 do
- before :each do
- @converter = Voyeur::Converter.create(format: :mp4)
- @media = Voyeur::Media.new(filename: valid_mpeg_file_path)
- end
+ let(:converter) { Voyeur::Converter.create(format: :mp4) }
+ let(:media) { Voyeur::Media.new(filename: valid_mpeg_file_path) }
- it "should use the correct factory" do
- @converter.class.to_s.should == "Voyeur::Mp4"
+ it "uses the correct factory" do
+ converter.class.to_s.should == "Voyeur::Mp4"
end
it "default convert string" do
- @converter.convert_options.should == "-b 1500k -vcodec libx264 -g 30"
+ converter.convert_options.should == "-b 1500k -vcodec libx264 -g 30"
end
context "A valid Media" do
@@ -20,44 +18,42 @@
end
context "#convert_options" do
- it "should name the media correctly" do
- @converter.convert(media: @media)
+ it "names the media correctly" do
+ converter.convert(media: media)
output_file = valid_mpeg_file_path.gsub(/mpeg/, "mp4")
- @converter.output_media.filename.should == output_file
+ converter.output_media.filename.should == output_file
end
- it "should return a media" do
- @converter.convert(media: @media)
- @converter.input_media.should == @media
+ it "returns a media" do
+ converter.convert(media: media)
+ converter.input_media.should == media
end
context "real media" do
- it "should return conversion status indicating success" do
- result = @converter.convert(media: @media)
+ it "returns conversion status indicating success" do
+ result = converter.convert(media: media)
result[:status].should == 0
- result[:media].should == @converter.output_media
+ result[:media].should == converter.output_media
end
- it "should allow them to name the media" do
- result = @converter.convert(media: @media)
+ it "allows them to name the media" do
+ result = converter.convert(media: media)
result[:status].should == 0
- result[:media].should == @converter.output_media
+ result[:media].should == converter.output_media
end
end
end
end
context "An invalid Media" do
- before :each do
- @converter = Voyeur::Converter.create(format: :mp4)
- @media = Voyeur::Media.new(filename: 'test_media.mpeg')
- end
+ let(:converter) { Voyeur::Converter.create(format: :mp4) }
+ let(:media) { Voyeur::Media.new(filename: 'test_media.mpeg') }
context "File does not exist" do
- it "should return conversion status indicating failure" do
- result = @converter.convert(media: @media)
+ it "returns conversion status indicating failure" do
+ result = converter.convert(media: media)
result[:status].should == 1
- result[:media].should == @converter.output_media
+ result[:media].should == converter.output_media
result[:error_message].should match(/test_media.mpeg: No such file or directory/)
result[:stderr].nil?.should == false
end
View
35 spec/converters/video_converters/ogv_spec.rb
@@ -2,42 +2,39 @@
describe Voyeur::Ogv do
context "New Video" do
- before :each do
- @converter = Voyeur::Converter.create(format: :ogv)
- @media = Voyeur::Media.new(filename: 'test_media.ogv')
- end
+ let(:converter) { Voyeur::Converter.create(format: :ogv) }
+ let(:media) { Voyeur::Media.new(filename: 'test_media.ogv') }
- it "should use the correct factory" do
- @converter.class.to_s.should == "Voyeur::Ogv"
+ it "uses the correct factory" do
+ converter.class.to_s.should == "Voyeur::Ogv"
end
context "#convert_options" do
it "default convert string" do
- @converter.convert_options.should == "-b 1500k -vcodec libtheora -acodec libvorbis -ab 160000 -g 30"
+ converter.convert_options.should == "-b 1500k -vcodec libtheora -acodec libvorbis -ab 160000 -g 30"
end
- it "should raise an exception if no media is passed" do
- @media = nil
- -> { @converter.convert(media: @media) }.should raise_error Voyeur::Exceptions::NoMediaPresent
+ it "raises an exception if no media is passed" do
+ media = nil
+ -> { converter.convert(media: media) }.should raise_error Voyeur::Exceptions::NoMediaPresent
end
it "should return a media" do
- @converter.convert(media: @media)
- @converter.input_media.should == @media
+ converter.convert(media: media)
+ converter.input_media.should == media
end
end
end
context "An invalid Video" do
- before :each do
- @converter = Voyeur::Converter.create(format: :ogv)
- @media = Voyeur::Media.new(filename: 'test_media.mpeg')
- end
+ let(:converter) { Voyeur::Converter.create(format: :ogv) }
+ let(:media) { Voyeur::Media.new(filename: 'test_media.mpeg') }
+
context "File does not exist" do
- it "should return conversion status indicating failure" do
- result = @converter.convert(media: @media)
+ it "returns conversion status indicating failure" do
+ result = converter.convert(media: media)
result[:status].should == 1
- result[:media].should == @converter.output_media
+ result[:media].should == converter.output_media
result[:error_message].should match(/test_media.mpeg: No such file or directory/)
result[:stderr].nil?.should == false
end
View
37 spec/converters/video_converters/webm_spec.rb
@@ -2,47 +2,42 @@
describe Voyeur::Webm do
context "New Media" do
- before :each do
- @converter = Voyeur::Converter.create(format: :webm)
- @media = Voyeur::Media.new(filename: 'test_media.webm')
- end
+ let(:converter) { Voyeur::Converter.create(format: :webm) }
+ let(:media) { Voyeur::Media.new(filename: 'test_media.webm') }
- it "should use the correct factory" do
- @converter.class.to_s.should == "Voyeur::Webm"
+ it "uses the correct factory" do
+ converter.class.to_s.should == "Voyeur::Webm"
end
context "#convert_options" do
it "default convert string" do
- @converter.convert_options.should == "-b 1500k -vcodec libvpx -acodec libvorbis -ab 160000 -f webm -g 30"
+ converter.convert_options.should == "-b 1500k -vcodec libvpx -acodec libvorbis -ab 160000 -f webm -g 30"
end
- it "should raise an exception if no media is passed" do
- @media = nil
- -> { @converter.convert(media: @media) }.should raise_error Voyeur::Exceptions::NoMediaPresent
+ it "raises an exception if no media is passed" do
+ media = nil
+ -> { converter.convert(media: media) }.should raise_error Voyeur::Exceptions::NoMediaPresent
end
- it "should return a media" do
- @converter.convert(media: @media)
- @converter.input_media.should == @media
+ it "returns a media" do
+ converter.convert(media: media)
+ converter.input_media.should == media
end
end
end
context "An invalid Media" do
- before :each do
- @converter = Voyeur::Converter.create(format: :webm)
- @media = Voyeur::Media.new(filename: 'test_media.mpeg')
- end
+ let(:converter) { Voyeur::Converter.create(format: :webm) }
+ let(:media) { Voyeur::Media.new(filename: 'test_media.mpeg') }
context "File does not exist" do
- it "should return conversion status indicating failure" do
- result = @converter.convert(media: @media)
+ it "returns conversion status indicating failure" do
+ result = converter.convert(media: media)
result[:status].should == 1
- result[:media].should == @converter.output_media
+ result[:media].should == converter.output_media
result[:error_message].should match(/test_media.mpeg: No such file or directory/)
result[:stderr].nil?.should == false
end
end
end
-
end
View
48 spec/converters/webm_spec.rb
@@ -1,48 +0,0 @@
-require 'spec_helper'
-
-describe Voyeur::Webm do
- context "New Video" do
- before :each do
- @converter = Voyeur::Converter.create(format: :webm)
- @video = Voyeur::Media.new(filename: 'test_video.webm')
- end
-
- it "should use the correct factory" do
- @converter.class.to_s.should == "Voyeur::Webm"
- end
-
- context "#convert_options" do
- it "default convert string" do
- @converter.convert_options.should == "-b 1500k -vcodec libvpx -acodec libvorbis -ab 160000 -f webm -g 30"
- end
-
- it "should raise an exception if no video is passed" do
- @video = nil
- -> { @converter.convert(media: @video) }.should raise_error Voyeur::Exceptions::NoMediaPresent
- end
-
- it "should return a video" do
- @converter.convert(media: @video)
- @converter.input_media.should == @video
- end
- end
- end
-
- context "An invalid Video" do
- before :each do
- @converter = Voyeur::Converter.create(format: :webm)
- @video = Voyeur::Media.new(filename: 'test_video.mpeg')
- end
-
- context "File does not exist" do
- it "should return conversion status indicating failure" do
- result = @converter.convert(media: @video)
- result[:status].should == 1
- result[:media].should == @converter.output_media
- result[:error_message].should match(/test_video.mpeg: No such file or directory/)
- result[:stderr].nil?.should == false
- end
- end
- end
-
-end
View
70 spec/media_time_spec.rb
@@ -2,55 +2,47 @@
describe Voyeur::MediaTime do
context "When passing a valid 0 time string in" do
- before :each do
- @raw_time = "00:00:00.00"
- @media_time = Voyeur::MediaTime.new(@raw_time)
- end
-
+ let(:raw_time) { "00:00:00.00" }
+ let(:media_time) { Voyeur::MediaTime.new(raw_time) }
+
it "hours minutes and seconds should be 0" do
- @media_time.hours.should == 0
- @media_time.minutes.should == 0
- @media_time.seconds.should == 0
+ media_time.hours.should == 0
+ media_time.minutes.should == 0
+ media_time.seconds.should == 0
end
-
- it "should return 0 seconds" do
- @media_time.to_seconds.should == 0
+
+ it "returns 0 seconds" do
+ media_time.to_seconds.should == 0
end
end
-
+
context "When passing a a valid 1 minutes long time string in" do
- before :each do
- @raw_time = "00:01:00.00"
- @media_time = Voyeur::MediaTime.new(@raw_time)
- end
-
- it "should have minutes as one" do
- @media_time.hours.should == 0
- @media_time.minutes.should == 1
- @media_time.seconds.should == 0
+ let(:raw_time) { "00:01:00.00" }
+ let(:media_time) { Voyeur::MediaTime.new(raw_time) }
+
+ it "haves minutes as one" do
+ media_time.hours.should == 0
+ media_time.minutes.should == 1
+ media_time.seconds.should == 0
end
-
- it "should return 60 seconds" do
- @media_time.to_seconds.should == 60
+
+ it "returns 60 seconds" do
+ media_time.to_seconds.should == 60
end
end
-
+
context "When passing a valid string with 1 hour 10 minute and 20 seconds" do
- before :each do
- @raw_time = "01:10:20.00"
- @media_time = Voyeur::MediaTime.new(@raw_time)
- end
-
- it "should have hour as one, minutes as 10 and seconds as 20" do
- @media_time.hours.should == 1
- @media_time.minutes.should == 10
- @media_time.seconds.should == 20
+ let(:raw_time) { "01:10:20.00" }
+ let(:media_time) { Voyeur::MediaTime.new(raw_time) }
+
+ it "haves hour as one, minutes as 10 and seconds as 20" do
+ media_time.hours.should == 1
+ media_time.minutes.should == 10
+ media_time.seconds.should == 20
end
-
- it "should return 4220 seconds" do
- @media_time.to_seconds.should == 4220
+
+ it "returns 4220 seconds" do
+ media_time.to_seconds.should == 4220
end
-
end
-
end
View
32 spec/video_spec.rb
@@ -1,40 +1,40 @@
require 'spec_helper'
describe Voyeur::Media do
- it 'should create a new video object from a filename' do
+ it 'creates a new video object from a filename' do
video_input_name = 'test_file.mpeg'
video = Voyeur::Media.new filename: video_input_name
video.filename.should == video_input_name
end
-
- it 'should get duration of a media object from a filename' do
+
+ it 'gets duration of a media object from a filename' do
video = Voyeur::Media.new( filename: valid_mpeg_file_path )
video.raw_duration.should_not be_nil
video.raw_duration.should_not == ''
end
- it "should convert a video to ogv" do
+ it "converts a video to ogv" do
Voyeur::Media.new( filename: valid_mpeg_file_path ).convert(to: :ogv)
ogv_file = valid_mpeg_file_path.gsub(/mpeg/, "ogv")
File.should exist(ogv_file)
File.delete(ogv_file)
end
- it "should convert a video to mp4" do
+ it "converts a video to mp4" do
Voyeur::Media.new( filename: valid_mpeg_file_path ).convert(to: :mp4)
mp4_file = valid_mpeg_file_path.gsub(/mpeg/, "mp4")
File.should exist(mp4_file)
File.delete(mp4_file)
end
- it "should convert a video to webm" do
+ it "converts a video to webm" do
Voyeur::Media.new( filename: valid_mpeg_file_path ).convert(to: :webm)
webm_file = valid_mpeg_file_path.gsub(/mpeg/, "webm")
File.should exist(webm_file)
File.delete(webm_file)
end
- it "should convert a video to all HTML5 video formats" do
+ it "converts a video to all HTML5 video formats" do
Voyeur::Media.new( filename: valid_mpeg_file_path ).convert_to_html5
mp4_file = valid_mpeg_file_path.gsub(/mpeg/, "mp4")
@@ -50,15 +50,15 @@
File.delete(webm_path)
end
- it "should allow the user to name the video" do
+ it "allows the user to name the video" do
Voyeur::Media.new( filename: valid_mpeg_file_path ).
convert(to: :webm, output_filename: "sexypants")
webm_file = "#{fixture_file_path}/sexypants.webm"
File.should exist(webm_file)
File.delete(webm_file)
end
- it "should allow the user to specify a video path" do
+ it "allows the user to specify a video path" do
output_path = "#{fixture_file_path}/converted"
Voyeur::Media.new( filename: valid_mpeg_file_path ).
convert(to: :ogv, output_path: output_path)
@@ -67,7 +67,7 @@
File.delete(test_file)
end
- it "should allow a user to specify a video path and filename" do
+ it "allows a user to specify a video path and filename" do
output_path = "#{fixture_file_path}/converted"
Voyeur::Media.new( filename: valid_mpeg_file_path ).
convert(to: :ogv, output_path: output_path, output_filename: "supersexypants")
@@ -76,14 +76,14 @@
File.delete(supersexypants_file)
end
- it "should allow user to convert given to a format given a class name" do
+ it "allows user to convert given to a format given a class name" do
Voyeur::Media.new( filename: valid_mpeg_file_path ).convert(to: Voyeur::Webm)
webm_file = valid_mpeg_file_path.gsub(/mpeg/, "webm")
- File.should exist(webm_file).should be_true
+ File.should exist(webm_file)
File.delete(webm_file)
end
- it "should allow a user to specify a video path and filename when converting all formats" do
+ it "allows a user to specify a video path and filename when converting all formats" do
output_path = "#{fixture_file_path}/converted"
Voyeur::Media.new( filename: valid_mpeg_file_path ).
convert_to_html5(output_path: output_path, output_filename: "supersexypants")
@@ -100,14 +100,14 @@
File.delete(webm_file)
end
- it "should not allow the user to specify a folder that doesn't exist" do
+ it "nots allow the user to specify a folder that doesn't exist" do
output_path = "#{fixture_file_path}/icecream"
-> { Voyeur::Media.new( filename: valid_mpeg_file_path ).
convert(to: :ogv, output_path: output_path) }.should raise_error Voyeur::Exceptions::InvalidLocation
end
-
+
context "when convert is called with a block" do
- it "should update the progress with time" do
+ it "updates the progress with time" do
output = ''
Voyeur::Media.new( filename: valid_mpeg_file_path ).convert(to: :ogv) do |time|
output += time

0 comments on commit a00cee6

Please sign in to comment.