Class: Inferno::Utils::StaticAssets

Inherits:
Object
  • Object
show all
Defined in:
lib/inferno/utils/static_assets.rb

Class Method Summary collapse

Class Method Details

.base_pathObject



11
12
13
# File 'lib/inferno/utils/static_assets.rb', line 11

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

.inferno_pathObject



19
20
21
# File 'lib/inferno/utils/static_assets.rb', line 19

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

.public_pathObject



15
16
17
# File 'lib/inferno/utils/static_assets.rb', line 15

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

.static_assets_folderObject



6
7
8
9
# File 'lib/inferno/utils/static_assets.rb', line 6

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

.static_assets_mapObject

A hash of urls => file_paths which will be served with ‘Rack::Static`



24
25
26
27
28
29
# File 'lib/inferno/utils/static_assets.rb', line 24

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