sshfs-mapper: Reorganized code.
git-svn-id: https://websvn.glenux.net/svn/Upoc/sshfs-mapper/trunk@1655 eaee96b3-f302-0410-b096-c6cfd47f7835
This commit is contained in:
parent
2c979d9de2
commit
b6fe3b2d35
3 changed files with 13 additions and 12 deletions
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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]"
|
Loading…
Reference in a new issue