Class: Guard::Spinach::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/guard/spinach/runner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(paths, opts = nil) ⇒ Runner

Returns a new instance of Runner.



6
7
8
9
# File 'lib/guard/spinach/runner.rb', line 6

def initialize(paths, opts = nil)
  @paths = paths
  @options = opts || {}
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/guard/spinach/runner.rb', line 4

def options
  @options
end

#pathsObject (readonly)

Returns the value of attribute paths.



4
5
6
# File 'lib/guard/spinach/runner.rb', line 4

def paths
  @paths
end

Instance Method Details

#notify(passed) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/guard/spinach/runner.rb', line 32

def notify(passed)
  opts = {title: 'Spinach results', priority: 2}

  if passed
    status = 'Passed'
    image = :success
  else
    status = 'Failed'
    image = :failed
  end

  Guard::Compat::UI.notify(status, opts.merge(image: image))
end

#runObject



11
12
13
14
15
# File 'lib/guard/spinach/runner.rb', line 11

def run
  puts "Running #{paths.empty? ? "all Spinach features" : paths.join(" ")}"
  system(run_command)
  notify($? == 0)
end

#run_commandObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/guard/spinach/runner.rb', line 17

def run_command
  cmd = []
  cmd << @options[:command_prefix] if @options[:command_prefix]
  if @options[:binstubs]
    cmd << 'bin/spinach'
  else
    cmd << 'spinach'
  end
  cmd << paths.join(" ")
  cmd << '-g' if @options[:generate]
  cmd << "-t #{@options[:tags].join(',')}" if @options[:tags] && @options[:tags].any?
  cmd << '-b' if @options[:backtrace]
  cmd.join(" ")
end