Skip to content

Commit

Permalink
Camping::Apps returns!
Browse files Browse the repository at this point in the history
  • Loading branch information
judofyr committed Oct 27, 2008
1 parent 214fbe6 commit a4074fa
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
10 changes: 9 additions & 1 deletion lib/camping-unabridged.rb
Expand Up @@ -90,6 +90,13 @@ module Camping
C = self
S = IO.read(__FILE__) rescue nil
P = "<h1>Cam\ping Problem!</h1><h2>%s</h2>"
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.
#
Expand Down Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions lib/camping.rb
@@ -1,6 +1,7 @@
%w[uri stringio rack].map{|l|require l};class Object;def meta_def m,&b
(class<<self;self end).send:define_method,m,&b end end;module Camping;C=self
S=IO.read(__FILE__)rescue nil;P="<h1>Cam\ping Problem!</h1><h2>%s</h2>"
S=IO.read(__FILE__)rescue nil;P="<h1>Cam\ping Problem!</h1><h2>%s</h2>";Apps=[].
instance_eval{def << i;delete_if{|f|f.to_s==i.to_s};super;end;self}
class H<Hash
def method_missing m,*a;m.to_s=~/=$/?self[$`]=a[0]:a==[]?self[m.to_s]:super end
undef id,type;end;module Helpers;def R c,*g
Expand Down Expand Up @@ -44,8 +45,8 @@ def M;def M;end;constants.map{|c|k=const_get(c)
k.meta_def(:urls){["/#{c.scan(/.[^A-Z]*/).map(&N.method(:[]))*'/'}"]
}if !k.respond_to?:urls}end end;class I<R()
end; end;X=Controllers;class<<self;def goes m
eval S.gsub(/Camping/,m.to_s),TOPLEVEL_BINDING end;def call e
X.M;e=H[e.to_hash];k,m,*a=X.D e.PATH_INFO,(e.REQUEST_METHOD||'get').downcase
eval S.gsub(/Camping/,m=m.to_s),t=TOPLEVEL_BINDING;Apps<<eval(m,t) end;def call(
e)X.M;e=H[e.to_hash];k,m,*a=X.D e.PATH_INFO,(e.REQUEST_METHOD||'get').downcase
e.REQUEST_METHOD=m;k.new(e).service(*a).to_a;end
def method_missing m,c,*a;X.M;h=Hash===a[-1]?H[a.pop]:{};e=
H[h[:env]||{}].merge!({'rack.input'=>StringIO.new,'REQUEST_METHOD'=>m.to_s})
Expand Down
4 changes: 2 additions & 2 deletions lib/camping/ar.rb
Expand Up @@ -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
4 changes: 2 additions & 2 deletions lib/camping/mab.rb
Expand Up @@ -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

0 comments on commit a4074fa

Please sign in to comment.