Sha256: f548d113df9239a007ebc3d6f5060eff8dc1f581afb64cece462aab357ff3749
Contents?: true
Size: 1.96 KB
Versions: 1
Compression:
Stored size: 1.96 KB
Contents
module EacLauncher class Context include ::Eac::SimpleCache DEFAULT_PROJECTS_ROOT = '.'.freeze DEFAULT_SETTINGS_FILE = ::File.join(ENV['HOME'], '.config', 'eac_launcher', 'settings.yml') DEFAULT_CACHE_ROOT = ::File.join(ENV['HOME'], '.cache', 'eac_launcher') class << self attr_writer :current def current @current ||= default end def default @default ||= Context.new end end attr_reader :root, :settings, :cache_root attr_accessor :publish_options def initialize(options = {}) @options = options.with_indifferent_access @root = ::EacLauncher::Instances::Base.new(build_option(:projects_root), nil) @settings = ::EacLauncher::Context::Settings.new(build_option(:settings_file)) @cache_root = build_option(:cache_root) @publish_options = { new: false, confirm: false, stereotype: nil } end def instance(to_root_path) instances.find { |i| i.to_root_path == to_root_path } end private def build_option(key) @options[key] || env_option(key) || default_option(key) end def env_option(key) ENV["EAC_LAUNCHER_#{key}".underscore.upcase] end def default_option(key) self.class.const_get("DEFAULT_#{key}".underscore.upcase) end 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
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
eac_launcher-0.1.5 | lib/eac_launcher/context.rb |