zuk-picnic 0.8.0.20090318 → 0.8.0.20090427

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. data/Manifest.txt +26 -27
  2. data/lib/picnic/cli.rb +2 -0
  3. data/lib/picnic/conf.rb +21 -5
  4. data/lib/picnic.rb +1 -1
  5. data/vendor/{camping-2.0.20090212 → camping-2.0.20090421}/CHANGELOG +0 -0
  6. data/vendor/{camping-2.0.20090212 → camping-2.0.20090421}/COPYING +0 -0
  7. data/vendor/camping-2.0.20090421/README +82 -0
  8. data/vendor/{camping-2.0.20090212 → camping-2.0.20090421}/Rakefile +9 -3
  9. data/vendor/camping-2.0.20090421/bin/camping +97 -0
  10. data/vendor/{camping-2.0.20090212 → camping-2.0.20090421}/doc/camping.1.gz +0 -0
  11. data/vendor/{camping-2.0.20090212 → camping-2.0.20090421}/examples/README +0 -0
  12. data/vendor/{camping-2.0.20090212 → camping-2.0.20090421}/examples/blog.rb +0 -0
  13. data/vendor/{camping-2.0.20090212 → camping-2.0.20090421}/examples/campsh.rb +0 -0
  14. data/vendor/{camping-2.0.20090212 → camping-2.0.20090421}/examples/tepee.rb +0 -0
  15. data/vendor/{camping-2.0.20090212 → camping-2.0.20090421}/extras/Camping.gif +0 -0
  16. data/vendor/{camping-2.0.20090212 → camping-2.0.20090421}/extras/permalink.gif +0 -0
  17. data/vendor/{camping-2.0.20090212 → camping-2.0.20090421}/lib/camping/ar/session.rb +0 -0
  18. data/vendor/{camping-2.0.20090212 → camping-2.0.20090421}/lib/camping/ar.rb +0 -0
  19. data/vendor/{camping-2.0.20090212 → camping-2.0.20090421}/lib/camping/mab.rb +0 -0
  20. data/vendor/camping-2.0.20090421/lib/camping/reloader.rb +184 -0
  21. data/vendor/camping-2.0.20090421/lib/camping/server.rb +159 -0
  22. data/vendor/{camping-2.0.20090212 → camping-2.0.20090421}/lib/camping/session.rb +1 -0
  23. data/vendor/{camping-2.0.20090212 → camping-2.0.20090421}/lib/camping-unabridged.rb +53 -61
  24. data/vendor/{camping-2.0.20090212 → camping-2.0.20090421}/lib/camping.rb +23 -25
  25. data/vendor/{camping-2.0.20090212 → camping-2.0.20090421}/setup.rb +0 -0
  26. data/vendor/{camping-2.0.20090212 → camping-2.0.20090421}/test/apps/env_debug.rb +0 -0
  27. data/vendor/{camping-2.0.20090212 → camping-2.0.20090421}/test/apps/forms.rb +0 -0
  28. data/vendor/{camping-2.0.20090212 → camping-2.0.20090421}/test/apps/misc.rb +0 -0
  29. data/vendor/{camping-2.0.20090212 → camping-2.0.20090421}/test/apps/sessions.rb +0 -0
  30. data/vendor/{camping-2.0.20090212 → camping-2.0.20090421}/test/test_camping.rb +0 -0
  31. metadata +28 -29
  32. data/vendor/camping-2.0.20090212/README +0 -119
  33. data/vendor/camping-2.0.20090212/bin/camping +0 -99
  34. data/vendor/camping-2.0.20090212/extras/flipbook_rdoc.rb +0 -491
  35. data/vendor/camping-2.0.20090212/lib/camping/reloader.rb +0 -163
  36. data/vendor/camping-2.0.20090212/lib/camping/server.rb +0 -158
