From a4074fa6af5e0ba5889bda6bb33128e195e61361 Mon Sep 17 00:00:00 2001 From: Magnus Holm Date: Wed, 27 Aug 2008 21:38:35 +0200 Subject: [PATCH] Camping::Apps returns! --- lib/camping-unabridged.rb | 10 +++++++++- lib/camping.rb | 7 ++++--- lib/camping/ar.rb | 4 ++-- lib/camping/mab.rb | 4 ++-- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/lib/camping-unabridged.rb b/lib/camping-unabridged.rb index 064a1c1..a851110 100644 --- a/lib/camping-unabridged.rb +++ b/lib/camping-unabridged.rb @@ -90,6 +90,13 @@ module Camping C = self S = IO.read(__FILE__) rescue nil P = "

Cam\ping Problem!

%s

" + Apps = [].instance_eval do + def <<(i) + delete_if { |f| f.to_s == i.to_s} + super + end + self + end # An object-like Hash. # All Camping query string and cookie variables are loaded as this. # @@ -550,7 +557,8 @@ class << self # module Blog::Views; ... end # def goes(m) - eval S.gsub(/Camping/,m.to_s), TOPLEVEL_BINDING + eval S.gsub(/Camping/,m=m.to_s), t=TOPLEVEL_BINDING + Apps << eval(m,t) end # Ruby web servers use this method to enter the Camping realm. The e diff --git a/lib/camping.rb b/lib/camping.rb index a2a9d79..fbb533e 100644 --- a/lib/camping.rb +++ b/lib/camping.rb @@ -1,6 +1,7 @@ %w[uri stringio rack].map{|l|require l};class Object;def meta_def m,&b (class<StringIO.new,'REQUEST_METHOD'=>m.to_s}) diff --git a/lib/camping/ar.rb b/lib/camping/ar.rb index 65badb9..47eea89 100644 --- a/lib/camping/ar.rb +++ b/lib/camping/ar.rb @@ -73,6 +73,6 @@ def Base.table_name_prefix end Camping::S.sub! /autoload\s*:Base\s*,\s*['"]camping\/ar['"]/, "" Camping::S.sub! /def\s*Y[;\s]*self[;\s]*end/, $AR_EXTRAS -Object.constants.map{|c|Object.const_get(c)}.each do |c| - c::Models.module_eval $AR_EXTRAS if c.respond_to?(:goes) +Camping::Apps.each do |c| + c::Models.module_eval $AR_EXTRAS end diff --git a/lib/camping/mab.rb b/lib/camping/mab.rb index 1c70a8e..04dbf9b 100644 --- a/lib/camping/mab.rb +++ b/lib/camping/mab.rb @@ -21,6 +21,6 @@ def tag!(*g,&b) } Camping::S.sub! /autoload\s*:Mab\s*,\s*['"]camping\/mab['"]/, $MAB_CODE -Object.constants.map{|c|Object.const_get(c)}.each do |c| - c.module_eval $MAB_CODE if c.respond_to?(:goes) +Camping::Apps.each do |c| + c.module_eval $MAB_CODE end