Sha256: c5a905fe075c1c059edb1427b6619de13469a9c690609eb3e6a41b358a957a57

Contents?: true

Size: 989 Bytes

Versions: 1

Compression:

Stored size: 989 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.remove(removed)
          repository.add(added)
          system('clear 2>/dev/null') || system('cls 2>/dev/null')

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
retest-0.8.0.pre2 lib/retest.rb