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:
parent
b31d20a0ce
commit
81a325116c
3 changed files with 116 additions and 106 deletions
12
config.rb
12
config.rb
|
@ -5,7 +5,8 @@ require 'ostruct'
|
|||
require 'pp'
|
||||
require 'find'
|
||||
|
||||
class Config
|
||||
module SshfsMapper
|
||||
class Config
|
||||
attr_reader :options
|
||||
|
||||
def initialize()
|
||||
|
@ -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 )
|
||||
|
@ -97,5 +101,5 @@ class Config
|
|||
s << "verbose_enable = #{@options.verbose_enable}"
|
||||
s.join("\n")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
10
map.rb
10
map.rb
|
@ -1,6 +1,12 @@
|
|||
|
||||
class Map
|
||||
module SshfsMapper
|
||||
class Map
|
||||
def initialize
|
||||
@host = nil
|
||||
@port = 22
|
||||
@user = nil
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
class SshfsMapper
|
||||
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
|
||||
|
||||
|
|
Loading…
Reference in a new issue