Requirements: remove circular references.

This commit is contained in:
Glenn Y. Rolland 2015-11-05 23:14:02 +01:00
parent d3309f0344
commit 222cc7c23b
8 changed files with 36 additions and 29 deletions

View file

@ -5,11 +5,18 @@ def _ str
Qt::Object.tr(str) Qt::Object.tr(str)
end end
module Qasim
autoload :Config, 'qasim/config' ## Core libs
autoload :Map, 'qasim/map' require 'qasim/constants'
autoload :Ui, 'qasim/ui' require 'qasim/config'
autoload :Cli, 'qasim/cli' require 'qasim/map'
autoload :MapManager, 'qasim/map_manager' require 'qasim/map_manager'
end
## Plugins for maps
require 'qasim/map/generic'
require 'qasim/map/smb'
require 'qasim/map/ssh'
require 'qasim/map/webdav'

View file

@ -1,4 +1,5 @@
require 'qasim/qasim_qrc' require 'qasim/qasim_qrc'
require 'qasim/ui'
module Qasim module Qasim
class QasimApp class QasimApp

View file

@ -68,8 +68,6 @@ module Qasim ; module Map
line = env_substitute(line) line = env_substitute(line)
params[:filename] = filename params[:filename] = filename
case line case line
when /^\s*TYPE\s*=\s*(.*)\s*$/ then
params[:type] = $1
when /^\s*REMOTE_USER\s*=\s*(.*)\s*$/ then when /^\s*REMOTE_USER\s*=\s*(.*)\s*$/ then
params[:ssh_user] = $1 params[:ssh_user] = $1
when /^\s*REMOTE_PORT\s*=\s*(.*)\s*$/ then when /^\s*REMOTE_PORT\s*=\s*(.*)\s*$/ then
@ -83,13 +81,20 @@ module Qasim ; module Map
when /^\s*MAP\s*=\s*(.*)\s+(.*)\s*$/ then when /^\s*MAP\s*=\s*(.*)\s+(.*)\s*$/ then
params[:links] ||= {} params[:links] ||= {}
params[:links][$1] = $2 params[:links][$1] = $2
when /^\s*([A-Z_]+)\s*=\s*(.*)\s*$/ then
key = $1.downcase.to_sym
params[key] = $2
when /^\s*$/,/^\s*#/ then when /^\s*$/,/^\s*#/ then
else else
raise MapParseError, "parse error at #{@filename}:#{linect}" STDERR.puts line
raise ParseError, "parse error at #{filename}:#{linect}"
end end
end end
f.close f.close
map_class = class_for params[:type] map_class = class_for params[:type]
if map_class.nil? then
raise ParseError, "no plugin found for type « #{params[:type]} »"
end
map = map_class.new appcfg, params map = map_class.new appcfg, params
return map return map
end end

View file

@ -2,7 +2,7 @@
require 'fileutils' require 'fileutils'
require 'pp' require 'pp'
module Qasim ; class Map; class Generic module Qasim ; module Map; class Generic
attr_reader :links attr_reader :links
attr_reader :filename attr_reader :filename
attr_reader :name attr_reader :name

View file

@ -3,22 +3,20 @@
require 'fileutils' require 'fileutils'
require 'qasim/map/generic' require 'qasim/map/generic'
class Qasim::Map::Webdav < Qasim::Map::Generic module Qasim; module Map; class Webdav < Qasim::Map::Generic
def initialize *opts def initialize *opts
super super
end end
def self.parameters def self.parameters
super.merge({ super.merge({
webdav_user: { required: true}, # ex : foo smb_user: { required: true}, # ex : foo
webdav_password: { required: true}, # ex : bar smb_password: { required: true}, # ex : bar
webdav_port: { default: 80}, # ex : 80, 8080, 443
webdav_protocol: { default: :http} # ex : http, https
}) })
end end
def self.handles def self.handles
[ :webdav, :webdavs ] [ :samba, :cifs, :smb ]
end
end end
end ; end ; end

View file

@ -2,7 +2,7 @@
require 'fileutils' require 'fileutils'
require 'qasim/map/generic' require 'qasim/map/generic'
module Qasim ; class Map ; class Ssh < Qasim::Map::Generic module Qasim ; module Map ; class Ssh < Qasim::Map::Generic
attr_reader :path, attr_reader :path,
:host, :host,
:port, :port,

View file

@ -3,7 +3,7 @@
require 'fileutils' require 'fileutils'
require 'qasim/map/generic' require 'qasim/map/generic'
class Qasim::Map::Webdav < Qasim::Map::Generic module Qasim; module Map; class Webdav < Qasim::Map::Generic
def initialize *opts def initialize *opts
super super
end end
@ -20,5 +20,6 @@ class Qasim::Map::Webdav < Qasim::Map::Generic
def self.handles def self.handles
[ :webdav, :webdavs ] [ :webdav, :webdavs ]
end end
end end ; end ; end

View file

@ -1,8 +1,3 @@
require 'qasim/constants' require 'qasim/ui/about'
require 'qasim/ui/preferences'
module Qasim ; module Ui
autoload :About, 'qasim/ui/about'
autoload :Preferences, 'qasim/ui/preferences'
end ; end