Sha256: cddec0c691a3bc5d4029b2895a35f4623ae4a33d088517aeee0860ca8d86aed8
Contents?: true
Size: 1.35 KB
Versions: 1
Compression:
Stored size: 1.35 KB
Contents
require 'ruby-progressbar' require 'eac_launcher/instances/base' module EacLauncher class Context class InstanceDiscovery attr_reader :instances def initialize(context) @context = context @progress = ::ProgressBar.create(title: 'Instance discovery', total: 1) @instances = path_instances(@context.root, nil) ensure @progress.finish if @progress end private def path_instances(path, parent_instance) update_progress_format(path) on_rescued_path_instances(path) do |r| if path.project? parent_instance = ::EacLauncher::Instances::Base.instanciate(path, parent_instance) r << path end children = path.children update_progress_count(children) r.concat(children.flat_map { |c| path_instances(c, parent_instance) }) end end def on_rescued_path_instances(path) r = [] begin yield(r) if path.included? rescue StandardError => ex warn("#{path}: #{ex}") end r end def update_progress_format(path) @progress.format = "%t (Paths: %c/%C, Current: #{path.logical}) |%B| %a" end def update_progress_count(children) @progress.total += children.count @progress.increment end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
eac_launcher-0.6.0 | lib/eac_launcher/context/instance_discovery.rb |