@@ -0,0 +1,159 @@
1
+ require 'irb'
2
+ require 'rack'
3
+ require 'camping/reloader'
4
+
5
+ # TODO: I guess we should documentate this too...
6
+ class Camping::Server
7
+ attr_reader :reloader
8
+ attr_accessor :conf
9
+
10
+ def initialize(conf, paths)
11
+ @conf = conf
12
+ @paths = paths
13
+ @reloader = Camping::Reloader.new
14
+ connect(@conf.database) if @conf.database
15
+ end
16
+
17
+ def connect(db)
18
+ unless Camping.autoload?(:Models)
19
+ Camping::Models::Base.establish_connection(db)
20
+ end
21
+ end
22
+
23
+ def find_scripts
24
+ scripts = @paths.map do |path|
25
+ case
26
+ when File.file?(path)
27
+ path
28
+ when File.directory?(path)
29
+ Dir[File.join(path, '*.rb')]
30
+ end
31
+ end.flatten.compact
32
+ @reloader.update(*scripts)
33
+ end
34
+
35
+ def index_page(apps)
36
+ welcome = "You are Camping"
37
+ header = <<-HTML
38
+ <html>
39
+ <head>
40
+ <title>#{welcome}</title>
41
+ <style type="text/css">
42
+ body {
43
+ font-family: verdana, arial, sans-serif;
44
+ padding: 10px 40px;
45
+ margin: 0;
46
+ }
47
+ h1, h2, h3, h4, h5, h6 {
48
+ font-family: utopia, georgia, serif;
49
+ }
50
+ </style>
51
+ </head>
52
+ <body>
53
+ <h1>#{welcome}</h1>
54
+ HTML
55
+ footer = '</body></html>'
56
+ main = if apps.empty?
57
+ "<p>Good day. I'm sorry, but I could not find any Camping apps."\
58
+ "You might want to take a look at the console to see if any errors"\
59
+ "have been raised</p>"
60
+ else
61
+ "<p>Good day. These are the Camping apps you've mounted.</p><ul>" +
62
+ apps.map do |mount, app|
63
+ "<li><h3 style=\"display: inline\"><a href=\"/#{mount}\">#{app}</a></h3><small> / <a href=\"/code/#{mount}\">View source</a></small></li>"
64
+ end.join("\n") + '</ul>'
65
+ end
66
+
67
+ header + main + footer
68
+ end
69
+
70
+ def app
71
+ reload!
72
+ all_apps = apps
73
+ rapp = case all_apps.length
74
+ when 0
75
+ proc{|env|[200,{'Content-Type'=>'text/html'},index_page([])]}
76
+ when 1
77
+ apps.values.first
78
+ else
79
+ hash = {
80
+ "/" => proc {|env|[200,{'Content-Type'=>'text/html'},index_page(all_apps)]}
81
+ }
82
+ all_apps.each do |mount, wrapp|
83
+ # We're doing @reloader.reload! ourself, so we don't need the wrapper.
84
+ app = wrapp.app
85
+ hash["/#{mount}"] = app
86
+ hash["/code/#{mount}"] = proc do |env|
87
+ [200,{'Content-Type'=>'text/plain','X-Sendfile'=>wrapp.script.file},'']
88
+ end
89
+ end
90
+ Rack::URLMap.new(hash)
91
+ end
92
+ rapp = Rack::ContentLength.new(rapp)
93
+ rapp = Rack::Lint.new(rapp)
94
+ rapp = XSendfile.new(rapp)
95
+ rapp = Rack::ShowExceptions.new(rapp)
96
+ end
97
+
98
+ def apps
99
+ @reloader.apps.inject({}) do |h, (mount, wrapp)|
100
+ h[mount.to_s.downcase] = wrapp
101
+ h
102
+ end
103
+ end
104
+
105
+ def call(env)
106
+ app.call(env)
107
+ end
108
+
109
+ def start
110
+ handler, conf = case @conf.server
111
+ when "console"
112
+ puts "** Starting console"
113
+ reload!
114
+ this = self; eval("self", TOPLEVEL_BINDING).meta_def(:reload!) { this.reload!; nil }
115
+ ARGV.clear
116
+ IRB.start
117
+ exit
118
+ when "mongrel"
119
+ puts "** Starting Mongrel on #{@conf.host}:#{@conf.port}"
120
+ [Rack::Handler::Mongrel, {:Port => @conf.port, :Host => @conf.host}]
121
+ when "webrick"
122
+ puts "** Starting WEBrick on #{@conf.host}:#{@conf.port}"
123
+ [Rack::Handler::WEBrick, {:Port => @conf.port, :BindAddress => @conf.host}]
124
+ end
125
+
126
+ handler.run(self, conf)
127
+ end
128
+
129
+ def reload!
130
+ find_scripts
131
+ @reloader.reload!
132
+ end
133
+
134
+ # A Rack middleware for reading X-Sendfile. Should only be used in
135
+ # development.
136
+ class XSendfile
137
+
138
+ HEADERS = [
139
+ "X-Sendfile",
140
+ "X-Accel-Redirect",
141
+ "X-LIGHTTPD-send-file"
142
+ ]
143
+
144
+ def initialize(app)
145
+ @app = app
146
+ end
147
+
148
+ def call(env)
149
+ status, headers, body = @app.call(env)
150
+ headers = Rack::Utils::HeaderHash.new(headers)
151
+ if header = HEADERS.detect { |header| headers.include?(header) }
152
+ path = headers[header]
153
+ body = File.read(path)
154
+ headers['Content-Length'] = body.length.to_s
155
+ end
156
+ [status, headers, body]
157
+ end
158
+ end
159
+ end
@@ -1,4 +1,5 @@
1
1
  # == About camping/session.rb
