Sha256: 15b388faad764edbb17daba53bef25b6864d766b7bae1438f3dc73446504a0ba

Contents?: true

Size: 489 Bytes

Versions: 2

Compression:

Stored size: 489 Bytes

Contents

module ShopifyTheme
  module Filters
    class Whitelist
      DEFAULT_WHITELIST = %w(layout/ assets/ config/ snippets/ templates/ locales/)

      attr_reader :patterns

      def initialize(pattern_strings=[])
        @patterns = (pattern_strings.empty? ? DEFAULT_WHITELIST : pattern_strings).map { |pattern| Regexp.new(pattern) }
      end

      def select(list)
        list.select do |entry|
          patterns.any? { |pat| pat.match(entry) }
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
shopify_theme-0.0.25 lib/shopify_theme/filters/whitelist.rb
shopify_theme-0.0.24 lib/shopify_theme/filters/whitelist.rb