Class: Codesake::Kernel

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/codesake/kernel.rb

Constant Summary collapse

NONE =
0
TEXT =
1
JSP =
2
UNKNOWN =
-1

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#engineObject (readonly)

Returns the value of attribute engine.



7
8
9
# File 'lib/codesake/kernel.rb', line 7

def engine
  @engine
end

Instance Method Details

#choose_engine(filename, options) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/codesake/kernel.rb', line 14

def choose_engine(filename, options)


  engine = nil

  case detect(filename)
  when TEXT
    engine = Codesake::Engine::Text.new(filename)
  when NONE
    engine = Codesake::Engine::Generic.new(filename)
  when JSP
    engine = Codesake::Engine::Jsp.new(filename, options)
  end
  engine
end

#detect(filename) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/codesake/kernel.rb', line 30

def detect(filename)
  return NONE if filename.nil? or filename.empty?
  return TEXT if Codesake::Engine::Text.is_txt?(filename)
  return JSP if (File.extname(filename) == ".jsp")


  return UNKNOWN
end