Class: Logi::Config

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Config

Returns a new instance of Config.



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

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



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

def default_layout
  @default_layout
end

#layout_pathObject

Returns the value of attribute layout_path

Returns:

  • (Object)

    the current value of layout_path



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

def layout_path
  @layout_path
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

#output_pathObject

Returns the value of attribute output_path

Returns:

  • (Object)

    the current value of output_path



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

def output_path
  @output_path
end

#post_pathObject

Returns the value of attribute post_path

Returns:

  • (Object)

    the current value of post_path



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

def post_path
  @post_path
end

Class Method Details

.default_commandObject



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

def self.default_command    ; 'post'  ; end

.default_layoutObject



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

def self.default_layout
  File.expand_path("#{__dir__}/layout/default.html.erb")
end

.default_layout_pathObject



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

def self.default_layout_path; 'layout'; end

.default_output_pathObject



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

def self.default_output_path; 'public'; end

.default_post_pathObject



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

def self.default_post_path  ; 'post'  ; end

.default_root_pathObject



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

def self.default_root_path  ; '.'     ; end

Instance Method Details

#layout_path_for(post) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/logi/config.rb', line 39

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

#output_path_for(post) ⇒ Object



47
48
49
# File 'lib/logi/config.rb', line 47

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

#pathObject



31
32
33
# File 'lib/logi/config.rb', line 31

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

#post_path_for(post) ⇒ Object



35
36
37
# File 'lib/logi/config.rb', line 35

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

#postsObject



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

def posts
  @posts ||= {}
end

#rootObject



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

def root
  options[:root] || self.class.default_root_path
end