Sha256: 769dfe90b1188a28df5f6e8b49b34267bb44c63a75af5d687b40572eaefa6180
Contents?: true
Size: 1.71 KB
Versions: 4
Compression:
Stored size: 1.71 KB
Contents
require 'host_range' module Auger class Project attr_accessor :name, :fqdns, :hosts, :connections, :roles def self.load(name, &block) project = new(name) project.instance_eval(&block) project end def initialize(name) @name = name @hosts = [] @fqdns = [] @connections = [] @roles = Hash.new { |h,k| h[k] = [] } self end def role(name, *args) options = args.last.is_a?(Hash) ? args.pop : {} servers = args.map { |arg| HostRange.parse(arg) }.flatten #servers.each { |server| roles[name] << server } servers.each { |server| roles[name] << Auger::Server.new(server, options) } end def server(*args) options = args.last.is_a?(Hash) ? args.pop : {} roles = [] servers = [] args.each do |arg| case arg when Symbol then roles << arg when String then servers << arg else raise ArgumentError, "illegal argument to server: #{arg}" end end roles = [nil] if roles.empty? # default role roles.each { |name| role(name, *servers, options) } end alias :hosts :server ## return array of servers for given array of roles (default to all) def servers(roles = []) (roles.empty? ? @roles.values : @roles.values_at(*roles)) .flatten end alias :host :hosts ## add fqdn or return list of fqdns def fqdns(*ranges) ranges.empty? ? @fqdns.flatten : @fqdns << [*ranges].map {|r| HostRange.parse(r)} end alias :fqdn :fqdns def tests @connections.map do |connection| connection.requests.map do |request| request.tests.map { |test| test } end end.flatten end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
auger-1.3.3 | lib/auger/project.rb |
auger-1.3.2 | lib/auger/project.rb |
auger-1.3.1 | lib/auger/project.rb |
auger-1.3.0 | lib/auger/project.rb |