1
0
Fork 0

Add class Diversipub::RackApp

This commit is contained in:
Alex Kotov 2023-05-02 17:38:54 +04:00
parent 6ba8ca10ae
commit 4a2820f081
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
3 changed files with 31 additions and 0 deletions

View File

@ -41,6 +41,7 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename f }
spec.add_runtime_dependency 'rack', '~> 2.2', '>= 2.2.7'
spec.add_runtime_dependency 'sinatra', '~> 3.0', '>= 3.0.6'
spec.add_development_dependency 'pry', '~> 0.14'

View File

@ -1,7 +1,9 @@
# frozen_string_literal: true
require 'rack'
require 'sinatra/base'
require_relative 'diversipub/main'
require_relative 'diversipub/rack_app'
require_relative 'diversipub/sinatra_app'
require_relative 'diversipub/version'

View File

@ -0,0 +1,28 @@
# frozen_string_literal: true
module Diversipub
##
# Rack web application.
#
class RackApp
def initialize(sinatra_app)
@sinatra_app = sinatra_app
end
def call(env)
to_app.call env
end
def to_app
@to_app ||= builder.to_app
end
private
def builder
@builder ||= Rack::Builder.new.tap do |builder|
builder.run @sinatra_app
end
end
end
end