summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2011-06-16 15:11:50 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2011-06-16 15:11:50 +0200
commit8135a99aa065b2616e69647b7fa3149609f0978a (patch)
tree9dda1d6af056a5c6ee96f26f248846dc4c427612 /lib
parentd23181c138e8f0258641308ffd34370d3b132e8e (diff)
downloadzorglub-8135a99aa065b2616e69647b7fa3149609f0978a.zip
zorglub-8135a99aa065b2616e69647b7fa3149609f0978a.tar.gz
add class Zorglub::Config
Diffstat (limited to 'lib')
-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
+#