Sha256: 64b6cabbdffc3b1d61a177bd5555c4d1a0e1c84db13d075449bf3e6ff40e76b5

Contents?: true

Size: 1.28 KB

Versions: 5

Compression:

Stored size: 1.28 KB

Contents

Dir[ File.join( File.dirname(__FILE__), '*.rb' ) ].each do |f|
  begin
    require f
  rescue LoadError => e
    puts "WARNING: Missing required dependency to activate optional built-in extension #{File.basename(f)}\n  #{e}"
  rescue StandardError => e
    puts "WARNING: Missing runtime configuration to activate optional built-in extension #{File.basename(f)}\n  #{e}"
  end
end

module Awestruct
  module Extensions
    class Pipeline

      attr_reader :before_extensions
      attr_reader :extensions
      attr_reader :after_extensions
      attr_reader :helpers
      attr_reader :transformers

      def initialize(&block)
        @extensions = []
        @helpers    = []
        @transformers  = []
        instance_eval &block if block
      end

      def extension(ext)
        @extensions << ext
        ext.transform(@transformers) if ext.respond_to?('transform')
      end

      def helper(helper)
        @helpers << helper
      end

      def transformer(transformer)
        @transformers << transformer
      end

      def execute(site)
        extensions.each do |ext|
          ext.execute( site )
        end
      end

      def watch(watched_dirs)
        extensions.each do |ext|
          ext.watch( watched_dirs ) if ext.respond_to?('watch')
        end
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
awestruct-0.5.3 lib/awestruct/extensions/pipeline.rb
awestruct-0.5.2.1 lib/awestruct/extensions/pipeline.rb
awestruct-0.5.2 lib/awestruct/extensions/pipeline.rb
awestruct-0.5.1 lib/awestruct/extensions/pipeline.rb
awestruct-0.5.1a lib/awestruct/extensions/pipeline.rb