2
+ # TODO: Clean everything up. Lots of just plain wrong stuff in here.
2
3
  #
3
4
  # This file contains two modules which supply basic sessioning to your Camping app.
4
5
  # Again, we're dealing with a pretty little bit of code: approx. 60 lines.
@@ -9,23 +9,6 @@
9
9
  # nicely with piles of documentation everywhere. This documentation is entirely
10
10
  # generated from lib/camping-unabridged.rb using RDoc and our "flipbook" template
11
11
  # found in the extras directory of any camping distribution.
12
- #
13
- # == Requirements
14
- #
15
- # Camping requires at least Ruby 1.8.2.
16
- #
17
- # Camping depends on the following libraries. If you install through RubyGems,
18
- # these will be automatically installed for you.
19
- #
20
- # * ActiveRecord, used in your models.
21
- # ActiveRecord is an object-to-relational database mapper with adapters
22
- # for SQLite3, MySQL, PostgreSQL, SQL Server and more.
23
- # * Markaby, used in your views to describe HTML in plain Ruby.
24
- #
25
- # Camping also works well with Mongrel, the swift Ruby web server.
26
- # http://rubyforge.org/projects/mongrel Mongrel comes with examples
27
- # in its <tt>examples/camping</tt> directory.
28
- #
29
12
  %w[uri stringio rack].map { |l| require l }
30
13
 
31
14
  class Object #:nodoc:
@@ -34,7 +17,11 @@ class Object #:nodoc:
34
17
  end
35
18
  end
36
19
 
37
- # == Camping
20
+ # == Camping
21
+ # TODO: Tutorial: Camping.goes, MVC (link to Controllers, Models, Views where
22
+ # they're described in detail), Camping Server (for development), Rack
23
+ # (for production). the create-method. Service overload too, perhaps?
24
+ # Overriding r404, r500 and r501.
38
25
  #
39
26
  # The camping module contains three modules for separating your application:
40
27
  #
@@ -47,6 +34,7 @@ end
47
34
  # * Camping::Helpers which can be used in controllers and views.
48
35
  #
49
36
  # == The Camping Server
37
+ # TODO: Only for development.
50
38
  #
51
39
  # How do you run Camping apps? Oh, uh... The Camping Server!
52
40
  #
@@ -84,6 +72,7 @@ end
84
72
  # end
85
73
  # end
86
74
  #
75
+ # TODO: Wiki is down.
87
76
  # For more tips, see http://code.whytheluckystiff.net/camping/wiki/GiveUsTheCreateMethod.
88
77
  module Camping
89
78
  C = self
@@ -91,6 +80,7 @@ module Camping
91
80
  P = "<h1>Cam\ping Problem!</h1><h2>%s</h2>"
92
81
  U = Rack::Utils
93
82
  Apps = []
83
+ # TODO: @input[:page] != @input['page']
94
84
  # An object-like Hash.
95
85
  # All Camping query string and cookie variables are loaded as this.
96
86
  #
@@ -125,7 +115,8 @@ module Camping
125
115
  end
126
116
  undef id, type
127
117
  end
128
-
118
+
119
+ # TODO: Fair enough. Maybe complete the ActionPack example?
129
120
  # Helpers contains methods available in your controllers and views. You may add
130
121
  # methods of your own to this module, including many helper methods from Rails.
131
122
  # This is analogous to Rails' <tt>ApplicationHelper</tt> module.
@@ -190,7 +181,7 @@ module Camping
190
181
  # is assigned to route <tt>/logout</tt>. The HTML will come out as:
191
182
  #
192
183
  # <div id="menu">
193
- # <a href="//localhost:3301/frodo/">Home</a>
184
+ # <a href="http://localhost:3301/frodo/">Home</a>
194
185
  # <a href="/frodo/profile">Profile</a>
195
186
  # <a href="/frodo/logout">Logout</a>
196
187
  # <a href="http://google.com">Google</a>
@@ -251,6 +242,7 @@ module Camping
251
242
  # Forgivable, considering that it's only really a handful of methods and accessors.
252
243
  #
253
244
  # == Treating controller methods like Response objects
245
+ # TODO: I don't think this belongs here. Either Controllers or Camping.
254
246
  #
255
247
  # Camping originally came with a barebones Response object, but it's often much more readable
256
248
  # to just use your controller as the response.
@@ -279,6 +271,7 @@ module Camping
279
271
  #
280
272
  module Base
281
273
  attr_accessor :input, :cookies, :headers, :body, :status, :root
274
+ M = proc { |_, o, n| o.merge(n, &M) }
282
275
 
283
276
  # Display a view, calling it by its method name +m+. If a <tt>layout</tt>
284
277
  # method is found in Camping::Views, it will be used to wrap the HTML.
@@ -328,6 +321,7 @@ module Camping
328
321
  # You can also switch the body and the header in order to support Rack:
329
322
  #
330
323
  # r(302, {'Location' => self / "/view/12"}, '')
324
+ # r(another_app.call(@env))
331
325
  #
332
326
  # See also: #r404, #r500 and #r501
333
327
  def r(s, b, h = {})
@@ -367,8 +361,8 @@ module Camping
367
361
  # end
368
362
  #
369
363
  # See: I
370
- def r404(p=env.PATH)
371
- r(404, P % "#{p} not found")
364
+ def r404(p)
365
+ P % "#{p} not found"
372
366
  end
373
367
 
374
368
  # If there is a parse error in Camping or in your application's source code, it will not be caught
@@ -378,15 +372,15 @@ module Camping
378
372
  # You can overide it, but if you have an error in here, it will be uncaught !
379
373
  #
380
374
  # See: I
