Sha256: bf8869355f8fa6510e183851d5da4212027d2a3f00f60bf0541c9eabd632fea8

Contents?: true

Size: 841 Bytes

Versions: 20

Compression:

Stored size: 841 Bytes

Contents

class Stasis
  class Ignore < Plugin

    before_render :before_render
    controller_method :ignore

    def initialize(stasis)
      @stasis = stasis
      @ignore = {}
    end

    # This event triggers before each file renders. Rejects any `paths` that are included
    # in the `@ignore` `Array`.
    def before_render
      matches = _match_key?(@ignore, @stasis.path)
      matches.each do |group|
        group.each do |path|
          @stasis.path = nil if _within?(path)
        end
      end
    end

    # This method is bound to all controllers. Adds an `Array` of paths to the `@ignore`
    # `Array`.
    def ignore(*array)
      array.each do |path|
        path = @stasis.controller._resolve(path)
        if path
          @ignore[path] ||= []
          @ignore[path] << @stasis.path
        end
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
stasis-0.1.19 lib/stasis/plugins/ignore.rb
stasis-0.1.18 lib/stasis/plugins/ignore.rb
stasis-0.1.17 lib/stasis/plugins/ignore.rb
stasis-0.1.16 lib/stasis/plugins/ignore.rb
stasis-0.1.15 lib/stasis/plugins/ignore.rb
stasis-0.1.14 lib/stasis/plugins/ignore.rb
stasis-0.1.13 lib/stasis/plugins/ignore.rb
stasis-0.1.12 lib/stasis/plugins/ignore.rb
stasis-0.1.11 lib/stasis/plugins/ignore.rb
stasis-0.1.10 lib/stasis/plugins/ignore.rb
stasis-0.1.9 lib/stasis/plugins/ignore.rb
stasis-0.1.8 lib/stasis/plugins/ignore.rb
stasis-0.1.7 lib/stasis/plugins/ignore.rb
stasis-0.1.6 lib/stasis/plugins/ignore.rb
stasis-0.1.5 lib/stasis/plugins/ignore.rb
stasis-0.1.4 lib/stasis/plugins/ignore.rb
stasis-0.1.3 lib/stasis/plugins/ignore.rb
stasis-0.1.2 lib/stasis/plugins/ignore.rb
stasis-0.1.1 lib/stasis/plugins/ignore.rb
stasis-0.1.0 lib/stasis/plugins/ignore.rb