lib/revenc/encfs_wrapper.rb in revenc-0.1.3 vs lib/revenc/encfs_wrapper.rb in revenc-0.2.1

- old
+ new

@@ -7,26 +7,23 @@ @base_dir = base_dir @options = options end def mount(source=nil, mount_point_folder=nil) + mount_point_options = @options || {} + mount_point_options = mount_point_options.merge(@options[:mount].dup) if @options[:mount] # add params from config file if not specified - source = configatron.mount.source.name unless source - mount_point_folder = configatron.mount.mountpoint.name unless mount_point_folder + source = (mount_point_options[:source] ? mount_point_options[:source][:name] : nil) unless source + mount_point_folder = (mount_point_options[:mountpoint] ? mount_point_options[:mountpoint][:name] : nil) unless mount_point_folder # sanity check params raise "source folder not specified" unless source raise "mountpoint not specified" unless mount_point_folder - mount_point_options = @options.merge(:passphrasefile => configatron.mount.passphrasefile.name) - mount_point_options = mount_point_options.merge(:keyfile => configatron.mount.keyfile.name) - mount_point_options = mount_point_options.merge(:cmd => configatron.mount.cmd) if configatron.mount.cmd - mount_point_options = mount_point_options.merge(:executable => configatron.mount.executable) if configatron.mount.executable + mount_point = MountPoint.new(mount_point_folder, source, mount_point_options.merge(@options)) - mount_point = MountPoint.new(mount_point_folder, source, mount_point_options) - if @options[:verbose] puts "mount: source=#{mount_point.source.name}".cyan puts "mount: mountpoint=#{mount_point.name}".cyan puts "mount: passphrasefile=#{mount_point.passphrasefile.name}".cyan puts "mount: keyfile=#{mount_point.keyfile.name}".cyan @@ -36,22 +33,22 @@ mount_point.execute end def unmount(foldername = nil) - + unmount_point_options = @options || {} + unmount_point_options = unmount_point_options.merge(@options[:unmount].dup) if @options[:unmount] + mount_point_options = @options[:mount] ? @options[:mount].dup : {} + # add param from config file if not specified, try specific unmount - foldername = configatron.unmount.mountpoint.name unless foldername + foldername = (unmount_point_options[:mountpoint] ? unmount_point_options[:mountpoint][:name] : nil) unless foldername # fallback to mount.mountpoint if specified - foldername = configatron.mount.mountpoint.name unless foldername - + foldername = (mount_point_options[:mountpoint] ? mount_point_options[:mountpoint][:name] : nil) unless foldername + # sanity check params raise "mountpoint not specified" unless foldername - unmount_point_options = @options || {} - unmount_point_options = unmount_point_options.merge(:cmd => configatron.unmount.cmd) if configatron.umount.cmd - unmount_point_options = unmount_point_options.merge(:executable => configatron.unmount.executable) if configatron.umount.executable unmount_point = UnmountPoint.new(foldername, unmount_point_options) if @options[:verbose] puts "unmount: mountpoint=#{unmount_point.mountpoint.name}".cyan puts "unmount: cmd=#{unmount_point.cmd}".cyan @@ -60,26 +57,25 @@ unmount_point.execute end def copy(source=nil, destination=nil) + copy_options = @options || {} + copy_options = copy_options.merge(@options[:copy].dup) if @options[:copy] + mount_point_options = @options[:mount] ? @options[:mount].dup : {} # add params from config file if not specified - source = configatron.copy.source.name unless source + source = (copy_options[:source] ? copy_options[:source][:name] : nil) unless source # fallback - source = configatron.mount.mountpoint.name unless source - destination = configatron.copy.destination.name unless destination + source = (mount_point_options[:mountpoint] ? mount_point_options[:mountpoint][:name] : nil) unless source + destination = (copy_options[:destination] ? copy_options[:destination][:name] : nil) unless destination # sanity check params raise "source folder not specified" unless source raise "destination not specified" unless destination - copy_options = @options || {} - copy_options = copy_options.merge(:cmd => configatron.copy.cmd) if configatron.copy.cmd - copy_options = copy_options.merge(:executable => configatron.copy.executable) if configatron.copy.executable - copy_options = copy_options.merge(:mountpoint => configatron.mount.mountpoint.name) if configatron.mount.mountpoint.name - - copy_folder = CopySourceFolder.new( source, destination, copy_options) + copy_options = copy_options.merge(:mountpoint => mount_point_options[:mountpoint][:name]) if mount_point_options[:mountpoint] + copy_folder = CopySourceFolder.new(source, destination, copy_options) if @options[:verbose] puts "copy: source=#{copy_folder.name}".cyan puts "copy: destination=#{copy_folder.destination.name}".cyan puts "copy: cmd=#{copy_folder.cmd}".cyan