381
- def r500(k,m,x)
382
- r(500, P % "#{k}.#{m}" + "<h3>#{x.class} #{x.message}: <ul>#{x.backtrace.map{|b|"<li>#{b}</li>"}}</ul></h3>")
375
+ def r500(k,m,e)
376
+ raise e
383
377
  end
384
378
 
385
379
  # Called if an undefined method is called on a Controller, along with the request method +m+ (GET, POST, etc.)
386
380
  #
387
381
  # See: I
388
- def r501(m=@method)
389
- r(501, P % "#{m.upcase} not implemented")
382
+ def r501(m)
383
+ P % "#{m.upcase} not implemented"
390
384
  end
391
385
 
392
386
  # Turn a controller into an array. This is designed to be used to pipe
@@ -401,46 +395,41 @@ module Camping
401
395
  # end
402
396
  # end
403
397
  def to_a
404
- @response.body = (@body.respond_to?(:each) ? @body : '')
405
- @response.status = @status
406
- @response.headers.merge!(@headers)
398
+ r = Rack::Response.new(@body, @status, @headers)
407
399
  @cookies.each do |k, v|
408
400
  v = {:value => v, :path => self / "/"} if String===v
409
- @response.set_cookie(k, v) if @request.cookies[k] != v
401
+ r.set_cookie(k, v)
410
402
  end
411
- @response.to_a
403
+ r.to_a
412
404
  end
413
405
 
414
- def initialize(env) #:nodoc:
415
- @request, @response, @env =
416
- Rack::Request.new(env), Rack::Response.new, env
417
- @root, @input, @cookies,
418
- @headers, @status =
419
- @env.SCRIPT_NAME.sub(/\/$/,''),
420
- H[@request.params], H[@request.cookies],
421
- @response.headers, @response.status
422
-
423
- @input.each do |k, v|
424
- if k[-2..-1] == "[]"
425
- @input[k[0..-3]] = @input.delete(k)
426
- elsif k =~ /(.*)\[([^\]]+)\]$/
427
- (@input[$1] ||= H[])[$2] = @input.delete(k)
428
- end
406
+ def initialize(env, m) #:nodoc:
407
+ r = @request = Rack::Request.new(@env = env)
408
+ @root, p, @cookies,
409
+ @headers, @status, @method =
410
+ (env.SCRIPT_NAME||'').sub(/\/$/,''),
411
+ H[r.params], H[r.cookies],
412
+ {}, m =~ /r(\d+)/ ? $1.to_i : 200, m
413
+
414
+ @input = p.inject(H[]) do |h, (k, v)|
415
+ h.merge(k.split(/[\]\[]+/).reverse.inject(v) { |x, i| H[i => x] }, &M)
429
416
  end
430
417
  end
431
418
 
419
+ # TODO: The wiki is down. Service overload should probably go in Camping.
432
420
  # All requests pass through this method before going to the controller. Some magic
433
421
  # in Camping can be performed by overriding this method.
434
422
  #
435
423
  # See http://code.whytheluckystiff.net/camping/wiki/BeforeAndAfterOverrides for more
436
424
  # on before and after overrides with Camping.
437
425
  def service(*a)
438
- r = catch(:halt){send(@env.REQUEST_METHOD.downcase, *a)}
426
+ r = catch(:halt){send(@method, *a)}
439
427
  @body ||= r
440
428
  self
441
429
  end
442
430
  end
443
-
431
+
432
+ # TODO: @input & @cookies at least.
444
433
  # Controllers is a module for placing classes which handle URLs. This is done
445
434
  # by defining a route to each class using the Controllers::R method.
446
435
  #
@@ -510,7 +499,7 @@ module Camping
510
499
  [I, 'r404', p]
511
500
  end
512
501
 
513
- N = H.new { |_,x| x.downcase }.merge! "N" => '(\d+)', "X" => '(\w+)', "Index" => ''
502
+ N = H.new { |_,x| x.downcase }.merge! "N" => '(\d+)', "X" => '([^/]+)', "Index" => ''
514
503
  # The route maker, this is called by Camping internally, you shouldn't need to call it.
515
504
  #
516
505
  # Still, it's worth know what this method does. Since Ruby doesn't keep track of class
@@ -533,8 +522,7 @@ module Camping
533
522
  end
534
523
 
535
524
  # Internal controller with no route. Used by #D and C.call to show internal messages.
536
- class I < R()
537
- end
525
+ I = R()
538
526
  end
539
527
  X = Controllers
540
528
 
@@ -559,10 +547,12 @@ module Camping
559
547
  # And array with [statuc, headers, body] is expected at the output.
560
548
  def call(e)
561
549
  X.M
562
- e = H[e.to_hash]
563
- k,m,*a=X.D e.PATH_INFO,(e.REQUEST_METHOD||'get').downcase
564
- e.REQUEST_METHOD = m
565
- k.new(e).service(*a).to_a
550
+ e = H[e]
551
+ p = e.PATH_INFO = U.unescape(e.PATH_INFO)
552
+ k,m,*a=X.D p,(e.REQUEST_METHOD||'get').downcase
553
+ k.new(e,m).service(*a).to_a
554
+ rescue
555
+ r500(:I, k, m, $!, :env => e).to_a
566
556
  end
567
557
 
568
558
  # The Camping scriptable dispatcher. Any unhandled method call to the app module will
