Permalink
Browse files

fail obviously when mediainfo CLI not installed

  • Loading branch information...
1 parent 31a9b65 commit 0a4205525e0d73eab94165e0a935a3e1547e94ba @greatseth greatseth committed Oct 12, 2010
Showing with 19 additions and 1 deletion.
  1. +14 −1 lib/mediainfo.rb
  2. +5 −0 test/mediainfo_test.rb
View
@@ -91,6 +91,7 @@ class Mediainfo
class Error < StandardError; end
class ExecutionError < Error; end
class IncompatibleVersionError < Error; end
+ class UnknownVersionError < Error; end
def self.delegate(method_name, stream_type = nil)
if stream_type == :general
@@ -101,7 +102,11 @@ def self.delegate(method_name, stream_type = nil)
end
def self.version
- @version ||= `#{path} --Version`[/v([\d.]+)/, 1]
+ @version ||= `#{version_command}`[/v([\d.]+)/, 1]
+ end
+
+ def self.version_command
+ "#{path} --Version"
end
# AttrReaders depends on this.
@@ -371,6 +376,14 @@ def #{stream_type}?; streams.any? { |x| x.#{stream_type}? }; end
###
def initialize(full_filename = nil)
+ unless mediainfo_version
+ raise UnknownVersionError,
+ "Unable to determine mediainfo version. " +
+ "We tried: #{self.class.version_command} " +
+ "Are you sure mediainfo is installed at #{self.class.path.inspect}? " +
+ "Set Mediainfo.path = /where/is/mediainfo if it is not in your PATH."
+ end
+
if mediainfo_version < "0.7.25"
raise IncompatibleVersionError,
"Your version of mediainfo, #{mediainfo_version}, " +
View
@@ -144,4 +144,9 @@ def setup
Mediainfo.any_instance.stubs(:mediainfo_version).returns("0.7.10")
assert_raises(Mediainfo::IncompatibleVersionError) { Mediainfo.new }
end
+
+ test "fails obviously when CLI is not installed" do
+ Mediainfo.any_instance.stubs(:mediainfo_version).returns(nil)
+ assert_raises(Mediainfo::UnknownVersionError) { Mediainfo.new }
+ end
end

0 comments on commit 0a42055

Please sign in to comment.