Sha256: e31c3a75c430e8518cbd6f5efd2131dbb0020f49854f7c3bd1b2d756352a1526
Contents?: true
Size: 683 Bytes
Versions: 25
Compression:
Stored size: 683 Bytes
Contents
module Capistrano class Configuration class RoleFilter def initialize(values) av = Array(values).dup av = av.flat_map { |v| v.is_a?(String) ? v.split(",") : v } @rex = regex_matcher(av) end def filter(servers) Array(servers).select { |s| s.is_a?(String) ? false : s.roles.any? { |r| @rex.match r } } end private def regex_matcher(values) values.map! do |v| case v when Regexp then v else vs = v.to_s vs =~ %r{^/(.+)/$} ? Regexp.new($1) : /^#{Regexp.quote(vs)}$/ end end Regexp.union values end end end end
Version data entries
25 entries across 25 versions & 2 rubygems