Class: Toto::Config

Inherits:
Hash show all
Defined in:
lib/toto.rb

Constant Summary collapse

Defaults =
{
  :author => ENV['USER'],                               # blog author
  :title => Dir.pwd.split('/').last,                    # site title
  :root => "index",                                     # site index
  :url => "http://127.0.0.1",
  :date => lambda {|now| now.strftime("%d/%m/%Y") },    # date function
  :markdown => :smart,                                  # use markdown
  :disqus => false,                                     # disqus name
  :summary => {:max => 150, :delim => /~\n/},           # length of summary and delimiter
  :ext => 'txt',                                        # extension for articles
  :cache => 28800,                                      # cache duration (seconds)
  :github => {:user => "", :repos => [], :ext => 'md'}, # Github username and list of repos
  :to_html => lambda {|path, page, ctx|                 # returns an html, from a path & context
    ERB.new(File.read("#{path}/#{page}.rhtml")).result(ctx)
  }
}

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ Config

Returns a new instance of Config.



309
310
311
312
# File 'lib/toto.rb', line 309

def initialize obj
  self.update Defaults
  self.update obj
end

Instance Method Details

#set(key, val = nil, &blk) ⇒ Object



314
315
316
317
318
319
320
# File 'lib/toto.rb', line 314

def set key, val = nil, &blk
  if val.is_a? Hash
    self[key].update val
  else
    self[key] = block_given?? blk : val
  end
end