Sha256: f7e9e742805623daa2a762437f05bf720d7ac754db13316ce8afab0e9bf86576

Contents?: true

Size: 1016 Bytes

Versions: 3

Compression:

Stored size: 1016 Bytes

Contents

require 'listen'
require 'string/similarity'

require "retest/version"
require "retest/runner"
require "retest/repository"
require "retest/test_options"
require "retest/options"
require "retest/version_control"

module Retest
  class Error < StandardError; end

  class << self
    def start(command)
      puts "Launching Retest..."

      build(
        runner: Runner.for(command),
        repository: Repository.new(files: VersionControl.files)
      ).start

      puts "Ready to refactor! You can make file changes now"
    end

    def build(runner:, repository:)
      Listen.to('.', only: /\.rb$/, relative: true) do |modified, added, removed|
        begin
          repository.add(added)
          repository.remove(removed)
          runner.remove(removed)
          system('clear 2>/dev/null') || system('cls 2>/dev/null')

          runner.run repository.find_test (modified + added).first
        rescue => e
          puts "Something went wrong: #{e.message}"
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
retest-0.8.2 lib/retest.rb
retest-0.8.1 lib/retest.rb
retest-0.8.0 lib/retest.rb