Module: FSR::Cmd
- Included in:
- CommandSocket
- Defined in:
- lib/fsr/cmd.rb,
lib/fsr/cmd/api.rb,
lib/fsr/cmd/enum.rb,
lib/fsr/cmd/load.rb,
lib/fsr/cmd/calls.rb,
lib/fsr/cmd/sofia.rb,
lib/fsr/cmd/fsctl.rb,
lib/fsr/cmd/hupall.rb,
lib/fsr/cmd/status.rb,
lib/fsr/cmd/reload.rb,
lib/fsr/cmd/uuid_dump.rb,
lib/fsr/cmd/originate.rb,
lib/fsr/cmd/reload_xml.rb,
lib/fsr/cmd/valet_info.rb,
lib/fsr/cmd/uuid_bridge.rb,
lib/fsr/cmd/sofia/status.rb,
lib/fsr/cmd/sofia_contact.rb,
lib/fsr/cmd/global_getvar.rb,
lib/fsr/cmd/domain_exists.rb,
lib/fsr/cmd/sofia/profile.rb,
lib/fsr/cmd/global_setvar.rb
Defined Under Namespace
Classes: API, Calls, Command, DomainExists, Enum, Fsctl, GlobalGetvar, GlobalSetvar, Hupall, Load, Originate, Reload, ReloadXML, Sofia, SofiaContact, Status, UuidBridge, UuidDump, ValetInfo
Constant Summary
- COMMANDS =
{}
- LOAD_PATH =
[Pathname(FSR::ROOT).join( "fsr", "cmd")]
Class Method Summary (collapse)
- + (Object) list
-
+ (Object) load_all(force_reload = false)
Load all of the commands we find in Cmd::LOAD_PATH.
- + (Object) load_command(command, force_reload = false)
- + (Object) register(command, obj)
Instance Method Summary (collapse)
Class Method Details
+ (Object) list
34 35 36 |
# File 'lib/fsr/cmd.rb', line 34 def self.list COMMANDS.keys end |
+ (Object) load_all(force_reload = false)
Load all of the commands we find in Cmd::LOAD_PATH
63 64 65 66 67 68 |
# File 'lib/fsr/cmd.rb', line 63 def self.load_all(force_reload = false) LOAD_PATH.each do |load_path| Dir[load_path.join("*.rb").to_s].each { |command_file| load_command(command_file, force_reload) } end list end |
+ (Object) load_command(command, force_reload = false)
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/fsr/cmd.rb', line 38 def self.load_command(command, force_reload = false) # If we get a path specification and it's an existing file, load it if File.file?(command) if force_reload return load(command) else return require(command) end end Log.debug "Trying load paths" # If we find a file named the same as the command passed in LOAD_PATH, load it if found_command_path = LOAD_PATH.detect { |command_path| command_path.join("#{command}.rb").file? } command_file = found_command_path.join(command) Log.debug "Trying to load #{command_file}" if force_reload load command_file.to_s + ".rb" else require command_file end else raise "#{command} not found in #{LOAD_PATH.join(":")}" end end |
+ (Object) register(command, obj)
27 28 29 30 31 32 |
# File 'lib/fsr/cmd.rb', line 27 def self.register(command, obj) COMMANDS[command.to_sym] = obj code = "def %s(*args, &block) COMMANDS[%p].new(self, *args, &block) end" % [command, command] Cmd.module_eval(code) end |
Instance Method Details
- (Object) commands
70 71 72 |
# File 'lib/fsr/cmd.rb', line 70 def commands FSR::Cmd.list end |