Skip to content

Commit

Permalink
* Rakefile: use git rev-list to estimate a revision number.
Browse files Browse the repository at this point in the history
 * examples/: switch the example to use 'camping/ar' and allow the blog to use cookie sessions.
 * lib/camping.rb: slight change to assign @response and @request early, to avoid tripping up an older Ruby version.
  • Loading branch information
_why committed May 25, 2008
1 parent 56d4c3a commit d56614c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ require 'fileutils'
include FileUtils

NAME = "camping"
REV = File.read(".svn/entries").split("\n")[3] rescue nil
VERS = ENV['VERSION'] || ("1.5" + (REV ? ".#{REV}" : ""))
REV = (`#{ENV['GIT'] || "git"} rev-list HEAD`.split.length + 1).to_s rescue nil
VERS = ENV['VERSION'] || ("1.9" + (REV ? ".#{REV}" : ""))
CLEAN.include ['**/.*.sw?', '*.gem', '.config', 'test/test.log', '.*.pt']
RDOC_OPTS = ['--quiet', '--title', "Camping, the Documentation",
"--opname", "index.html",
Expand Down
5 changes: 2 additions & 3 deletions examples/blog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$:.unshift File.dirname(__FILE__) + "/../lib"
require 'camping'
require 'camping/db'
require 'camping/ar'
require 'camping/session'

Camping.goes :Blog
Expand Down Expand Up @@ -263,7 +263,6 @@ def _form(post, opts)
end

def Blog.create
Camping::Models::Session.create_schema
Blog::Models.create_schema :assume => (Blog::Models::Post.table_exists? ? 1.0 : 0.0)
Blog::Models.create_schema :assume => (Blog::Models::Post.table_exists? ? 1.0 : 0.0)
end

2 changes: 1 addition & 1 deletion examples/campsh.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby

$:.unshift File.dirname(__FILE__) + "/../lib"
%w(rubygems redcloth camping camping/db acts_as_versioned).each { |lib| require lib }
%w(rubygems redcloth camping camping/ar acts_as_versioned).each { |lib| require lib }

Camping.goes :CampSh

Expand Down
2 changes: 1 addition & 1 deletion examples/tepee.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/ruby
$:.unshift File.dirname(__FILE__) + "/../lib"
%w(rubygems redcloth camping camping/db acts_as_versioned).each { |lib| require lib }
%w(rubygems redcloth camping camping/ar acts_as_versioned).each { |lib| require lib }

Camping.goes :Tepee

Expand Down
14 changes: 7 additions & 7 deletions lib/camping-unabridged.rb
Original file line number Diff line number Diff line change
Expand Up @@ -404,14 +404,14 @@ def to_a
end

def initialize(env) #:nodoc:
@request, @root,
@input, @cookies,
@response, @headers,
@body, @status =
Rack::Request.new(env), @request.script_name.sub(/\/$/,''),
@request, @response =
Rack::Request.new(env), Rack::Response.new
@root, @input, @cookies,
@headers, @body, @status =
@request.script_name.sub(/\/$/,''),
H[@request.params], H[@request.cookies],
Rack::Response.new, @response.headers,
@response.body, @response.status
@response.headers, @response.body,
@response.status

@input.each do |k, v|
if k[-2..-1] == "[]"
Expand Down
9 changes: 5 additions & 4 deletions lib/camping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ def method_missing *a,&b;a.shift if a[0]==:render;m=Mab.new({},self)
backtrace.map{|b|"<li>#{b}</li>"}}</ul></h3>"end;def r501 m=@method
r 501,P%"#{m.upcase} not implemented"end;def to_a
@response.to_a;end;def initialize(env)
@request,@root,@input,@cookies,@response,@headers,@body,@status =
Rack::Request.new(env),@request.script_name.sub(/\/$/,''),H[@request.params],
H[@request.cookies],Rack::Response.new,@response.headers,@response.body,
@request,@response=Rack::Request.new(env),Rack::Response.new
@root,@input,@cookies,@headers,@body,@status =
@request.script_name.sub(/\/$/,''),H[@request.params],
H[@request.cookies],@response.headers,@response.body,
@response.status;@input.each{|k,v|if k[-2..-1]=="[]";@input[k[0..-3]]=
@input.delete(k)elsif k=~/(.*)\[([^\]])\]$/;(@input[$1]||={})[$2]=
@input.delete(k)end};end;def service *a;o=@cookies.dup;@response.body=
Expand All @@ -45,4 +46,4 @@ def method_missing m,c,*a;X.M;h=Hash===a[-1]?H[a.pop]:{};e=
H[h[:env]||{}].u({'rack.input'=>StringIO.new,'REQUEST_METHOD'=>m.to_s})
k=X.const_get(c).new(H[e]);k.send("input=",h[:input])if h[:input]
k.service(*a);end;end;module Views;include X,Helpers end;module Models
autoload:Base,'camping/ar';def Y;self;end end;autoload:Mab,'camping/mab'end
autoload:Base,'camping/ar';def Y;self;end end;autoload:Mab,'camping/mab'end

0 comments on commit d56614c

Please sign in to comment.