diff --git a/sshfs-mapper.rb b/sshfs-mapper.rb index e045b4b..3b87e3d 100755 --- a/sshfs-mapper.rb +++ b/sshfs-mapper.rb @@ -4,22 +4,22 @@ $DEBUG = true $VERBOSE = true -require 'config' -require 'map' +require 'sshfs-mapper/config' +require 'sshfs-mapper/map' module SshfsMapper class SshfsMapper - def initialize() + def initialize @active_maps = nil puts "-- sshfs-mapper --" conf = Config.new - conf.parseCmd ARGV - @active_maps = conf.parseFile + conf.parse_cmd_line ARGV + @active_maps = conf.parse_file puts conf end - def run() + def run if @active_maps.nil? then return end @@ -35,3 +35,4 @@ end app = SshfsMapper::SshfsMapper.new app.run + diff --git a/config.rb b/sshfs-mapper/config.rb similarity index 93% rename from config.rb rename to sshfs-mapper/config.rb index c79c5f8..97a780e 100644 --- a/config.rb +++ b/sshfs-mapper/config.rb @@ -11,7 +11,7 @@ module SshfsMapper attr_reader :maps_active attr_reader :maps - def initialize() + def initialize user = if ENV['USER'] then ENV['USER'] else @@ -39,20 +39,20 @@ module SshfsMapper @verbose_enable = false end - def parseFile( &blk ) + def parse_file &blk puts "Config: #{@config_dir}/config" maps = [] Find.find( @config_dir ) do |path| - if File.file?( path ) + if File.file? path if File.basename( path ) =~ /.map$/ begin - map = Map.new( path ) + map = Map.new path map.parse() if blk then yield map else - maps.push( map ) + maps.push map end rescue # error while parsing map @@ -64,7 +64,7 @@ module SshfsMapper return maps end - def parseCmd( args ) + def parse_cmd_line args opts = OptionParser.new do |opts| opts.banner = "Usage: #{$0} [options]" diff --git a/map.rb b/sshfs-mapper/map.rb similarity index 100% rename from map.rb rename to sshfs-mapper/map.rb