Sha256: d4e79c77e3e08ad5a8904f73b5f37ca4b064adfd27b5829e6c6d104dfb10aad6

Contents?: true

Size: 754 Bytes

Versions: 5

Compression:

Stored size: 754 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

5 entries across 5 versions & 1 rubygems

Version Path
page-object-0.6.6 features/sample-app/sample_app.rb
page-object-0.6.5 features/sample-app/sample_app.rb
page-object-0.6.4 features/sample-app/sample_app.rb
page-object-0.6.3 features/sample-app/sample_app.rb
page-object-0.6.2 features/sample-app/sample_app.rb