Class: Stitch::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/stitch/compiler.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.allObject



12
13
14
# File 'lib/stitch/compiler.rb', line 12

def all
  Compiler.compilers.select {|c| c.enabled? }
end

.all_extensionsObject



16
17
18
# File 'lib/stitch/compiler.rb', line 16

def all_extensions
  Compiler.all.map {|c| c.extensions }.flatten
end

.compile(*args) ⇒ Object



50
51
52
# File 'lib/stitch/compiler.rb', line 50

def compile(*args)
  self.new.compile(*args)
end

.compilersObject



4
5
6
# File 'lib/stitch/compiler.rb', line 4

def compilers
  @compilers ||= []
end

.enabled(value) ⇒ Object



34
35
36
# File 'lib/stitch/compiler.rb', line 34

def enabled(value)
  @enabled = value
end

.enabled?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/stitch/compiler.rb', line 38

def enabled?
  @enabled != false
end

.extensions(*exts) ⇒ Object

Child methods



29
30
31
32
# File 'lib/stitch/compiler.rb', line 29

def extensions(*exts)
  @extensions ||= []
  @extensions |= exts.map(&:to_s)
end

.for_extension(extension) ⇒ Object



20
21
22
23
24
25
# File 'lib/stitch/compiler.rb', line 20

def for_extension(extension)
  extension.gsub!(/^\./, "")
  all.find do |item|
    item.extensions.include?(extension)
  end
end

.inherited(child) ⇒ Object



8
9
10
# File 'lib/stitch/compiler.rb', line 8

def inherited(child)
  Compiler.compilers.unshift(child)
end

.source(value) ⇒ Object



42
43
44
# File 'lib/stitch/compiler.rb', line 42

def source(value)
  @source = value
end

.source?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/stitch/compiler.rb', line 46

def source?
  @source || false
end

Instance Method Details

#compile(filename) ⇒ Object



55
56
57
# File 'lib/stitch/compiler.rb', line 55

def compile(filename)
  raise "Re-implement"
end