rspec_pacman_formatter 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 198bbc3273f050d5b1fa643af9c173b74ce2eaaa77b1c4783e8b45ab86d74a5b
4
- data.tar.gz: fc5469d069cec318ae7a880b7bfbbf5c313050afc70971dff3f9da5abe3be58f
3
+ metadata.gz: e2582e4de37da5bd450f9a7fed3c47b54fc83a1452c6263cf71b91257c77db21
4
+ data.tar.gz: 9f2900b545cdcd3a055c51a8f93bdd9b1077e3ccf4a41cc3062c697cc0d2dab9
5
5
  SHA512:
6
- metadata.gz: 574f40643dc2e055695364d1130bcbbfaa563f6d4dfcf5ee593665a0e0e547fbe020f2c02ba0a78b1a0d9bfeae54edb7ca9db867a255b7fefee475ff3f997209
7
- data.tar.gz: 500e17eb364931ea41fdafb588db12695aa72b34540cc0b7eafac7c32ca01024993ff2251de5773ba3bcfe891d1a2e29131cdb0fe5d46da1d329473b102b2aea
6
+ metadata.gz: 18a38e2999b64e1ae5d98bf498e537d50b7671e46772daafda3c5b1aeeee25c2cbf7705a460c7cd839b002b8f7e751e70660fa36f5424bf7420bb8684d158ff3
7
+ data.tar.gz: d6eadf45a64122cb4209777466ce6ca6ad241a54095a2fb1625d27c8dba6b0dad88303659865cee2e057c047f339de8632d4c6641286b29f3a3eefb66ab809ee
@@ -3,35 +3,34 @@ require 'rspec/core/formatters/base_text_formatter'
3
3
 
4
4
  module RspecPacmanFormatter
5
5
  class Pacman < RSpec::Core::Formatters::BaseTextFormatter
6
- RSpec::Core::Formatters.register(
7
- self, :start, :close, :example_started,
8
- :example_passed, :example_failed, :example_pending
9
- )
6
+ CI_TERMINAL_WIDTH = 80
7
+ RSpec::Core::Formatters.register(self, :start, :close, :example_started,
8
+ :example_passed, :example_failed,
9
+ :example_pending)
10
10
 
11
11
  attr_accessor :progress_line, :failed
12
12
 
13
13
  def initialize(*args)
14
14
  super
15
15
  @progress_line = ''
16
- @failed = 0
17
- @cols = 0
18
- @notification = 0
19
- @repetitions = 0
16
+ @failed = 0
17
+ @notification = 0
18
+ @repetitions = 0
19
+ end
20
+
21
+ def cols
22
+ @cols ||= begin
23
+ width = `tput cols`.chomp.to_i
24
+ width.nil? || width.zero? ? CI_TERMINAL_WIDTH : width
25
+ end
20
26
  end
21
27
 
22
28
  def start(notification)
23
29
  puts 'GAME STARTED'
24
- @cols = terminal_width
25
30
  @notification = notification.count
26
31
  update_progress_line
27
32
  end
28
33
 
29
- def terminal_width
30
- `tput cols`.chomp.to_i
31
- rescue StandardError
32
- CI_TERMINAL_WIDTH
33
- end
34
-
35
34
  def example_started(_)
36
35
  step(Characters::PACMAN)
37
36
  end
@@ -54,12 +53,12 @@ module RspecPacmanFormatter
54
53
  end
55
54
 
56
55
  def update_progress_line
57
- if @notification > @cols
58
- if (@notification / @cols).eql?(@repetitions)
59
- @progress_line = Characters::PACDOT * (@notification - (@cols * @repetitions))
56
+ if @notification > cols
57
+ if (@notification / cols).eql?(@repetitions)
58
+ @progress_line = Characters::PACDOT * (@notification - (cols * @repetitions))
60
59
  return
61
60
  end
62
- @progress_line = Characters::PACDOT * @cols
61
+ @progress_line = Characters::PACDOT * cols
63
62
  return
64
63
  end
65
64
  @progress_line = Characters::PACDOT * @notification
@@ -70,11 +69,10 @@ module RspecPacmanFormatter
70
69
  def step(character)
71
70
  @progress_line = @progress_line.sub(/#{Regexp.quote(Characters::PACMAN)}|#{Regexp.quote(Characters::PACDOT)}/, character)
72
71
  print format("%s\r", @progress_line)
73
- if @progress_line[-1] =~ /ᗣ|\./
74
- @repetitions += 1
75
- puts
76
- update_progress_line
77
- end
72
+ return unless @progress_line[-1] =~ /ᗣ|\./
73
+ @repetitions += 1
74
+ puts
75
+ update_progress_line
78
76
  end
79
77
  end
80
78
  end
@@ -1,3 +1,3 @@
1
1
  module RspecPacmanFormatter
2
- VERSION = '0.1.4'.freeze
2
+ VERSION = '0.1.5'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec_pacman_formatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Luis Rojas Aragonés
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-04-07 00:00:00.000000000 Z
11
+ date: 2018-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec