From 6ba8ca10ae2f678bef3e1a2bfa68ef810dd2f06e Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Tue, 2 May 2023 17:19:55 +0400 Subject: [PATCH] Add class Diversipub::SinatraApp --- diversipub.gemspec | 2 ++ lib/diversipub.rb | 3 +++ lib/diversipub/sinatra_app.rb | 23 +++++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 lib/diversipub/sinatra_app.rb diff --git a/diversipub.gemspec b/diversipub.gemspec index d8a8a83..cb514b6 100644 --- a/diversipub.gemspec +++ b/diversipub.gemspec @@ -41,6 +41,8 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename f } + spec.add_runtime_dependency 'sinatra', '~> 3.0', '>= 3.0.6' + spec.add_development_dependency 'pry', '~> 0.14' spec.add_development_dependency 'rake', '~> 13.0' end diff --git a/lib/diversipub.rb b/lib/diversipub.rb index f499c79..8fdce2b 100644 --- a/lib/diversipub.rb +++ b/lib/diversipub.rb @@ -1,4 +1,7 @@ # frozen_string_literal: true +require 'sinatra/base' + require_relative 'diversipub/main' +require_relative 'diversipub/sinatra_app' require_relative 'diversipub/version' diff --git a/lib/diversipub/sinatra_app.rb b/lib/diversipub/sinatra_app.rb new file mode 100644 index 0000000..8434ec1 --- /dev/null +++ b/lib/diversipub/sinatra_app.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Diversipub + ## + # Sinatra web application. + # + class SinatraApp < Sinatra::Base + set :environment, :production + set :root, File.expand_path('../..', __dir__).freeze + set :views, nil + set :public_folder, nil + + def initialize(main) + super() + @main = main + end + + class << self + # Disable default Sinatra servers & middleware. + alias new new! + end + end +end