Sha256: c7e8ce13779c5d30be7404dfd4a836452c5278f6543f5c2a4501809368cc3330

Contents?: true

Size: 911 Bytes

Versions: 68

Compression:

Stored size: 911 Bytes

Contents

module Inferno
  module Utils
    # @private
    class StaticAssets
      class << self
        def static_assets_folder
          @static_assets_folder ||=
            File.expand_path(File.join(inferno_path, 'public'))
        end

        def base_path
          @base_path ||= Application['base_path']
        end

        def public_path
          @public_path ||= "/#{base_path}/public".gsub('//', '/')
        end

        def inferno_path
          @inferno_path ||= File.expand_path(File.join(__dir__, '..'))
        end

        # A hash of urls => file_paths which will be served with `Rack::Static`
        def static_assets_map
          Dir.glob(File.join(static_assets_folder, '*'))
            .each_with_object({}) do |filename, hash|
              hash["#{public_path}/#{File.basename(filename)}"] = filename.delete_prefix(inferno_path)
            end
        end
      end
    end
  end
end

Version data entries

68 entries across 68 versions & 1 rubygems

Version Path
inferno_core-0.5.0 lib/inferno/utils/static_assets.rb
inferno_core-0.4.44 lib/inferno/utils/static_assets.rb
inferno_core-0.4.43 lib/inferno/utils/static_assets.rb
inferno_core-0.4.42 lib/inferno/utils/static_assets.rb
inferno_core-0.4.41 lib/inferno/utils/static_assets.rb
inferno_core-0.4.40 lib/inferno/utils/static_assets.rb
inferno_core-0.4.39 lib/inferno/utils/static_assets.rb
inferno_core-0.4.38 lib/inferno/utils/static_assets.rb
inferno_core-0.4.35 lib/inferno/utils/static_assets.rb
inferno_core-0.4.34 lib/inferno/utils/static_assets.rb
inferno_core-0.4.33 lib/inferno/utils/static_assets.rb
inferno_core-0.4.32 lib/inferno/utils/static_assets.rb
inferno_core-0.4.31 lib/inferno/utils/static_assets.rb
inferno_core-0.4.30 lib/inferno/utils/static_assets.rb
inferno_core-0.4.29 lib/inferno/utils/static_assets.rb
inferno_core-0.4.28 lib/inferno/utils/static_assets.rb
inferno_core-0.4.27 lib/inferno/utils/static_assets.rb
inferno_core-0.4.26 lib/inferno/utils/static_assets.rb
inferno_core-0.4.25 lib/inferno/utils/static_assets.rb
inferno_core-0.4.24 lib/inferno/utils/static_assets.rb