Class: Toto::Config

Inherits:
Hash show all
Defined in:
lib/toto-haml.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
}

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ Config

Github username and list of repos



290
291
292
293
# File 'lib/toto-haml.rb', line 290

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

Instance Method Details

#[](key, *args) ⇒ Object



303
304
305
306
# File 'lib/toto-haml.rb', line 303

def [] key, *args
  val = super(key)
  val.respond_to?(:call) ? val.call(*args) : val
end

#set(key, val) ⇒ Object



295
296
297
298
299
300
301
# File 'lib/toto-haml.rb', line 295

def set key, val
  if val.is_a? Hash
    self[key].update val
  else
    self[key] = val
  end
end