Skip to content

Commit

Permalink
* lib/camping.rb: ActiveRecord no longer required, but uses `autoloa…
Browse files Browse the repository at this point in the history
…d` to

   load ActiveRecord to keep backwards.
 * lib/camping/db.rb: moved AR code here, support for other drivers will be
   here.
 * Rakefile: dropped activerecord dep, still have activesupport.
  • Loading branch information
_why committed Jul 11, 2006
1 parent e47edd4 commit 1dc82b2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ spec =
s.homepage = 'http://code.whytheluckystiff.net/camping/'
s.executables = ['camping']

s.add_dependency('activerecord', '>=1.14.2')
s.add_dependency('activesupport', '>1.3.1')
s.add_dependency('markaby', '>0.4')
s.add_dependency('metaid')
s.required_ruby_version = '>= 1.8.2'
Expand Down
7 changes: 3 additions & 4 deletions lib/camping.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%w[active_record markaby metaid tempfile uri].map{|l|require l}
%w[active_support markaby metaid tempfile uri].map{|l|require l}
module Camping;Apps=[];C=self;S=IO.read(__FILE__).sub(/S=I.+$/,'')
P="Cam\ping Problem!";module Helpers;def R c,*g;p=/\(.+?\)/;g.inject(c.
urls.find{|x|x.scan(p).size==g.size}.dup){|s,a|s.sub p,C.escape((a[
Expand Down Expand Up @@ -45,9 +45,8 @@ def qs_parse q,d='&;';m=proc{|_,o,n|o.u(n,&m)rescue([*o
]||"GET")).service *a;rescue Exception=>x;X::ServerError.new(r,e,'get').service(
k,m,x)end;def method_missing m,c,*a;k=X.const_get c;k.new('',
H['HTTP_HOST','','SCRIPT_NAME','','HTTP_COOKIE',''],m.to_s).service *a;end
end;module Views;include X,Helpers end;module Models;A=
ActiveRecord;Base=A::Base;def Base.table_name_prefix;"#{name[/\w+/]}_".
downcase.sub(/^(#{A}|camping)_/i,'')end end;class Mab<Markaby::Builder;include \
end;module Views;include X,Helpers end;module Models;autoload(:Base,'camping/db')
end;class Mab<Markaby::Builder;include \
Views;def tag! *g,&b;h=g[-1];[:href,:action,:src].map{|a|(h[a]=self/h[a])rescue
0};super end end;H=HashWithIndifferentAccess;class H;def method_missing m,*a
m.to_s=~/=$/?self[$`]=a[0]:a==[]?self[m]:raise(NoMethodError,"#{m}")end
Expand Down
14 changes: 14 additions & 0 deletions lib/camping/db.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require 'active_record'
module Camping::Models
A = ActiveRecord
Base = A::Base
def Base.table_name_prefix
"#{name[/\w+/]}_".downcase.sub(/^(#{A}|camping)_/i,'')
end
end
Camping::S.sub! "autoload(:Base,'camping/db')", "Base=ActiveRecord::Base"
Camping::Apps.each do |app|
unless app::Models.const_defined? :Base
app::Models::Base = Camping::Models::Base
end
end

0 comments on commit 1dc82b2

Please sign in to comment.