Sha256: a0813096f9bd0a5852a826f0515c5c2549b7e89bd0eec0f78fa17d1222fdb6ec

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

require 'guard/compat/plugin'

require 'guard/busted/options'
require 'guard/busted/runner'
require 'guard/busted/utils'

module Guard
  # Plugin for 'guard' which starts 'busted' (lua unit testing framework) if a change is detected.
  class Busted < Plugin
    include BustedUtils
    attr_reader :options, :runner

    # Initializes a Guard plugin.
    def initialize(options = {})
      super

      @options = Guard::BustedOptions::DEFAULTS.merge(options)
      @runner = Guard::BustedRunner.new(@options)
    end

    # Called once when Guard starts.
    def start
      check_if_busted_exist
      run_all if @options[:run_all_on_start]
    end

    # Called when just `enter` is pressed
    def run_all
      @runner.run_all
    end

    # Called on file(s) modifications that the Guard plugin watches.
    def run_on_modifications(paths)
      @runner.run(paths)
    end

    private

    def check_if_busted_exist
      return unless which('busted').nil?

      puts 'Busted not found. Use :cmd option or ' \
           'install `busted` via `luarocks install busted --local`'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
guard-busted-0.1.2 lib/guard/busted.rb