Class: Cmdserver::Settings

Inherits:
Object
  • Object
show all
Defined in:
lib/cmdserver.rb

Overview

{{{

Direct Known Subclasses

CustomSettings

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(work_dir = "~/.cmdserver/") ⇒ Settings

Returns a new instance of Settings.



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/cmdserver.rb', line 15

def initialize(work_dir="~/.cmdserver/")
    @workdir = Pathname.new(File.expand_path(work_dir))
    @module_dir = @workdir + "modules"
    if not @workdir.exist?
        Dir.mkdir @workdir
    end
    if not @module_dir.exist?
        Dir.mkdir @module_dir
    end
    # load_modules is now being called by the
    # TCPCommandServer class
end

Instance Attribute Details

#module_dirObject (readonly)

Returns the value of attribute module_dir.



12
13
14
# File 'lib/cmdserver.rb', line 12

def module_dir
  @module_dir
end

#workdirObject (readonly)

Returns the value of attribute workdir.



13
14
15
# File 'lib/cmdserver.rb', line 13

def workdir
  @workdir
end

Instance Method Details

#load_modulesObject



28
29
30
31
32
33
34
# File 'lib/cmdserver.rb', line 28

def load_modules
    Dir.glob("#{@module_dir}/**/*.rb").each do |mod|
        Cmdserver::Cmdprotocol.extend_protocol()
        puts "Loading module: #{mod}"
        require mod
    end
end