Skip to content
This repository
Browse code

Removes examples so it can be replaced with separate repo

  • Loading branch information...
commit 5f6e788e27d495af3fa76d0286af8814cd2652b9 1 parent 6f5d1f3
Yehuda Katz authored August 18, 2009
87  actionpack/examples/minimal.rb
... ...
@@ -1,87 +0,0 @@
1  
-$:.push File.join(File.dirname(__FILE__), "..", "lib")
2  
-$:.push File.join(File.dirname(__FILE__), "..", "..", "activesupport", "lib")
3  
-require "action_controller"
4  
-
5  
-class Runner
6  
-  def initialize(app, output)
7  
-    @app, @output = app, output
8  
-  end
9  
-
10  
-  def puts(*)
11  
-    super if @output
12  
-  end
13  
-
14  
-  def call(env)
15  
-    env['n'].to_i.times { @app.call(env) }
16  
-    @app.call(env).tap { |response| report(env, response) }
17  
-  end
18  
-
19  
-  def report(env, response)
20  
-    if ENV["DEBUG"]
21  
-      out = env['rack.errors']
22  
-      p response.headers
23  
-      out.puts response.status, response.headers.to_yaml, '---'
24  
-      response.body.each { |part| out.puts part }
25  
-      out.puts '---'
26  
-    end
27  
-  end
28  
-
29  
-  def self.puts(*)
30  
-    super if @output
31  
-  end
32  
-
33  
-  def self.run(app, n, label = nil, uri = "/", output = true)
34  
-    @output = output
35  
-    puts label, '=' * label.size if label
36  
-    env = Rack::MockRequest.env_for(uri).merge('n' => n, 'rack.input' => StringIO.new(''), 'rack.errors' => $stdout)
37  
-    t = Benchmark.realtime { new(app, output).call(env) }
38  
-    puts "%d ms / %d req = %.1f usec/req" % [10**3 * t, n, 10**6 * t / n]
39  
-    puts
40  
-  end
41  
-end
42  
-
43  
-N = (ENV['N'] || 1000).to_i
44  
-
45  
-class BasePostController < ActionController::Base
46  
-  append_view_path "#{File.dirname(__FILE__)}/views"
47  
-
48  
-  def index
49  
-    render :text => 'Hello'
50  
-  end
51  
-
52  
-  def partial
53  
-    render :partial => "/partial"
54  
-  end
55  
-
56  
-  def many_partials
57  
-    render :partial => "/many_partials"
58  
-  end
59  
-
60  
-  def partial_collection
61  
-    render :partial => "/collection", :collection => [1,2,3,4,5,6,7,8,9,10]
62  
-  end
63  
-
64  
-  def show_template
65  
-    render :template => "template"
66  
-  end
67  
-end
68  
-
69  
-# p BasePostController.call(Rack::MockRequest.env_for("/?action=index").merge("REQUEST_URI" => "/")).body
70  
-
71  
-Runner.run(BasePostController, N, 'index', "/?action=index", false)
72  
-Runner.run(BasePostController, N, 'partial', "/?action=partial", false)
73  
-Runner.run(BasePostController, N, 'many partials', "/?action=many_partials", false)
74  
-Runner.run(BasePostController, N, 'collection', "/?action=partial_collection", false)
75  
-Runner.run(BasePostController, N, 'template', "/?action=show_template", false)
76  
-
77  
-(ENV["M"] || 1).to_i.times do
78  
-  Runner.run(BasePostController, N, 'index', "/?action=index")
79  
-  Runner.run(BasePostController, N, 'partial', "/?action=partial")
80  
-  Runner.run(BasePostController, N, 'many partials', "/?action=many_partials")
81  
-  Runner.run(BasePostController, N, 'collection', "/?action=partial_collection")
82  
-  Runner.run(BasePostController, N, 'template', "/?action=show_template")
83  
-end
84  
-  # Runner.run(BasePostController.action(:many_partials), N, 'index')
85  
-  # Runner.run(BasePostController.action(:many_partials), N, 'many_partials')
86  
-  # Runner.run(BasePostController.action(:partial_collection), N, 'collection')
87  
-  # Runner.run(BasePostController.action(:show_template), N, 'template')
1  actionpack/examples/views/_collection.erb
... ...
@@ -1 +0,0 @@
1  
-<%= collection %>
1  actionpack/examples/views/_hello.erb
... ...
@@ -1 +0,0 @@
1  
-Hello
10  actionpack/examples/views/_many_partials.erb
... ...
@@ -1,10 +0,0 @@
1  
-<%= render :partial => '/hello' %>
2  
-<%= render :partial => '/hello' %>
3  
-<%= render :partial => '/hello' %>
4  
-<%= render :partial => '/hello' %>
5  
-<%= render :partial => '/hello' %>
6  
-<%= render :partial => '/hello' %>
7  
-<%= render :partial => '/hello' %>
8  
-<%= render :partial => '/hello' %>
9  
-<%= render :partial => '/hello' %>
10  
-<%= render :partial => '/hello' %>
10  actionpack/examples/views/_partial.erb
... ...
@@ -1,10 +0,0 @@
1  
-<%= "Hello" %>
2  
-<%= "Hello" %>
3  
-<%= "Hello" %>
4  
-<%= "Hello" %>
5  
-<%= "Hello" %>
6  
-<%= "Hello" %>
7  
-<%= "Hello" %>
8  
-<%= "Hello" %>
9  
-<%= "Hello" %>
10  
-<%= "Hello" %>
1  actionpack/examples/views/layouts/alt.html.erb
... ...
@@ -1 +0,0 @@
1  
-+ <%= yield %> +
1  actionpack/examples/views/layouts/kaigi.html.erb
... ...
@@ -1 +0,0 @@
1  
-Hello <%= yield %> Goodbye
1  actionpack/examples/views/template.html.erb
... ...
@@ -1 +0,0 @@
1  
-Hello

0 notes on commit 5f6e788

Please sign in to comment.
Something went wrong with that request. Please try again.