Sha256: 15be0f819eafb17e723f82890d0f89482662501c6548207d2ecbc34105202941

Contents?: true

Size: 1.01 KB

Versions: 17

Compression:

Stored size: 1.01 KB

Contents

# encoding: utf-8
module Middleman
  module Presentation
    # The ignore file uses to ignore slides
    #
    # @see [Transformers::IgnoreSlides]
    class IgnoreFile
      private

      attr_reader :unignore, :ignore, :path

      protected

      attr_writer :unignore, :ignore

      public

      def initialize(path)
        @unignore = @ignore = /^!$/
        @path = path

        parse_file(path) if File.exist? path
      end

      def ignore?(slide)
        return false unless File.exist? path

        slide.match?(ignore) && !slide.match?(unignore)
      end

      private

      def parse_file(path)
        File.readlines(path).each do |l|
          next if l =~ /^#/
          l = l.chomp.sub(/\s*#.*/, '')

          if l =~ /^!/
            self.unignore = Regexp.union(
              unignore,
              Regexp.new(
                l.sub(/^!/, '')
              )
            )
          else
            self.ignore = Regexp.union(ignore, Regexp.new(l))
          end
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
middleman-presentation-core-0.17.7 lib/middleman-presentation-core/ignore_file.rb
middleman-presentation-core-0.17.6 lib/middleman-presentation-core/ignore_file.rb
middleman-presentation-core-0.17.5 lib/middleman-presentation-core/ignore_file.rb
middleman-presentation-core-0.17.2 lib/middleman-presentation-core/ignore_file.rb
middleman-presentation-core-0.17.1 lib/middleman-presentation-core/ignore_file.rb
middleman-presentation-core-0.17.0 lib/middleman-presentation-core/ignore_file.rb
middleman-presentation-core-0.16.3 lib/middleman-presentation-core/ignore_file.rb
middleman-presentation-core-0.16.2 lib/middleman-presentation-core/ignore_file.rb
middleman-presentation-core-0.16.0 lib/middleman-presentation-core/ignore_file.rb
middleman-presentation-core-0.16.0.rc2 lib/middleman-presentation-core/ignore_file.rb
middleman-presentation-core-0.16.0.rc1 lib/middleman-presentation-core/ignore_file.rb
middleman-presentation-core-0.16.0.beta lib/middleman-presentation-core/ignore_file.rb
middleman-presentation-core-0.16.0.alpha lib/middleman-presentation-core/ignore_file.rb
middleman-presentation-0.15.8 lib/middleman-presentation/ignore_file.rb
middleman-presentation-0.15.7 lib/middleman-presentation/ignore_file.rb
middleman-presentation-0.15.6 lib/middleman-presentation/ignore_file.rb
middleman-presentation-0.15.5 lib/middleman-presentation/ignore_file.rb