Class: TotoBongo::Config

Inherits:
Hash
  • Object
show all
Defined in:
lib/toto-bongo.rb

Constant Summary collapse

Defaults =

This is the hash that stores all teh configuation options

{
  :author => ENV['USER'],                               # blog author
  :title => Dir.pwd.split('/').last,                    # blog index title
  :description => "Blog for your existing rails app",   # blog meta description
  :markdown => :smart,                                  # use markdown
  :keywords => "blog rails existing",                   # blog meta keywords
  :root => "index",                                     # site index
  :url => "http://127.0.0.1",                           # root URL of the site
  :prefix => "blog",                                        # common path prefix for the blog
  :date => lambda {|now| now.strftime("%d/%m/%Y") },    # date function
  :disqus => false,                                     # disqus name
  :summary => {:max => 150, :delim => /~\n/},           # length of summary and delimiter
  :ext => "txt",                                        # extension for articles
  :cache => 28800,                                      # cache duration (seconds)
  :to_html => lambda {|path, page, ctx|                 # returns an html, from a path & context
    Haml::Engine.new(File.read("#{path}/#{page}.html.haml")).render(ctx)
  },
  :error => lambda {|code|                              # The HTML for your error page
    "<font style='font-size:300%'>toto-bongo error (#{code})</font>"
  }
}

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ Config

Returns a new instance of Config.



480
481
482
483
484
# File 'lib/toto-bongo.rb', line 480

def initialize obj

  self.update Defaults
  self.update obj
end

Instance Method Details

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



486
487
488
489
490
491
492
# File 'lib/toto-bongo.rb', line 486

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