@@ -585,14 +575,15 @@ module Camping
585
575
  #
586
576
  def method_missing(m, c, *a)
587
577
  X.M
588
- h=Hash===a[-1]?H[a.pop]:{}
589
- e=H[h[:env]||{}].merge!({'rack.input'=>StringIO.new,'REQUEST_METHOD'=>m.to_s})
590
- k = X.const_get(c).new(H[e])
591
- k.send("input=",h[:input]) if h[:input]
578
+ h = Hash === a[-1] ? a.pop : {}
579
+ e = H[Rack::MockRequest.env_for('',h[:env]||{})]
580
+ k = X.const_get(c).new(e,m.to_s)
581
+ k.send("input=", h[:input]) if h[:input]
592
582
  k.service(*a)
593
583
  end
594
584
  end
595
-
585
+
586
+ # TODO: More examples.
596
587
  # Views is an empty module for storing methods which create HTML. The HTML is described
597
588
  # using the Markaby language.
598
589
  #
@@ -601,7 +592,8 @@ module Camping
601
592
  # If your Views module has a <tt>layout</tt> method defined, it will be called with a block
602
593
  # which will insert content from your view.
603
594
  module Views; include X, Helpers end
604
-
595
+
596
+ # TODO: Migrations
605
597
  # Models is an empty Ruby module for housing model classes derived
606
598
  # from ActiveRecord::Base. As a shortcut, you may derive from Base
607
599
  # which is an alias for ActiveRecord::Base.
@@ -11,44 +11,42 @@ h.any?? u+"?"+U.build_query(h[0]):u end;def / p
11
11
  p[0]==?/?@root+p:p end;def URL c='/',*a;c=R(c, *a) if c.respond_to?:urls
12
12
  c=self/c;c=@request.url[/.{8,}?(?=\/)/]+c if c[0]==?/;URI c end
13
13
  end;module Base;attr_accessor:input,:cookies,:headers,:body,:status,:root
14
+ M=proc{|_,o,n|o.merge(n,&M)}
14
15
  def render v,*a,&b;mab(/^_/!~v.to_s){send(v,*a,&b)} end
15
16
  def mab l=nil,&b;m=Mab.new({},self);s=m.capture(&b)
16
17
  s=m.capture{layout{s}} if l && m.respond_to?(:layout);s end
17
18
  def r s,b,h={};b,h=h,b if Hash===b;@status=s;
18
19
  @headers.merge!(h);@body=b;end;def redirect *a;r 302,'','Location'=>URL(*a).
19
- to_s;end;def r404 p=env.PATH;r 404,P%"#{p} not found"end;def r500 k,m,x
20
- r 500,P%"#{k}.#{m}"+"<h3>#{x.class} #{x.message}: <ul>#{x.
21
- backtrace.map{|b|"<li>#{b}</li>"}}</ul></h3>"end;def r501 m=@method
22
- r 501,P%"#{m.upcase} not implemented"end;def to_a
23
- @response.body=@body.respond_to?(:each)?@body:""
24
- @response.status=@status;@response.headers.merge!(@headers)
20
+ to_s;end;def r404 p;P%"#{p} not found"end;def r500 k,m,e;raise e;end
21
+ def r501 m;P%"#{m.upcase} not implemented"end;def to_a
22
+ r=Rack::Response.new(@body,@status,@headers)
25
23
  @cookies.each{|k,v|v={:value=>v,:path=>self/"/"} if String===v
26
- @response.set_cookie(k,v) if @request.cookies[k]!=v}
27
- @response.to_a;end;def initialize(env)
28
- @request,@response,@env=Rack::Request.new(env),Rack::Response.new,env
29
- @root,@input,@cookies,@headers,@status=
30
- @env.SCRIPT_NAME.sub(/\/$/,''),H[@request.params],
31
- H[@request.cookies],@response.headers,@response.status
32
- @input.each{|k,v|if k[-2..-1]=="[]";@input[k[0..-3]]=
33
- @input.delete(k)elsif k=~/(.*)\[([^\]]+)\]$/
34
- (@input[$1]||=H[])[$2]=@input.delete(k)end};end;def service *a
35
- r=catch(:halt){send(@env.REQUEST_METHOD.downcase,*a)};@body||=r
24
+ r.set_cookie(k,v)}
25
+ r.to_a;end;def initialize(env,m)
26
+ r=@request=Rack::Request.new(@env=env)
27
+ @root,p,@cookies,@headers,@status,@method=
28
+ (env.SCRIPT_NAME||'').sub(/\/$/,''),H[r.params],
29
+ H[r.cookies],{},m=~/r(\d+)/?$1.to_i: 200,m
30
+ @input=p.inject(H[]){|h,(k,v)|h.merge k.split(/[\]\[]+/).reverse.inject(v){|x,i|
31
+ H[i=>x]},&M};end;def service *a
32
+ r=catch(:halt){send(@method,*a)};@body||=r
36
33
  self;end;end;module Controllers;@r=[];class<<self;def r;@r end;def R *u;r=@r
