Class: EacLauncher::Instances::RunnerHelper

Inherits:
EacRubyUtils::Console::DocoptRunner
  • Object
show all
Includes:
EacRubyUtils::Console::Speaker
Defined in:
lib/eac_launcher/instances/runner_helper.rb

Instance Method Summary collapse

Instance Method Details

#contextObject



11
12
13
# File 'lib/eac_launcher/instances/runner_helper.rb', line 11

def context
  @context ||= ::EacLauncher::Context.current
end

#find_instance(instance_name) ⇒ Object



15
16
17
# File 'lib/eac_launcher/instances/runner_helper.rb', line 15

def find_instance(instance_name)
  context.instances.find { |i| i.name == instance_name }
end

#find_instance!(instance_path) ⇒ Object



19
20
21
22
23
24
# File 'lib/eac_launcher/instances/runner_helper.rb', line 19

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

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

#instance_label(instance) ⇒ Object



40
41
42
# File 'lib/eac_launcher/instances/runner_helper.rb', line 40

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

#instance_stereotypes(instance) ⇒ Object



36
37
38
# File 'lib/eac_launcher/instances/runner_helper.rb', line 36

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

#instancesObject



26
27
28
29
30
31
32
33
34
# File 'lib/eac_launcher/instances/runner_helper.rb', line 26

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