Skip to content

Commit

Permalink
Earning more bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
judofyr committed Nov 13, 2008
1 parent 5359649 commit 7eabcbb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lib/camping-unabridged.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
# ActiveRecord is an object-to-relational database mapper with adapters
# for SQLite3, MySQL, PostgreSQL, SQL Server and more.
# * Markaby, used in your views to describe HTML in plain Ruby.
# * MetAid, a few metaprogramming methods which Camping uses.
#
# Camping also works well with Mongrel, the swift Ruby web server.
# http://rubyforge.org/projects/mongrel Mongrel comes with examples
Expand Down Expand Up @@ -90,6 +89,7 @@ module Camping
C = self
S = IO.read(__FILE__) rescue nil
P = "<h1>Cam\ping Problem!</h1><h2>%s</h2>"
U = Rack::Utils
Apps = []
# An object-like Hash.
# All Camping query string and cookie variables are loaded as this.
Expand Down Expand Up @@ -202,9 +202,9 @@ def R(c,*g)
raise "bad route" unless u = c.urls.find{|x|
break x if x.scan(p).size == g.size &&
/^#{x}\/?$/ =~ (x=g.inject(x){|x,a|
x.sub p,Rack::Utils.escape((a[a.class.primary_key]rescue a))})
x.sub p,U.escape((a[a.class.primary_key]rescue a))})
}
h.any?? u+"?"+h[0].map{|x|x.map{|z|Rack::Utils.escape z}*"="}*"&": u
h.any?? u+"?"+U.build_query(h[0]) : u
end

# Simply builds a complete path from a path +p+ within the app. If your application is
Expand Down
8 changes: 4 additions & 4 deletions lib/camping.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
%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>";Apps=[]
class H<Hash
S=IO.read(__FILE__)rescue nil;P="<h1>Cam\ping Problem!</h1><h2>%s</h2>"
U=Rack::Utils;Apps=[];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
p,h=/\(.+?\)/,g.grep(Hash);g-=h;raise"bad route"unless u=c.urls.find{|x|
break x if x.scan(p).size==g.size&&/^#{x}\/?$/=~(x=g.inject(x){|x,a|
x.sub p,Rack::Utils.escape((a[a.class.primary_key]rescue a))})}
h.any?? u+"?"+h[0].map{|x|x.map{|z|Rack::Utils.escape z}*"="}*"&":u end;def / p
x.sub p,U.escape((a[a.class.primary_key]rescue a))})}
h.any?? u+"?"+U.build_query(h[0]):u end;def / p
p[/^\//]?@root+p:p end;def URL c='/',*a;c=R(c, *a) if c.respond_to?:urls
c=self/c;c=@request.url.split("/",4)[0..-2].join("/")+c if c[/^\//];URI c end
end;module Base;attr_accessor:input,:cookies,:headers,:body,:status,:root
Expand Down

0 comments on commit 7eabcbb

Please sign in to comment.