From b6fe3b2d35db40c30a98c51fbf2a63930ea94782 Mon Sep 17 00:00:00 2001 From: glenux Date: Mon, 7 Mar 2011 23:25:47 +0000 Subject: [PATCH] sshfs-mapper: Reorganized code. git-svn-id: https://websvn.glenux.net/svn/Upoc/sshfs-mapper/trunk@1655 eaee96b3-f302-0410-b096-c6cfd47f7835 --- sshfs-mapper.rb | 13 +++++++------ config.rb => sshfs-mapper/config.rb | 12 ++++++------ map.rb => sshfs-mapper/map.rb | 0 3 files changed, 13 insertions(+), 12 deletions(-) rename config.rb => sshfs-mapper/config.rb (93%) rename map.rb => sshfs-mapper/map.rb (100%) 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