37
34
  Class.new{meta_def(:urls){u};meta_def(:inherited){|x|r<<x}}end
38
35
  def D p,m;p='/'if !p||!p[0]
39
36
  r.map{|k|k.urls.map{|x|return(k.instance_method(m)rescue nil)?
40
37
  [k,m,*$~[1..-1]]:[I,'r501',m]if p=~/^#{x}\/?$/}};[I,'r404',p] end
41
- N=H.new{|_,x|x.downcase}.merge! "N"=>'(\d+)',"X"=>'(\w+)',"Index"=>''
38
+ N=H.new{|_,x|x.downcase}.merge! "N"=>'(\d+)',"X"=>'([^/]+)',"Index"=>''
42
39
  def M;def M;end;constants.map{|c|k=const_get(c)
43
40
  k.send:include,C,Base,Helpers,Models;@r=[k]+r if r-[k]==r
44
41
  k.meta_def(:urls){["/#{c.scan(/.[^A-Z]*/).map(&N.method(:[]))*'/'}"]
45
- }if !k.respond_to?:urls}end end;class I<R()
46
- end; end;X=Controllers;class<<self;def goes m
47
- Apps<<eval(S.gsub(/Camping/,m.to_s),TOPLEVEL_BINDING) end;def call(
48
- e)X.M;e=H[e.to_hash];k,m,*a=X.D e.PATH_INFO,(e.REQUEST_METHOD||'get').downcase
49
- e.REQUEST_METHOD=m;k.new(e).service(*a).to_a;end
50
- def method_missing m,c,*a;X.M;h=Hash===a[-1]?H[a.pop]:{};e=
51
- H[h[:env]||{}].merge!({'rack.input'=>StringIO.new,'REQUEST_METHOD'=>m.to_s})
52
- k=X.const_get(c).new(H[e]);k.send("input=",h[:input])if h[:input]
42
+ }if !k.respond_to?:urls}end end;I=R()
43
+ end;X=Controllers;class<<self;def goes m
44
+ Apps<<eval(S.gsub(/Camping/,m.to_s),TOPLEVEL_BINDING) end;def call e
45
+ X.M;e=H[e];p=e.PATH_INFO=U.unescape(e.PATH_INFO)
46
+ k,m,*a=X.D p,(e.REQUEST_METHOD||'get').downcase
47
+ k.new(e,m).service(*a).to_a;rescue;r500(:I,k,m,$!,:env=>e).to_a;end
48
+ def method_missing m,c,*a;X.M;h=Hash===a[-1]?a.pop: {}
49
+ e=H[Rack::MockRequest.env_for('',h[:env]||{})]
50
+ k=X.const_get(c).new(e,m.to_s);k.send("input=",h[:input])if h[:input]
53
51
  k.service(*a);end;end;module Views;include X,Helpers end;module Models
54
52
  autoload:Base,'camping/ar';def Y;self;end end;autoload:Mab,'camping/mab';C end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zuk-picnic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0.20090318
4
+ version: 0.8.0.20090427
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Zukowski
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-18 00:00:00 -07:00
12
+ date: 2009-04-27 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -83,33 +83,32 @@ files:
83
83
  - setup.rb
