Class: SimpleCov::CLI::Watch::Narrator

Inherits:
Object
  • Object
show all
Defined in:
lib/simplecov/cli/watch/narrator.rb

Instance Method Summary collapse

Constructor Details

#initialize(stdout, root) ⇒ Narrator

Returns a new instance of Narrator.



7
8
9
10
# File 'lib/simplecov/cli/watch/narrator.rb', line 7

def initialize(stdout, root)
  @stdout = stdout
  @root = root
end

Instance Method Details



12
13
14
15
16
17
# File 'lib/simplecov/cli/watch/narrator.rb', line 12

def banner(server, count)
  host = Serve.url_host(server.addr.fetch(3))
  @stdout.puts("watching #{count} file#{"s" unless count.eql?(1)}, " \
               "serving http://#{host}:#{server.addr.fetch(1)}/")
  @stdout.puts("Press Ctrl-C to stop.")
end

#change(changed, plan) ⇒ Object



19
20
21
22
23
24
# File 'lib/simplecov/cli/watch/narrator.rb', line 19

def change(changed, plan)
  named = name(changed)
  return @stdout.puts("#{named} changed, no recorded test touches it") unless plan.fetch(:run)

  @stdout.print("#{named} changed, #{action(plan.fetch(:tests))}...")
end

#failed_refreshObject



33
34
35
# File 'lib/simplecov/cli/watch/narrator.rb', line 33

def failed_refresh
  @stdout.puts(" the report did not regenerate")
end

#result(before, after) ⇒ Object



26
27
28
29
30
31
# File 'lib/simplecov/cli/watch/narrator.rb', line 26

def result(before, after)
  return @stdout.puts unless after

  delta = before ? format(" (%+.2f%%)", after - before) : ""
  @stdout.puts(format(" %.2f%%", after) + delta)
end

#stoppingObject



37
38
39
# File 'lib/simplecov/cli/watch/narrator.rb', line 37

def stopping
  @stdout.puts("\nsimplecov watch: stopping")
end