lib/caboodle/kit.rb in caboodle-0.2.12 vs lib/caboodle/kit.rb in caboodle-0.2.13
- old
+ new
@@ -5,11 +5,11 @@
set :app_file, __FILE__
set :logging, true
set :root, File.expand_path(File.join(File.dirname(__FILE__),"app"))
set :public, Proc.new { File.join(root, "public") }
set :haml, {:format => :html5 }
-
+
helpers Sinatra::CaboodleHelpers
template :layout do
@@template ||= File.open(File.join(File.dirname(__FILE__),"app","views","layout.haml")).read
end
@@ -17,11 +17,14 @@
before do
Caboodle::Site.cache_for ||= 600
response.headers['Cache-Control'] = "public, max-age=#{Caboodle::Site.cache_for}"
end
+ Config = Hashie::Mash.new
+
class << self
+
attr_accessor :credit_link
def configure_site config_path
set :config, config_path
if File.exists?(config_path)
@@ -51,19 +54,41 @@
Hashie::Mash.new(loaded).each{ |k,v|
v.strip! if v.class == String
Caboodle::Site[k.to_s] = v } rescue puts "Warning! Skipping #{p}"
Caboodle::Site.kits.uniq!
end
+
+ def load_custom_config p
+ loaded = YAML.load_file(p)
+ Hashie::Mash.new(loaded).each{ |k,v|
+ v.strip! if v.class == String
+ Config[k.to_s] = v
+ }
+ end
def dump_config
begin
p = config
d = Caboodle::Site.clone
e = d.to_hash
e.delete("required_settings")
File.open(p, 'w') {|f| f.write(YAML::dump(e))}
rescue
puts "Cannot write to config file: #{p}"
+ end
+ end
+
+ def config_files array_of_files
+ configure do
+ array_of_files.each do |file|
+ config_path = File.expand_path(File.join(Caboodle::App.root,"config",file))
+ if File.exists?(config_path)
+ load_custom_config(config_path)
+ else
+ `cp "#{File.join(root,"config",file)}" "#{File.join(Caboodle::App.root,"config",".")}"` rescue "Could not create the config yml file"
+ puts "\nThis kit has a separate configuration file which you must edit:\n #{File.expand_path(File.join(Caboodle::App.root,"config",file))}\n"
+ end
+ end
end
end
def setup
require_all
\ No newline at end of file