4
5
6
7
8
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
|
# File 'lib/rubord/models/commands/loader.rb', line 4
def self.load(path, client, registry, logCommands: true)
full_path = File.expand_path(path)
files = Dir["#{full_path}/**/*.rb"]
files.each do |file|
begin
Kernel.load(file)
rescue => e
puts "[Rubord:Commands] Error loading #{file}:"
puts " #{e.class}: #{e.message}"
end
end
found_classes = []
ObjectSpace.each_object(Class) do |klass|
next if klass == Rubord::CommandBase
if klass.ancestors.include?(Rubord::CommandBase)
found_classes << klass
end
end
found_classes.each do |klass|
begin
registry.register(klass, client, logCommands)
rescue => e
puts "[Rubord:Commands] ERRO ao registrar #{klass}:"
puts " #{e.class}: #{e.message}"
end
end
end
|