Sha256: 82a0bf10cf8c23542dc2fe08a6f610a6ffa879e8a23978c00b13472e02a89bc5

Contents?: true

Size: 1.13 KB

Versions: 9

Compression:

Stored size: 1.13 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_instance(instance_name)
        context.instances.find { |i| i.name == instance_name }
      end

      def find_instance!(instance_path)
        instance = find_instance(instance_path)
        return instance if instance

        raise "Instance not found in \"#{instance_path}\""
      end

      def instances
        if options['--all']
          context.instances
        elsif options['--pending']
          context.pending_instances
        else
          options['<instance_path>'].map { |p| find_instance!(p) }
        end
      end

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

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
eac_launcher-0.7.0 lib/eac_launcher/instances/runner_helper.rb
eac_launcher-0.6.8 lib/eac_launcher/instances/runner_helper.rb
eac_launcher-0.6.7 lib/eac_launcher/instances/runner_helper.rb
eac_launcher-0.6.6 lib/eac_launcher/instances/runner_helper.rb
eac_launcher-0.6.5 lib/eac_launcher/instances/runner_helper.rb
eac_launcher-0.6.4 lib/eac_launcher/instances/runner_helper.rb
eac_launcher-0.6.3 lib/eac_launcher/instances/runner_helper.rb
eac_launcher-0.6.2 lib/eac_launcher/instances/runner_helper.rb
eac_launcher-0.6.1 lib/eac_launcher/instances/runner_helper.rb