Class: Smith::Commands::Agents

Inherits:
Smith::CommandBase show all
Defined in:
lib/smith/commands/agency/agents.rb

Instance Attribute Summary

Attributes inherited from Smith::CommandBase

#options, #target

Instance Method Summary collapse

Methods inherited from Smith::CommandBase

#banner, #format_help, #initialize, #parse_options

Methods included from Logger

included

Constructor Details

This class inherits a constructor from Smith::CommandBase

Instance Method Details

#_agentsObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/smith/commands/agency/agents.rb', line 9

def _agents
  # FIXME make sure that if the path doesn't exist don't blow up.
  separator = (options[:one_column]) ? "\n" : " "

  Smith.agent_paths.inject([]) do |path_acc,path|
    path_acc.tap do |a|
      if path.exist?
        a << path.each_child.inject([]) do |agent_acc,p|
          agent_acc.tap do |b|
            b << Extlib::Inflection.camelize(p.basename('.rb')) if p.file? && p.basename('.rb').to_s.end_with?("agent")
          end
        end.flatten
      else
        return "Agent path doesn't exist: #{path}"
      end
    end
  end.flatten.sort.join(separator)
end

#executeObject



5
6
7
# File 'lib/smith/commands/agency/agents.rb', line 5

def execute
  responder.succeed(_agents)
end