Module: Smith::Commands::Common
- Defined in:
- lib/smith/commands/common.rb
Instance Method Summary collapse
-
#agent_group(group) ⇒ Array<Class>
Returns the fully qualified class of all agents in a group.
Instance Method Details
#agent_group(group) ⇒ Array<Class>
Returns the fully qualified class of all agents in a group. The group //must// be a sub-directory in the agents directory. Only sym-links are considered. The group directory is recursively searched and added to the ilst of agents for that group if it passed all checks.
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 |
# File 'lib/smith/commands/common.rb', line 14 def agent_group(group) agents = Smith.agent_directories.map do |agent_directory| raise RuntimeError, "No group specified." unless group group_directory(agent_directory, group) do |group_directory, groups_prefix| if group_directory.exist? && group_directory.directory? agents = Pathname.glob(group_directory.join("*.rb")).map(&:expand_path) agents.inject([]) do |acc, agent| if agent.symlink? = resolve_agent_path(group_directory, agent) acc << Utils.class_name_from_path(, agent_directory, groups_prefix) end end else nil end end end.uniq raise RuntimeError, "Group does not exist: #{group}" if agents == [nil] agents.compact.flatten end |