Class: Logi::Loader
- Inherits:
-
Object
show all
- Defined in:
- lib/logi/loader.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(config) ⇒ Loader
Returns a new instance of Loader.
8
9
10
|
# File 'lib/logi/loader.rb', line 8
def initialize config
@config = config
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(cmd, *args, &block) ⇒ Object
38
39
40
41
|
# File 'lib/logi/loader.rb', line 38
def method_missing cmd, *args, &block
path, options = args[0], args[1]
config.posts[path] = Logi::Post.new(cmd, path, options, block)
end
|
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
7
8
9
|
# File 'lib/logi/loader.rb', line 7
def config
@config
end
|
Instance Method Details
#layout(path) ⇒ Object
34
35
36
|
# File 'lib/logi/loader.rb', line 34
def layout path
config.default_layout = path
end
|
#layout_path(path) ⇒ Object
26
27
28
|
# File 'lib/logi/loader.rb', line 26
def layout_path path
config.layout_path = path
end
|
#load ⇒ Object
12
13
14
15
16
17
18
19
20
|
# File 'lib/logi/loader.rb', line 12
def load
instance_eval(File.read(config.path))
prefix = "#{config.root}/#{config.post_path}"
Dir["#{prefix}/**/*.*"].each do |fullpath|
path = fullpath.sub("#{prefix}/", '')
config.posts[path] ||=
Logi::Post.new(Logi::Default.default_command, path, {}, nil)
end
end
|
#output_path(path) ⇒ Object
30
31
32
|
# File 'lib/logi/loader.rb', line 30
def output_path path
config.output_path = path
end
|
#post_path(path) ⇒ Object
22
23
24
|
# File 'lib/logi/loader.rb', line 22
def post_path path
config.post_path = path
end
|