lib/caboodle/kit.rb in caboodle-0.2.5 vs lib/caboodle/kit.rb in caboodle-0.2.6
- old
+ new
@@ -72,26 +72,22 @@
def load_kit name
unless name.blank?
kit_name = name.to_s.split("::").last || name
kit_name = kit_name.downcase
- puts "))) Loading Kit: #{kit_name}"
orig = Caboodle.constants
begin
require "caboodle/kits/#{kit_name}/#{kit_name}" #rescue puts "Problem loading Kit: #{kit_name}"
added = Caboodle.constants - orig
- puts added
added.each do |d|
c = Caboodle.const_get(d)
if c.respond_to?(:is_a_caboodle_kit)
- puts "*** Register #{c}"
c.register_kit
end
end
rescue Exception=>e
if ENV["RACK_ENV"] == "production"
- puts e.inspect
Caboodle::Errors << Hashie::Mash.new({:title=>"Failed to load #{name} kit", :reason=>e.backtrace})
else
raise e
end
end
@@ -150,11 +146,11 @@
def require_all
if(Caboodle::Site.kits)
Caboodle::Site.kits.each { |k| load_kit k }
else
- STDERR.puts "Kits not registered"
+ STDERR.puts "No kits to register"
end
Caboodle::Kits
end
def use_all
@@ -163,15 +159,17 @@
def menu display, path, &block
path = "/" if Site.home_kit == self.to_s.gsub("Caboodle::","")
Caboodle::MenuItems << {:display=>display, :link=>path, :kit=>self}
self.get path, &block
- if Site.home_kit.blank?
- Site.home_kit = name
- end
+ @@has_menu = true
end
-
+
+ def has_menu?
+ defined?(@@has_menu)
+ end
+
def required keys
if keys.class == Array
keys.each do |k|
self.required_settings << k
end
@@ -249,9 +247,13 @@
def required_settings
r = RequiredSettings[self.ancestors.first.to_s.split("::").last] ||= []
RequiredSettings[self.ancestors.first.to_s.split("::").last]
end
+ def available_kits
+ Dir.new(File.join(File.dirname(__FILE__),"kits")).entries.delete_if{|a| a[0,1]=="."}
+ end
+
def start
errors = []
puts self.required_settings.inspect
self.required_settings.each do |s|
if Site[s].blank?
\ No newline at end of file