summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/zorglub.rb5
-rw-r--r--lib/zorglub/config.rb63
2 files changed, 66 insertions, 2 deletions
diff --git a/lib/zorglub.rb b/lib/zorglub.rb
index f93b4c1..60917c6 100644
--- a/lib/zorglub.rb
+++ b/lib/zorglub.rb
@@ -5,8 +5,9 @@ module Zorglub
#
VERSION = '0.0.1'
#
- autoload :App, './lib/zorglub/app.rb'
- autoload :Node, './lib/zorglub/node.rb'
+ autoload :App, './lib/zorglub/app.rb'
+ autoload :Config, './lib/zorglub/config.rb'
+ autoload :Node, './lib/zorglub/node.rb'
#
end
#
diff --git a/lib/zorglub/config.rb b/lib/zorglub/config.rb
new file mode 100644
index 0000000..8b5ae37
--- /dev/null
+++ b/lib/zorglub/config.rb
@@ -0,0 +1,63 @@
+#! /usr/bin/ruby
+#
+module Zorglub
+ #
+ class Config
+ @options = {
+ :root => '.',
+ :engine => 'haml',
+ :view_dir => 'view',
+ :layout_dir => 'layout',
+ :default_layout => 'default'
+ }
+ @engines = {
+ 'haml' => 'haml'
+ }
+ class << self
+ #
+ def [] k
+ options[k]
+ end
+ #
+ def []= k, v
+ option[k]=v
+ end
+ #
+ def view_base_path
+ if @options.has_key? :view_path
+ @options[:view_path]
+ else
+ File.join @options[:root], @options[:view_dir]
+ end
+ end
+ #
+ def layout_base_path
+ if @options.has_key? :layout_path
+ @options[:layout_path]
+ else
+ File.join @options[:root], @options[:layout_dir]
+ end
+ end
+ #
+ def register_engine name, ext
+ return unless name and ext
+ @engines[name]=ext
+ end
+ #
+ def engine_ext engine
+ @engines[engine]
+ end
+ end
+ #
+ def self.method_missing m, *args, &block
+ if m=~/(.*)=$/
+ @options[$1.to_sym]=args[0]
+ else
+ @options[m.to_sym]
+ end
+ end
+ #
+ end
+ #
+end
+#