class Quick::FS::ModuleDir

Public Class Methods

new(mod) click to toggle source
# File lib/quick/fs.rb, line 152
def initialize(mod)
        @mod = mod
end
path_method(name, value=nil, &body) click to toggle source
# File lib/quick/fs.rb, line 131
def self.path_method(name, value=nil, &body)
        body = proc {value} if value and not body
        define_method name do |path=nil, *args|
                cur, child = path_parts path
                if cur
                        target = child cur
                        if target.respond_to? name
                                target.send name, child, *args
                        else
                                FuseFS::DEFAULT_FS.send name, child, *args
                        end
                else
                        if body
                                instance_exec *args, &body
                        else
                                FuseFS::DEFAULT_FS.send name, child, *args
                        end
                end
        end
end

Private Instance Methods

child(name) click to toggle source
# File lib/quick/fs.rb, line 188
def child(name)
        case name
        when '._rfuse_check_'
                RFuseCheck.instance
        when '#brb_uri'
                BrBURI
        when '#singleton_class'
                self.class.new @mod.singleton_class
        else
                begin
                        subdir name
                rescue Errno::ENOENT
                        subfile name
                end
        end
end
path_parts(path) click to toggle source
# File lib/quick/fs.rb, line 182
def path_parts(path)
        return nil unless path
        path = path.sub /\A\//, ''
        path.split '/', 2
end
subdir(name) click to toggle source
# File lib/quick/fs.rb, line 205
def subdir(name)
        self.class.new @mod.const_get(name)
rescue NameError
        raise Errno::ENOENT
end
subfile(name) click to toggle source
# File lib/quick/fs.rb, line 211
def subfile(name)
        raise Errno::ENOENT unless name.end_with? '.rb'
        unless name =~ /\A(.+)\.in_use.rb\Z/
                @mod.code_files[name]
        else
                name = $1 + '.rb'
                raise Errno::ENOENT unless @mod.code_files.key? name
                @mod.code_files[name].in_use
        end
end
subfiles() click to toggle source
# File lib/quick/fs.rb, line 228
def subfiles
        files = @mod.code_files.keys.map(&:to_s)
        files + files.map {|s| s.sub /rb\Z/, 'in_use.rb'}
end
submods() click to toggle source
# File lib/quick/fs.rb, line 222
def submods
        consts = @mod.constants(false)
        consts.delete :fatal
        consts.select {|c| @mod.const_get(c).is_a? Module}.map &:to_s
end