Sha256: c7e8ce13779c5d30be7404dfd4a836452c5278f6543f5c2a4501809368cc3330

Contents?: true

Size: 911 Bytes

Versions: 77

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

77 entries across 77 versions & 1 rubygems

Version Path
inferno_core-0.3.9 lib/inferno/utils/static_assets.rb
inferno_core-0.3.8 lib/inferno/utils/static_assets.rb
inferno_core-0.3.7 lib/inferno/utils/static_assets.rb
inferno_core-0.3.6 lib/inferno/utils/static_assets.rb
inferno_core-0.3.5 lib/inferno/utils/static_assets.rb
inferno_core-0.3.4 lib/inferno/utils/static_assets.rb
inferno_core-0.3.3 lib/inferno/utils/static_assets.rb
inferno_core-0.3.2 lib/inferno/utils/static_assets.rb
inferno_core-0.3.1 lib/inferno/utils/static_assets.rb
inferno_core-0.3.0 lib/inferno/utils/static_assets.rb
inferno_core-0.3.0.rc1 lib/inferno/utils/static_assets.rb
inferno_core-0.2.0 lib/inferno/utils/static_assets.rb
inferno_core-0.2.0.rc4 lib/inferno/utils/static_assets.rb
inferno_core-0.2.0.rc3 lib/inferno/utils/static_assets.rb
inferno_core-0.2.0.rc2 lib/inferno/utils/static_assets.rb
inferno_core-0.2.0.rc1 lib/inferno/utils/static_assets.rb
inferno_core-0.1.4.pre lib/inferno/utils/static_assets.rb