Permalink
Browse files

raise exceptions on invalid scenarios

  • Loading branch information...
1 parent 67147fc commit 449d02bbfc99145fe7a3a74239dde16770d8e4c2 @ddollar committed May 11, 2010
Showing with 8 additions and 0 deletions.
  1. +8 −0 lib/squashr.rb
View
@@ -1,10 +1,18 @@
class Squashr
+ class SourceDirNotFound < Exception; end
+ class SourceNotDirectory < Exception; end
+ class TargetExists < Exception; end
+
VERSION = "0.0.1"
MKSQUASHFS_BIN = File.expand_path("../../ext/squashfs3.4/squashfs-tools/mksquashfs", __FILE__)
def self.squash(source, target, options=[])
+ raise SourceDirNotFound unless File.exist?(source)
+ raise SourceNotDirectory unless File.directory?(source)
+ raise TargetExists if File.exist?(target)
+
%x{ #{MKSQUASHFS_BIN} #{source} #{target} #{options.join(' ')} }
end

0 comments on commit 449d02b

Please sign in to comment.