lib/eac_launcher/context.rb in eac_launcher-0.3.2 vs lib/eac_launcher/context.rb in eac_launcher-0.4.0
- old
+ new
@@ -18,24 +18,30 @@
@default ||= Context.new
end
end
attr_reader :root, :settings, :cache_root
- attr_accessor :publish_options
+ attr_accessor :publish_options, :recache
def initialize(options = {})
@options = options.with_indifferent_access
- @root = ::EacLauncher::Paths::Logical.new(nil, build_option(:projects_root), '/')
+ @root = ::EacLauncher::Paths::Logical.new(self, nil, build_option(:projects_root), '/')
@settings = ::EacLauncher::Context::Settings.new(build_option(:settings_file))
@cache_root = build_option(:cache_root)
@publish_options = { new: false, confirm: false, stereotype: nil }
+ @instance_manager = ::EacLauncher::Context::InstanceManager.new(self)
+ @recache = false
end
def instance(name)
instances.find { |i| i.name == name }
end
+ def instances
+ @instance_manager.instances
+ end
+
private
def build_option(key)
@options[key] || env_option(key) || default_option(key)
end
@@ -53,32 +59,8 @@
instances.each do |i|
r[i.project_name] ||= []
r[i.project_name] << i
end
r.map { |name, instances| ::EacLauncher::Project.new(name, instances) }
- end
-
- def instances_uncached
- path_instances(root, nil)
- end
-
- def path_instances(path, parent_instance)
- on_rescued_path_instances(path) do |r|
- if path.project?
- parent_instance = ::EacLauncher::Instances::Base.instanciate(path, self, parent_instance)
- r << path if path.included?
- end
- r.concat(path.children.flat_map { |c| path_instances(c, parent_instance) })
- end
- end
-
- def on_rescued_path_instances(path)
- r = []
- begin
- yield(r)
- rescue StandardError => ex
- warn("#{path}: #{ex}")
- end
- r
end
end
end