Class: Guard::JasmineHeadlessWebkit

Inherits:
Guard
  • Object
show all
Defined in:
lib/guard/jasmine-headless-webkit.rb,
lib/guard/jasmine-headless-webkit/runner.rb

Defined Under Namespace

Classes: Runner

Constant Summary collapse

DEFAULT_EXTENSIONS =
%w{js coffee}
ALL_SPECS_MESSAGE =
"Guard::JasmineHeadlessWebkit running all specs..."
SOME_SPECS_MESSAGE =
"Guard::JasmineHeadlessWebkit running the following: %s"
DEFAULT_OPTIONS =
{
  :all_on_start => true,
  :run_before => false,
  :valid_extensions => DEFAULT_EXTENSIONS
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(watchers = [], options = {}) ⇒ JasmineHeadlessWebkit

Returns a new instance of JasmineHeadlessWebkit.



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/guard/jasmine-headless-webkit.rb', line 22

def initialize(watchers = [], options = {})
  super

  @options = DEFAULT_OPTIONS.merge(options)
  @filtered_options = options
  DEFAULT_OPTIONS.keys.each { |key| @filtered_options.delete(key) }

  UI.deprecation ":run_before is deprecated. Use guard-shell to do something beforehand. This will be removed in a future release." if @options[:run_before]

  @files_to_rerun = []
end

Instance Attribute Details

#files_to_rerunObject (readonly)

Returns the value of attribute files_to_rerun.



14
15
16
# File 'lib/guard/jasmine-headless-webkit.rb', line 14

def files_to_rerun
  @files_to_rerun
end

Instance Method Details

#reloadObject



39
40
41
42
# File 'lib/guard/jasmine-headless-webkit.rb', line 39

def reload
  @files_to_rerun = []
  UI.info "Resetting Guard::JasmineHeadlessWebkit failed files..."
end

#run_allObject



44
45
46
47
48
49
50
# File 'lib/guard/jasmine-headless-webkit.rb', line 44

def run_all
  run_something_and_rescue do
    @ran_before = false

    run_for_failed_files if run_all_things_before
  end
end

#run_on_change(paths) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/guard/jasmine-headless-webkit.rb', line 52

def run_on_change(paths)
  run_something_and_rescue do
    paths = filter_paths(paths)
    @ran_before = false
    if run_all_things_before
      @ran_before = true
      if !paths.empty?
        paths = (paths + @files_to_rerun).uniq

        run_for_failed_files(paths)
      else
        run_all
      end
    end
  end
end

#startObject



34
35
36
37
# File 'lib/guard/jasmine-headless-webkit.rb', line 34

def start
  UI.info "Guard::JasmineHeadlessWebkit is running."
  run_all if @options[:all_on_start]
end