Class: Logi::Config

Inherits:
Struct
  • Object
show all
Defined in:
lib/logi/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Config

Returns a new instance of Config.



10
11
12
13
# File 'lib/logi/config.rb', line 10

def initialize options={}
  @options = options
  Logi::Loader.new(self).load if File.exist?(path)
end

Instance Attribute Details

#default_layoutObject

Returns the value of attribute default_layout

Returns:

  • (Object)

    the current value of default_layout



6
7
8
# File 'lib/logi/config.rb', line 6

def default_layout
  @default_layout
end

#layout_pathObject

Returns the value of attribute layout_path

Returns:

  • (Object)

    the current value of layout_path



6
7
8
# File 'lib/logi/config.rb', line 6

def layout_path
  @layout_path
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/logi/config.rb', line 8

def options
  @options
end

#output_pathObject

Returns the value of attribute output_path

Returns:

  • (Object)

    the current value of output_path



6
7
8
# File 'lib/logi/config.rb', line 6

def output_path
  @output_path
end

#post_pathObject

Returns the value of attribute post_path

Returns:

  • (Object)

    the current value of post_path



6
7
8
# File 'lib/logi/config.rb', line 6

def post_path
  @post_path
end

Instance Method Details

#layout_path_for(post) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/logi/config.rb', line 31

def layout_path_for post
  if layout = post.options[:layout] || default_layout
    "#{root}/#{layout_path}/#{layout}"
  else
    Logi::Default.default_layout
  end
end

#output_path_for(post) ⇒ Object



39
40
41
# File 'lib/logi/config.rb', line 39

def output_path_for post
  "#{root}/#{output_path}/#{post.path.sub(/\..+$/, '')}.html"
end

#pathObject



23
24
25
# File 'lib/logi/config.rb', line 23

def path
  "#{root}/config/logi.rb"
end

#post_path_for(post) ⇒ Object



27
28
29
# File 'lib/logi/config.rb', line 27

def post_path_for post
  "#{root}/#{post_path}/#{post.path}"
end

#postsObject



15
16
17
# File 'lib/logi/config.rb', line 15

def posts
  @posts ||= {}
end

#rootObject



19
20
21
# File 'lib/logi/config.rb', line 19

def root
  File.expand_path(options[:root] || Logi::Default.default_root_path)
end