Sha256: 0ecad0f156c5dd72b72c973b8acb63dd65d7d79f1a4ec0e7e08ebbfbf42e555a
Contents?: true
Size: 1.51 KB
Versions: 6
Compression:
Stored size: 1.51 KB
Contents
# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details. # frozen_string_literal: true module Contrast module Utils # This module is to help perform sometimes necessary tasks specific to Sinatra module SinatraHelper SINATRA_VIEWS = [ ['public/stylesheets', '*.scss', %w[SASS]], ['views', '*.html', %w[HTML5]], ['views', '*.html.erb', %w[HTML5 ERB]], ['views', '*.html.haml', %w[HTML5 HAML]], ['public', '*.html', %w[HTML5]] ].cs__freeze def self.app_class @_app_class ||= begin return nil unless defined?(Sinatra) && defined?(Sinatra::Base) sinatra_layers = ObjectSpace.each_object(Sinatra::Base).to_a result_layer = sinatra_layers.find { |layer| layer.app.nil? } result_layer end end def self.scannable_view_dirs @_scannable_view_dirs ||= begin views = SINATRA_VIEWS.dup views << [view_directory, '*.erb', %w[HTML5 ERB]] if view_directory views << [view_directory, '*.haml', %w[HTML5 HAML]] if view_directory views << [public_directory, '*.html', %w[HTML5]] if public_directory views end end def self.view_directory @_view_directory ||= begin app_class&.settings&.views end end def self.public_directory @_public_directory ||= begin app_class&.settings&.public_dir end end end end end
Version data entries
6 entries across 6 versions & 1 rubygems