Sha256: 139da464f1426a6c82d0754d008e4e1c5b2ff75cebbbc57ac3cae1854fcfe0a5

Contents?: true

Size: 931 Bytes

Versions: 19

Compression:

Stored size: 931 Bytes

Contents

module Mina
  class Runner
    attr_reader :commands, :backend
    include Configuration::DSL

    def initialize(commands, backend)
      fail 'You must specify execution mode' if execution_mode.nil?
      fail 'Unsuported execution mode (pretty on windows)' if unsuported_execution_mode?
      @backend = backend
      @commands = commands
    end

    def run
      Mina::Runner.const_get(class_name_for(execution_mode)).new(script).run
    end

    def execution_mode
      @execution_mode ||=
      if fetch(:simulate)
        :printer
      else
        fetch(:execution_mode)
      end
    end

    private

    def script
      Mina::Backend.const_get(class_name_for(backend)).new(commands).prepare
    end

    def unsuported_execution_mode?
      execution_mode == :pretty && Gem::Platform.local.os == :windows
    end

    def class_name_for(symbol)
      symbol.to_s.split('_').map(&:capitalize).join
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
mina-1.2.4 lib/mina/runner.rb
mina-1.2.3 lib/mina/runner.rb
mina-1.2.2 lib/mina/runner.rb
mina-1.2.1 lib/mina/runner.rb
mina-1.2.0 lib/mina/runner.rb
mina-1.1.1 lib/mina/runner.rb
mina-1.1.0 lib/mina/runner.rb
mina-1.0.7 lib/mina/runner.rb
mina-1.0.6 lib/mina/runner.rb
mina-1.0.5 lib/mina/runner.rb
mina-1.0.4 lib/mina/runner.rb
mina-1.0.3 lib/mina/runner.rb
mina-1.0.2 lib/mina/runner.rb
mina-1.0.0 lib/mina/runner.rb
mina-1.0.0.rc2 lib/mina/runner.rb
mina-1.0.0.beta5 lib/mina/runner.rb
mina-1.0.0.beta4 lib/mina/runner.rb
mina-1.0.0.beta3 lib/mina/runner.rb
mina-1.0.0.beta2 lib/mina/runner.rb