Sha256: 9b78ada347f63af0c882304cedcd8f344f9ae923bc527d85f0e7b3f915178caa

Contents?: true

Size: 751 Bytes

Versions: 13

Compression:

Stored size: 751 Bytes

Contents

require 'rubygems'
require 'rack'
require 'webrick'


class SampleApp

  def self.start(host, port)
    Rack::Handler::WEBrick.run new,
                               :Host => host,
                               :Port => port,
                               :Logger => ::WEBrick::Log.new('/dev/null'),
                               :AccessLog => [nil, nil]
  end

  def initialize
    @public = Rack::File.new(File.expand_path("../public", __FILE__))
  end

  def call(env)
    req = Rack::Request.new(env)

    case req.path
    when "/"
      [200, {}, ["Sample Application"]]
    when "/compute"
      sleep 3
      resp = eval(req.params['calculator-expression']).to_s
      [200, {}, [resp]]
    else
      @public.call(env)
    end
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
page-object-0.8.1 features/sample-app/sample_app.rb
page-object-0.8 features/sample-app/sample_app.rb
page-object-0.7.6 features/sample-app/sample_app.rb
page-object-0.7.5.1 features/sample-app/sample_app.rb
page-object-0.7.5 features/sample-app/sample_app.rb
page-object-0.7.4 features/sample-app/sample_app.rb
page-object-0.7.3 features/sample-app/sample_app.rb
page-object-0.7.2 features/sample-app/sample_app.rb
page-object-0.7.1 features/sample-app/sample_app.rb
page-object-0.7.0 features/sample-app/sample_app.rb
page-object-0.6.9 features/sample-app/sample_app.rb
page-object-0.6.8 features/sample-app/sample_app.rb
page-object-0.6.7 features/sample-app/sample_app.rb