Sha256: d880c37891efb1a30b7e0ab9b291a5a60399e12c05827c6ba8cd06f664dd7178

Contents?: true

Size: 1.07 KB

Versions: 57

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 EacLauncher
  module Instances
    class RunnerHelper < ::EacRubyUtils::Console::DocoptRunner
      include ::EacRubyUtils::Console::Speaker

      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 options['--all']
          context.instances
        elsif options['--pending']
          context.pending_instances
        else
          options['<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

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
avm-tools-0.69.0 lib/eac_launcher/instances/runner_helper.rb
avm-tools-0.68.0 lib/eac_launcher/instances/runner_helper.rb
avm-tools-0.67.0 lib/eac_launcher/instances/runner_helper.rb
avm-tools-0.66.0 lib/eac_launcher/instances/runner_helper.rb
avm-tools-0.65.0 lib/eac_launcher/instances/runner_helper.rb
avm-tools-0.64.2 lib/eac_launcher/instances/runner_helper.rb
avm-tools-0.64.1 lib/eac_launcher/instances/runner_helper.rb
avm-tools-0.64.0 lib/eac_launcher/instances/runner_helper.rb
avm-tools-0.63.0 lib/eac_launcher/instances/runner_helper.rb
avm-tools-0.62.4 lib/eac_launcher/instances/runner_helper.rb
avm-tools-0.62.3 lib/eac_launcher/instances/runner_helper.rb
avm-tools-0.62.2 lib/eac_launcher/instances/runner_helper.rb
avm-tools-0.62.1 lib/eac_launcher/instances/runner_helper.rb
avm-tools-0.62.0 lib/eac_launcher/instances/runner_helper.rb
avm-tools-0.61.0 lib/eac_launcher/instances/runner_helper.rb
avm-tools-0.60.0 lib/eac_launcher/instances/runner_helper.rb
avm-tools-0.59.0 lib/eac_launcher/instances/runner_helper.rb