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

Version Path
capistrano-3.19.2 lib/capistrano/configuration/role_filter.rb
capistrano-3.19.1 lib/capistrano/configuration/role_filter.rb
capistrano-3.19.0 lib/capistrano/configuration/role_filter.rb
capistrano-3.18.1 lib/capistrano/configuration/role_filter.rb
honeybadger-5.4.0 vendor/bundle/ruby/3.2.0/gems/capistrano-3.18.0/lib/capistrano/configuration/role_filter.rb
honeybadger-5.3.0 vendor/bundle/ruby/3.2.0/gems/capistrano-3.18.0/lib/capistrano/configuration/role_filter.rb
capistrano-3.18.0 lib/capistrano/configuration/role_filter.rb
capistrano-3.17.3 lib/capistrano/configuration/role_filter.rb
capistrano-3.17.2 lib/capistrano/configuration/role_filter.rb
capistrano-3.17.1 lib/capistrano/configuration/role_filter.rb
capistrano-3.17.0 lib/capistrano/configuration/role_filter.rb
capistrano-3.16.0 lib/capistrano/configuration/role_filter.rb
capistrano-3.15.0 lib/capistrano/configuration/role_filter.rb
capistrano-3.14.1 lib/capistrano/configuration/role_filter.rb
capistrano-3.14.0 lib/capistrano/configuration/role_filter.rb
capistrano-3.13.0 lib/capistrano/configuration/role_filter.rb
capistrano-3.12.1 lib/capistrano/configuration/role_filter.rb
capistrano-3.12.0 lib/capistrano/configuration/role_filter.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/capistrano-3.11.0/lib/capistrano/configuration/role_filter.rb
capistrano-3.11.2 lib/capistrano/configuration/role_filter.rb