module EacLauncher class Context include ::Eac::SimpleCache class << self def current default end def default @default ||= Context.new( ENV['EAC_LAUNCHER_PROJECTS_ROOT'] || '.', ENV['EAC_LAUNCHER_SETTINGS_FILE'] || ::File.join(ENV['HOME'], '.config', 'eac_launcher', 'settings.yml') ) end end attr_reader :root, :settings attr_accessor :publish_options def initialize(projects_root, settings_file) @root = ::EacLauncher::Instances::Base.new(projects_root, nil) @settings = ::EacLauncher::Context::Settings.new(settings_file) @publish_options = { new: false, confirm: false, stereotype: nil } end def cache_root File.join(ENV['HOME'], '.cache', 'cli-utils', 'dev') end private def projects_uncached r = {} instances.each do |i| r[i.basename] ||= [] r[i.basename] << i end r.map { |name, instances| ::EacLauncher::Project.new(name, instances) } .select { |p| include_project?(p) } end def instances_uncached instance_instances(root) end def instance_instances(i) r = [] r << i if include_instance?(i) r += i.children.flat_map { |c| instance_instances(c) } r end def include_project?(p) !@settings.excluded_projects.include?(p.name) end def include_instance?(i) i.project? && !@settings.excluded_projects.include?(i.project_name) end end end