class Isomorfeus::AssetManager::Portfolio

Public Class Methods

get_load_path_entries(path, filter) click to toggle source
# File lib/isomorfeus/asset_manager/portfolio.rb, line 4
def self.get_load_path_entries(path, filter)
  path_entries = []
  return [] unless Dir.exist?(path)
  dir_entries = Dir.entries(path)
  dir_entries.each do |entry|
    next if entry == '.'
    next if entry == '..'
    next unless entry
    absolute_path = File.join(path, entry)
    if File.directory?(absolute_path)
      more_path_entries = get_load_path_entries(absolute_path, filter)
      path_entries.push(*more_path_entries) if more_path_entries.size > 0
    elsif (absolute_path.end_with?('.rb') || absolute_path.end_with?('.js')) && File.file?(absolute_path)
      push_entry = true
      if filter && filter.size > 0
        filter.each do |filter_entry|
          push_entry = false if absolute_path.end_with?(filter_entry)
        end
      end
      path_entries.push(absolute_path) if push_entry
    end
  end
  path_entries
end
get_load_paths_json(*filter) click to toggle source
# File lib/isomorfeus/asset_manager/portfolio.rb, line 29
def self.get_load_paths_json(*filter)
  cwd = Dir.pwd

  load_paths = Opal.paths.uniq
  load_path_entries = []

  load_paths.each do |path|
    next if path.start_with?(cwd)
    more_path_entries = get_load_path_entries(path, filter)
    load_path_entries.push(*more_path_entries) if more_path_entries.size > 0
  end

  cache_obj = { 'opal_load_paths' => load_paths, 'opal_load_path_entries' => load_path_entries }
  Oj.dump(cache_obj, mode: :strict, indent: 2)
end