class Capistrano::Configuration::HostFilter
Public Class Methods
new(values)
click to toggle source
# File lib/capistrano/configuration/host_filter.rb, line 4 def initialize(values) av = Array(values).dup av = av.flat_map { |v| v.is_a?(String) && v =~ /^(?<name>[-A-Za-z0-9.]+)(,\g<name>)*$/ ? v.split(",") : v } @rex = regex_matcher(av) end
Public Instance Methods
filter(servers)
click to toggle source
# File lib/capistrano/configuration/host_filter.rb, line 10 def filter(servers) Array(servers).select { |s| @rex.match s.to_s } end
Private Instance Methods
regex_matcher(values)
click to toggle source
# File lib/capistrano/configuration/host_filter.rb, line 16 def regex_matcher(values) values.map! do |v| case v when Regexp then v else vs = v.to_s vs =~ /^[-A-Za-z0-9.]+$/ ? /^#{Regexp.quote(vs)}$/ : Regexp.new(vs) end end Regexp.union values end