Class: Capistrano::Configuration::RoleFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/capistrano/configuration/role_filter.rb

Instance Method Summary collapse

Constructor Details

#initialize(values) ⇒ RoleFilter

Returns a new instance of RoleFilter



4
5
6
7
8
9
# File 'lib/capistrano/configuration/role_filter.rb', line 4

def initialize(values)
  av = Array(values).dup
  av.map! { |v| v.is_a?(String) ? v.split(",") : v }
  av.flatten!
  @rex = regex_matcher(av)
end

Instance Method Details

#filter(servers) ⇒ Object



11
12
13
# File 'lib/capistrano/configuration/role_filter.rb', line 11

def filter(servers)
  Array(servers).select { |s| s.is_a?(String) ? false : s.roles.any? { |r| @rex.match r } }
end