Turns a list, or something resembling a list, into a properly-formatted ServerDefinition list. Keep an eye on this one — it’s entirely too magical for its own good. In particular, if ServerDefinition ever inherits from Array, this will break.
# File lib/capistrano/role.rb, line 87 87: def self.wrap_list (*list) 88: options = list.last.is_a?(Hash) ? list.pop : {} 89: if list.length == 1 90: if list.first.nil? 91: return [] 92: elsif list.first.is_a?(Array) 93: list = list.first 94: end 95: end 96: options.merge! list.pop if list.last.is_a?(Hash) 97: list.map do |item| 98: self.wrap_server item, options 99: end 100: end
Wraps a string in a ServerDefinition, if it isn’t already. This and wrap_list should probably go in ServerDefinition in some form.
# File lib/capistrano/role.rb, line 79 79: def self.wrap_server (item, options) 80: item.is_a?(ServerDefinition) ? item : ServerDefinition.new(item, options) 81: end
# File lib/capistrano/role.rb, line 36 36: def clear 37: @dynamic_servers.clear 38: @static_servers.clear 39: end
# File lib/capistrano/role.rb, line 11 11: def each(&block) 12: servers.each &block 13: end
# File lib/capistrano/role.rb, line 32 32: def empty? 33: servers.empty? 34: end
# File lib/capistrano/role.rb, line 41 41: def include?(server) 42: servers.include?(server) 43: end
# File lib/capistrano/role.rb, line 15 15: def push(*list) 16: options = list.last.is_a?(Hash) ? list.pop : {} 17: list.each do |item| 18: if item.respond_to?(:call) 19: @dynamic_servers << DynamicServerList.new(item, options) 20: else 21: @static_servers << self.class.wrap_server(item, options) 22: end 23: end 24: end
# File lib/capistrano/role.rb, line 27 27: def servers 28: @static_servers + dynamic_servers 29: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.