Module: Muding

Defined in:
lib/muding.rb,
lib/version.rb,
lib/initializer.rb,
lib/muding_generator/base.rb,
lib/muding_generator/spec.rb,
lib/muding_generator/options.rb,
lib/muding_generator/scripts.rb,
lib/muding_generator/commands.rb,
lib/muding_generator/manifest.rb,
lib/muding_generator/simple_logger.rb,
lib/muding_generator/lookup.rb

Defined Under Namespace

Modules: Generator, VERSION Classes: Configuration, Initializer

Constant Summary collapse

Log =
Log4r::Logger.new 'muding'

Class Method Summary collapse

Class Method Details

.reload_controller_codeObject



47
48
49
50
# File 'lib/muding.rb', line 47

def reload_controller_code
	load "./mud/controllers/mud.rb"
	Dir["./mud/controllers/*_controller.rb"].sort.each { |ext| load ext }
end

.run(input, handle) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/muding.rb', line 9

def run(input, handle)
	unless input
		raise Errno::EPIPE.new("Nil String to Pipe")
	end
	default_command = handle.default_command
	session = handle.session
	route = handle.route

	reload_controller_code
	

	# if we don't have a default command we need to figure 
	# out what the command is.
	#
	# format: "command [args]"
	unless default_command 
		string_array = input.split(" ")
		command = string_array.shift
		args = string_array.join(" ") 
	else
		command = default_command.to_s
		args = input
	end

	if command == nil
		raise Controller::NoCommandException
	end

	return route.new(command, session).service(*args)

rescue Controller::NoCommandException
	return Controller::NotFound.new("get",session).service()
rescue Errno::EPIPE
	raise
rescue Exception => x
	Log.warn x
	return Controller::ServerError.new("get",session).service()
end