lib/caboodle/kit.rb in caboodle-0.2.3 vs lib/caboodle/kit.rb in caboodle-0.2.5

- old
+ new

@@ -74,19 +74,28 @@ unless name.blank? kit_name = name.to_s.split("::").last || name kit_name = kit_name.downcase puts "))) Loading Kit: #{kit_name}" orig = Caboodle.constants - 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 + 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 end Caboodle::Kits end @@ -115,14 +124,17 @@ def register_kit required_settings.each do |r| puts "checking #{r}" puts "value: #{Caboodle::Site[r]}" if Caboodle::Site[r].blank? - puts "Please set a value for #{r}:" - v = STDIN.gets - Caboodle::Site[r] = v - Caboodle::Kit.dump_config + puts "Rack env #{ENV["RACK_ENV"]}" + unless ENV["RACK_ENV"] == "production" + puts "Please set a value for #{r}:" + v = STDIN.gets + Caboodle::Site[r] = v + Caboodle::Kit.dump_config + end end end Site.kits << name Site.kits.uniq! Caboodle::Kits << self @@ -233,15 +245,16 @@ \"<a rel='me' href='#{url}' rel='me'>#{self.name.split("::").last}</a>\" end" end def required_settings - r = RequiredSettings[self.ancestors.first.to_s.split("::").last] ||= [:title, :description, :logo_url, :author] + r = RequiredSettings[self.ancestors.first.to_s.split("::").last] ||= [] RequiredSettings[self.ancestors.first.to_s.split("::").last] end def start errors = [] + puts self.required_settings.inspect self.required_settings.each do |s| if Site[s].blank? errors << " :#{s} has not been set" end end \ No newline at end of file