Module: Smith::Commands::Common

Included in:
Restart, Start, Stop
Defined in:
lib/smith/commands/common.rb

Instance Method Summary collapse

Instance Method Details

#agent_group(group) ⇒ Object

Raises:

  • (RuntimeError)


5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/smith/commands/common.rb', line 5

def agent_group(group)
  agents = Smith.agent_paths.map do |path|
    group_dir = path.join(group)
    if group_dir.exist? && group_dir.directory?
      agents = Pathname.glob(group_dir.join("*_agent.rb"))
      agents.map {|a| Extlib::Inflection.camelize(a.basename(".rb").to_s)}
    else
      nil
    end
  end.uniq

  raise RuntimeError, "Group does not exist: #{group}" if agents == [nil]
  agents.compact.flatten
end