Class: GG::DemoApp
Defined Under Namespace
Classes: Custom
Instance Method Summary collapse
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/gg/demo_app.rb', line 15 def call(env) case env[ 'PATH_INFO' ] when '/' response = Rack::Response.new response.write GG.render( 'slim/index.slim' ) response when '/demo' log_stuff [ 200, { 'Content-Type' => 'text/html' }, [ "<h1>GG</h1><p>This is a demo of GG</p>"] ] when '/inline_demo' log_stuff [ 200, { 'Content-Type' => 'text/html' }, [ %q{ <head> </head> <body> <h1>GG</h1> <p>This is a demo of GG</p> <div style="border:1px dotted silver;padding: 10px;background-color:#F0F0F0;"> <!--gg--> </div> <p>This is a footer</p> </body> } ] ] when '/demo.txt' log_stuff [ 200, { 'Content-Type' => 'text/plain' }, [ "This is a demo of GG (output goes to console using awesome_print gem)"] ] when '/env' gg env [ 200, { 'Content-Type' => 'text/html' }, [ "<h1>GG</h1><p>This is a dump of request.env and should contain some recursion</p><!--gg-->"] ] when '/limit' hash = (1..10).inject({}) do |memo, value| memo[value] = (1..20).inject({}) do |memo, value| memo[value] = rand(1..10) memo end memo end gg hash [ 200, { 'Content-Type' => 'text/html' }, [ "<h1>GG</h1><p>This is a dump of request.env and should contain some recursion</p><!--gg-->"] ] else [ 404, { 'Content-Type' => 'text/html' }, [ "<h1>Page Not Found</h1>" ] ] end end |
#log_stuff ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/gg/demo_app.rb', line 59 def log_stuff gg Object.new gg 123 gg 12.5 gg Object.new, true, :symbol, 'String' gg true gg false gg nil gg /^http[:]/ gg "Hello World <Escaped>" gg [ 1, "two", :three, [ 4, 5, 6 ] ] hash = { make: 'Lamborghini', model: 'Aventador', color: 'yellow', tags: [ 'car', 'exotic' ], wheels: { front: 22, rear: 24 } } gg hash custom = Custom.new( 'cube', [ 5, 3 ], 'yellow' ) gg custom recursive_hash = { a: 'alpha', b: 'bravo' } recursive_array = [ :a, :b, recursive_hash ] recursive_hash[ :array ] = recursive_array recursive_object = Object.new recursive_object.instance_variable_set :@hash, recursive_hash recursive_object.instance_variable_set :@array, recursive_array gg recursive_hash gg recursive_array gg recursive_object end |