Sha256: b0faf68452a20931eaf5648031fb6fb45fd66ce79278c8a6d738efff78c424fe

Contents?: true

Size: 997 Bytes

Versions: 7

Compression:

Stored size: 997 Bytes

Contents

# frozen_string_literal: true

require 'avm/core_ext'

module Avm
  module Launcher
    module Instances
      class RunnerHelper
        def context
          @context ||= ::Avm::Launcher::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

7 entries across 7 versions & 1 rubygems

Version Path
avm-tools-0.103.0 lib/avm/launcher/instances/runner_helper.rb
avm-tools-0.102.2 lib/avm/launcher/instances/runner_helper.rb
avm-tools-0.102.1 lib/avm/launcher/instances/runner_helper.rb
avm-tools-0.102.0 lib/avm/launcher/instances/runner_helper.rb
avm-tools-0.101.0 lib/avm/launcher/instances/runner_helper.rb
avm-tools-0.100.0 lib/avm/launcher/instances/runner_helper.rb
avm-tools-0.99.1 lib/avm/launcher/instances/runner_helper.rb