Class: Serve::FileTypeHandler
- Inherits:
-
Object
- Object
- Serve::FileTypeHandler
show all
- Defined in:
- lib/serve/handlers/file_type_handler.rb
Overview
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(root_path, template_path, extension) ⇒ FileTypeHandler
Returns a new instance of FileTypeHandler.
35
36
37
38
39
|
# File 'lib/serve/handlers/file_type_handler.rb', line 35
def initialize(root_path, template_path, extension)
@root_path = root_path
@template_path = template_path
@extension = extension
end
|
Instance Attribute Details
#extension ⇒ Object
Returns the value of attribute extension.
34
35
36
|
# File 'lib/serve/handlers/file_type_handler.rb', line 34
def extension
@extension
end
|
Class Method Details
22
23
24
|
# File 'lib/serve/handlers/file_type_handler.rb', line 22
def self.configure(extension, options)
extension_options[extension.to_sym].merge!(options)
end
|
.extension(*extensions) ⇒ Object
7
8
9
10
11
|
# File 'lib/serve/handlers/file_type_handler.rb', line 7
def self.extension(*extensions)
extensions.each do |ext|
FileTypeHandler.handlers[ext] = self
end
end
|
.extension_options ⇒ Object
26
27
28
|
# File 'lib/serve/handlers/file_type_handler.rb', line 26
def self.extension_options
@extension_options ||= Hash.new{|h,k| h[k] = {}}
end
|
.extensions ⇒ Object
13
14
15
|
# File 'lib/serve/handlers/file_type_handler.rb', line 13
def self.extensions
handlers.keys
end
|
.handlers ⇒ Object
3
4
5
|
# File 'lib/serve/handlers/file_type_handler.rb', line 3
def self.handlers
@handlers ||= {}
end
|
.handlers_for(path) ⇒ Object
17
18
19
20
|
# File 'lib/serve/handlers/file_type_handler.rb', line 17
def self.handlers_for(path)
extensions = File.basename(path).split(".")[1..-1]
extensions.collect{|e| [handlers[e], e] if handlers[e]}.compact
end
|
.options_for(extension) ⇒ Object
30
31
32
|
# File 'lib/serve/handlers/file_type_handler.rb', line 30
def self.options_for(extension)
extension_options[extension.to_sym]
end
|
Instance Method Details
#content_type ⇒ Object
45
46
47
|
# File 'lib/serve/handlers/file_type_handler.rb', line 45
def content_type
'text/html'
end
|
#layout? ⇒ Boolean
49
50
51
|
# File 'lib/serve/handlers/file_type_handler.rb', line 49
def layout?
true
end
|
#parse(input, context) ⇒ Object
53
54
55
|
# File 'lib/serve/handlers/file_type_handler.rb', line 53
def parse(input, context)
input.dup
end
|
#process(input, context) ⇒ Object
41
42
43
|
# File 'lib/serve/handlers/file_type_handler.rb', line 41
def process(input, context)
parse(input, context)
end
|