Sha256: 7286edad891596992b0ab2932f9b472e620d25e19a90237c12f891214a4162df

Contents?: true

Size: 997 Bytes

Versions: 7

Compression:

Stored size: 997 Bytes

Contents

module Koine
  class TestRunner
    class Adapters
      class Custom < BaseRegexp
        def initialize(file_pattern:, command: nil, commands: {})
          super(file_pattern: file_pattern)
          @command = command
          @commands = {}.tap do |hash|
            commands.each do |key, value|
              hash[key.to_sym] = value
            end
          end
        end

        private

        def all_tests(config)
          command(command_for(:all), config)
        end

        def single_file_command(config)
          command(command_for(:file), config)
        end

        def file_line_command(config)
          command(command_for(:line), config)
        end

        def command_for(type)
          @commands.fetch(type).to_s
        end

        def command(template, config)
          template.sub('{command}', @command)
                  .sub('{file}', config.file_path.to_s)
                  .sub('{line}', config.line.to_s)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
koine-test_runner-0.4.0 lib/koine/test_runner/adapters/custom.rb
koine-test_runner-0.3.0 lib/koine/test_runner/adapters/custom.rb
koine-test_runner-0.2.4 lib/koine/test_runner/adapters/custom.rb
koine-test_runner-0.2.3 lib/koine/test_runner/adapters/custom.rb
koine-test_runner-0.2.2 lib/koine/test_runner/adapters/custom.rb
koine-test_runner-0.2.1 lib/koine/test_runner/adapters/custom.rb
koine-test_runner-0.2.0 lib/koine/test_runner/adapters/custom.rb