lib/auger/project.rb in auger-1.4.1 vs lib/auger/project.rb in auger-1.4.2
- old
+ new
@@ -2,11 +2,11 @@
module Auger
class Project
attr_accessor :name, :connections, :servers
-
+
def self.load(name, &block)
project = new(name)
project.instance_eval(&block)
project
end
@@ -18,14 +18,23 @@
self
end
## set server, or list of server names, with optional roles and options
## e.g. server server1, server2, :roleA, :roleB, options => values
+ ## servers can be any combination in:
+ ## strings: passed through HostRange to make an array
+ ## array: or expressions that returns an array
+ ## block: returning an array (arrays will be flattened)
+ ## roles are symbols
+ ## options are hash members, must be last args
def server(*args)
options = args.last.is_a?(Hash) ? args.pop : {}
roles = args.select { |arg| arg.class == Symbol }
- servers = args.select { |arg| arg.class == String }.map { |arg| HostRange.parse(arg) }
+ servers =
+ args.select { |arg| arg.class == String }.map { |arg| HostRange.parse(arg) } +
+ args.select { |arg| arg.class == Array } +
+ (block_given? ? yield : [])
@servers += servers.flatten.map do |name|
Auger::Server.new(name, *roles, options)
end
end
@@ -58,7 +67,7 @@
end
end.flatten
end
end
-
+
end