Sha256: 24d4e4e1f0d87539643ab1e073b8845cc02b2f20b4cede2af196449f62560528

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/console/docopt_runner'
require 'eac_ruby_utils/console/speaker'

module Avm
  module Launcher
    module Instances
      class RunnerHelper < ::EacRubyUtils::Console::DocoptRunner
        def context
          @context ||= ::EacLauncher::Context.current
        end

        def find_instances(instance_name)
          context.instances.select { |instance| instance_match?(instance, instance_name) }
        end

        def instance_match?(instance, instance_name)
          ::File.fnmatch?(instance_name, instance.name)
        end

        def instances
          if parsed.all?
            context.instances
          elsif parsed.pending?
            context.pending_instances
          else
            parsed.instance_path.flat_map { |p| find_instances(p) }
          end
        end

        def instance_stereotypes(instance)
          instance.stereotypes.map(&:label).join(', ')
        end

        def instance_label(instance)
          "#{instance.name} [#{instance_stereotypes(instance)}]"
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
avm-tools-0.97.0 lib/avm/launcher/instances/runner_helper.rb
avm-tools-0.96.0 lib/avm/launcher/instances/runner_helper.rb