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_instances(instance_name) ⇒ Object



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

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

#instance_label(instance) ⇒ Object



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

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

#instance_match?(instance, instance_name) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#instance_stereotypes(instance) ⇒ Object



33
34
35
# File 'lib/eac_launcher/instances/runner_helper.rb', line 33

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

#instancesObject



23
24
25
26
27
28
29
30
31
# File 'lib/eac_launcher/instances/runner_helper.rb', line 23

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