Sha256: f57b57200b48d0aa025ea6188d9386c23026e3fa14e11fc2b94a15c2e0c07b4d

Contents?: true

Size: 933 Bytes

Versions: 5

Compression:

Stored size: 933 Bytes

Contents

module Stitch
  class Compiler
    class << self
      def compilers
        @compilers ||= []
      end
      
      def inherited(child)
        Compiler.compilers.unshift(child)
      end
      
      def for_extension(extension)
        extension.gsub!(/^\./, "")
        Compiler.compilers.select(&:enabled?).find do |item| 
          item.extensions.include?(extension) 
        end
      end
      
      # Child methods
      
      def extensions(*exts)
        @extensions ||= []
        @extensions |= exts.map(&:to_s)
      end
      
      def enabled(value)
        @enabled = value
      end
      
      def enabled?
        @enabled != false
      end
      
      def compile(*args)
        self.new.compile(*args)
      end
    end
    
    def compile(filename)
      raise "Re-implement"
    end
  end
end

# Require default compilers
require "stitch/compilers/javascript"
require "stitch/compilers/coffeescript"

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
stitch-rb-0.0.5 lib/stitch/compiler.rb
stitch-rb-0.0.4 lib/stitch/compiler.rb
stitch-rb-0.0.3 lib/stitch/compiler.rb
stitch-rb-0.0.2 lib/stitch/compiler.rb
stitch-rb-0.0.1 lib/stitch/compiler.rb