Sha256: f22bfe1488b6900e5144c238c10408ee2ba266f0d5d1bd38bb1e20662ddeefdd

Contents?: true

Size: 859 Bytes

Versions: 36

Compression:

Stored size: 859 Bytes

Contents

class KuberKit::ShellLauncher::Launcher
  StrategyNotFoundError = Class.new(KuberKit::NotFoundError)

  include KuberKit::Import[
    "core.service_store",
  ]

  Contract KuberKit::Shell::AbstractShell, Symbol => Any
  def call(shell, strategy_name)
    launcher = get_strategy(strategy_name)

    raise StrategyNotFoundError, "Can't find strategy with name #{strategy_name}" if launcher.nil?

    launcher.call(shell)
  end

  def register_strategy(strategy_name, strategy)
    @@strategies ||= {}

    if !strategy.is_a?(KuberKit::ShellLauncher::Strategies::Abstract)
      raise ArgumentError.new("should be an instance of KuberKit::ShellLauncher::Strategies::Abstract, got: #{strategy.inspect}")
    end

    @@strategies[strategy_name] = strategy
  end

  def get_strategy(strategy_name)
    @@strategies ||= {}
    @@strategies[strategy_name]
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
kuber_kit-1.3.9 lib/kuber_kit/shell_launcher/launcher.rb
kuber_kit-1.3.8 lib/kuber_kit/shell_launcher/launcher.rb
kuber_kit-1.3.7 lib/kuber_kit/shell_launcher/launcher.rb
kuber_kit-1.1.8 lib/kuber_kit/shell_launcher/launcher.rb
kuber_kit-1.3.6 lib/kuber_kit/shell_launcher/launcher.rb
kuber_kit-1.1.7 lib/kuber_kit/shell_launcher/launcher.rb
kuber_kit-1.3.5 lib/kuber_kit/shell_launcher/launcher.rb
kuber_kit-1.3.4 lib/kuber_kit/shell_launcher/launcher.rb
kuber_kit-1.1.6 lib/kuber_kit/shell_launcher/launcher.rb
kuber_kit-1.3.3 lib/kuber_kit/shell_launcher/launcher.rb
kuber_kit-1.3.2 lib/kuber_kit/shell_launcher/launcher.rb
kuber_kit-1.1.5 lib/kuber_kit/shell_launcher/launcher.rb
kuber_kit-1.3.1 lib/kuber_kit/shell_launcher/launcher.rb
kuber_kit-1.3.0 lib/kuber_kit/shell_launcher/launcher.rb
kuber_kit-1.1.4 lib/kuber_kit/shell_launcher/launcher.rb
kuber_kit-1.2.7 lib/kuber_kit/shell_launcher/launcher.rb
kuber_kit-1.2.6 lib/kuber_kit/shell_launcher/launcher.rb
kuber_kit-1.2.5 lib/kuber_kit/shell_launcher/launcher.rb
kuber_kit-1.2.4 lib/kuber_kit/shell_launcher/launcher.rb
kuber_kit-1.2.2 lib/kuber_kit/shell_launcher/launcher.rb