sshfs-mapper: completed map, config & app class.

git-svn-id: https://websvn.glenux.net/svn/Upoc/sshfs-mapper/trunk@1363 eaee96b3-f302-0410-b096-c6cfd47f7835
This commit is contained in:
glenux 2009-05-22 21:01:23 +00:00
parent 25cf230fe4
commit a2b00e87ae
3 changed files with 116 additions and 106 deletions

View file

@ -5,6 +5,7 @@ require 'ostruct'
require 'pp'
require 'find'
module SshfsMapper
class Config
attr_reader :options
@ -37,21 +38,24 @@ class Config
} )
end
def parseFile
def parseFile(&blk)
puts "Parsing #{@options.config_dir}/config"
puts "Parsing maps..."
maps = []
Find.find( @options.config_dir ) do |path|
if File.file?( path )
if File.basename( path ) =~ /.map$/
puts "* #{File.basename( path )}"
maps.push( path )
if blk then yield path end
else
Find.prune # Don't look any further into this way
end
#total_size += FileTest.size(path)
end
end
return maps
end
def parseCmd( args )
@ -98,4 +102,4 @@ class Config
s.join("\n")
end
end
end

8
map.rb
View file

@ -1,6 +1,12 @@
module SshfsMapper
class Map
def initialize
@host = nil
@port = 22
@user = nil
end
end
end

View file

@ -1,33 +1,33 @@
#!/usr/bin/ruby
require 'config'
require 'map'
class Map
def initialize()
end
def self.loadFromFile( filename )
end
end
class Config
end
module SshfsMapper
class SshfsMapper
def initialize()
@maps = nil
puts "-- sshfs-mapper --"
conf = Config.new
conf.parseCmd ARGV
conf.parseFile
@maps = conf.parseFile
puts conf
end
def run()
if @maps.nil? then
return
end
@maps.each do |map_path|
map = Map.new( map_path )
end
puts "--run"
end
end
end
SshfsMapper.new
app = SshfsMapper::SshfsMapper.new
app.run