84
84
  - test/picnic_test.rb
85
85
  - test/test_helper.rb
86
- - vendor/camping-2.0.20090212/CHANGELOG
87
- - vendor/camping-2.0.20090212/COPYING
88
- - vendor/camping-2.0.20090212/README
89
- - vendor/camping-2.0.20090212/Rakefile
90
- - vendor/camping-2.0.20090212/bin/camping
91
- - vendor/camping-2.0.20090212/doc/camping.1.gz
92
- - vendor/camping-2.0.20090212/examples/README
93
- - vendor/camping-2.0.20090212/examples/blog.rb
94
- - vendor/camping-2.0.20090212/examples/campsh.rb
95
- - vendor/camping-2.0.20090212/examples/tepee.rb
96
- - vendor/camping-2.0.20090212/extras/Camping.gif
97
- - vendor/camping-2.0.20090212/extras/flipbook_rdoc.rb
98
- - vendor/camping-2.0.20090212/extras/permalink.gif
99
- - vendor/camping-2.0.20090212/lib/camping-unabridged.rb
100
- - vendor/camping-2.0.20090212/lib/camping.rb
101
- - vendor/camping-2.0.20090212/lib/camping/ar.rb
102
- - vendor/camping-2.0.20090212/lib/camping/ar/session.rb
103
- - vendor/camping-2.0.20090212/lib/camping/mab.rb
104
- - vendor/camping-2.0.20090212/lib/camping/reloader.rb
105
- - vendor/camping-2.0.20090212/lib/camping/server.rb
106
- - vendor/camping-2.0.20090212/lib/camping/session.rb
107
- - vendor/camping-2.0.20090212/setup.rb
108
- - vendor/camping-2.0.20090212/test/apps/env_debug.rb
109
- - vendor/camping-2.0.20090212/test/apps/forms.rb
110
- - vendor/camping-2.0.20090212/test/apps/misc.rb
111
- - vendor/camping-2.0.20090212/test/apps/sessions.rb
112
- - vendor/camping-2.0.20090212/test/test_camping.rb
86
+ - vendor/camping-2.0.20090421/CHANGELOG
87
+ - vendor/camping-2.0.20090421/COPYING
88
+ - vendor/camping-2.0.20090421/README
89
+ - vendor/camping-2.0.20090421/Rakefile
90
+ - vendor/camping-2.0.20090421/bin/camping
91
+ - vendor/camping-2.0.20090421/doc/camping.1.gz
92
+ - vendor/camping-2.0.20090421/examples/README
93
+ - vendor/camping-2.0.20090421/examples/blog.rb
94
+ - vendor/camping-2.0.20090421/examples/campsh.rb
95
+ - vendor/camping-2.0.20090421/examples/tepee.rb
96
+ - vendor/camping-2.0.20090421/extras/Camping.gif
97
+ - vendor/camping-2.0.20090421/extras/permalink.gif
98
+ - vendor/camping-2.0.20090421/lib/camping-unabridged.rb
99
+ - vendor/camping-2.0.20090421/lib/camping.rb
100
+ - vendor/camping-2.0.20090421/lib/camping/ar.rb
101
+ - vendor/camping-2.0.20090421/lib/camping/ar/session.rb
102
+ - vendor/camping-2.0.20090421/lib/camping/mab.rb
103
+ - vendor/camping-2.0.20090421/lib/camping/reloader.rb
104
+ - vendor/camping-2.0.20090421/lib/camping/server.rb
105
+ - vendor/camping-2.0.20090421/lib/camping/session.rb
106
+ - vendor/camping-2.0.20090421/setup.rb
107
+ - vendor/camping-2.0.20090421/test/apps/env_debug.rb
108
+ - vendor/camping-2.0.20090421/test/apps/forms.rb
109
+ - vendor/camping-2.0.20090421/test/apps/misc.rb
110
+ - vendor/camping-2.0.20090421/test/apps/sessions.rb
111
+ - vendor/camping-2.0.20090421/test/test_camping.rb
113
112
  has_rdoc: true
114
113
  homepage: http://picnic.rubyforge.org
115
114
  post_install_message: