Sha256: 2b0bf5e8b732b1031d47b9e1a6a99717786fd0569ec457f09d42ff0b6cbea96f

Contents?: true

Size: 726 Bytes

Versions: 15

Compression:

Stored size: 726 Bytes

Contents

require 'erb'
require 'pathname'
require 'hanami/environment'
require 'hanami/utils/string'

module Hanami
  # @api private
  class Welcome
    # @api private
    def initialize(_app)
      @root = Pathname.new(__dir__).join('templates').realpath
    end

    # @api private
    def call(env)
      @request_path = env['REQUEST_PATH'] || ''
      @body = [ERB.new(@root.join('welcome.html.erb').read).result(binding)]

      [200, {}, @body]
    end

    # @api private
    def application_name
      application_class.app_name
    end

    private

    # @api private
    def application_class
      Hanami.configuration.apps do |app|
        return app if @request_path.include?(app.path_prefix)
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
hanami-1.3.2 lib/hanami/welcome.rb
hanami-1.3.1 lib/hanami/welcome.rb
hanami-1.3.0 lib/hanami/welcome.rb
hanami-1.3.0.beta1 lib/hanami/welcome.rb
hanami-1.2.0 lib/hanami/welcome.rb
hanami-1.2.0.rc2 lib/hanami/welcome.rb
hanami-1.2.0.rc1 lib/hanami/welcome.rb
hanami-1.2.0.beta2 lib/hanami/welcome.rb
hanami-1.2.0.beta1 lib/hanami/welcome.rb
hanami-1.1.1 lib/hanami/welcome.rb
hanami-1.1.0 lib/hanami/welcome.rb
hanami-1.1.0.rc1 lib/hanami/welcome.rb
hanami-1.1.0.beta3 lib/hanami/welcome.rb
hanami-1.1.0.beta2 lib/hanami/welcome.rb
hanami-1.1.0.beta1 lib/hanami/welcome.rb