From d56614c6fba50a774048e6cb36e136b755321ce7 Mon Sep 17 00:00:00 2001 From: _why Date: Sat, 24 May 2008 19:55:51 -0700 Subject: [PATCH] * Rakefile: use `git rev-list` to estimate a revision number. * 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. --- Rakefile | 4 ++-- examples/blog.rb | 5 ++--- examples/campsh.rb | 2 +- examples/tepee.rb | 2 +- lib/camping-unabridged.rb | 14 +++++++------- lib/camping.rb | 9 +++++---- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Rakefile b/Rakefile index bfe7e7a..109f3e2 100644 --- a/Rakefile +++ b/Rakefile @@ -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", diff --git a/examples/blog.rb b/examples/blog.rb index 4a0f6b0..4bc38c1 100755 --- a/examples/blog.rb +++ b/examples/blog.rb @@ -2,7 +2,7 @@ $:.unshift File.dirname(__FILE__) + "/../lib" require 'camping' -require 'camping/db' +require 'camping/ar' require 'camping/session' Camping.goes :Blog @@ -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 diff --git a/examples/campsh.rb b/examples/campsh.rb index 6f443d9..4243c93 100644 --- a/examples/campsh.rb +++ b/examples/campsh.rb @@ -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 diff --git a/examples/tepee.rb b/examples/tepee.rb index 7c2e14b..3a29ca9 100755 --- a/examples/tepee.rb +++ b/examples/tepee.rb @@ -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 diff --git a/lib/camping-unabridged.rb b/lib/camping-unabridged.rb index 85ee9ed..2c1ca81 100644 --- a/lib/camping-unabridged.rb +++ b/lib/camping-unabridged.rb @@ -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] == "[]" diff --git a/lib/camping.rb b/lib/camping.rb index 773cf5a..9ab1573 100644 --- a/lib/camping.rb +++ b/lib/camping.rb @@ -20,9 +20,10 @@ def method_missing *a,&b;a.shift if a[0]==:render;m=Mab.new({},self) backtrace.map{|b|"
  • #{b}
  • "}}"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= @@ -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 \ No newline at end of file +autoload:Base,'camping/ar';def Y;self;end end;autoload:Mab,'camping/mab'end