Sha256: 761f39d6c0f4191589d938b671e16a16682f642e259181702b73a2b030d33a8e

Contents?: true

Size: 793 Bytes

Versions: 35

Compression:

Stored size: 793 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(RUBY_PLATFORM =~ /mswin|mingw/ ? 'NUL:' : '/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

35 entries across 35 versions & 4 rubygems

Version Path
page-object-1.2.0 features/sample-app/sample_app.rb
page-object-1.1.1 features/sample-app/sample_app.rb
page_object-1.1.3 features/sample-app/sample_app.rb
page_object-1.1.2 features/sample-app/sample_app.rb
page_object-1.1.1 features/sample-app/sample_app.rb
page-object-1.1.0 features/sample-app/sample_app.rb
page-object-lds-0.0.14 features/sample-app/sample_app.rb
page-object-lds-0.0.13 features/sample-app/sample_app.rb
page-object-lds-0.0.12 features/sample-app/sample_app.rb
page-object-lds-0.0.11 features/sample-app/sample_app.rb
page-object-lds-0.0.1 features/sample-app/sample_app.rb
page-object-1.0.3 features/sample-app/sample_app.rb
meeane-page-object-0.1.11 features/sample-app/sample_app.rb
page-object-1.0.2 features/sample-app/sample_app.rb
page-object-1.0.1 features/sample-app/sample_app.rb
page-object-1.0 features/sample-app/sample_app.rb
page-object-0.9.8 features/sample-app/sample_app.rb
page-object-0.9.7 features/sample-app/sample_app.rb
page-object-0.9.6 features/sample-app/sample_app.rb
page-object-0.9.5 features/sample-app/sample_app.rb