parallel_rspec_progress 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d50cd9abfc423b4ecebd5deea4d195252e772a59f8ac110ca08882e852950c7
4
- data.tar.gz: 312b50c008c33f789ba0da5da1db87db69168cced7e9cbf73b996520c5e99a7a
3
+ metadata.gz: a945ab8eadd896eef539852a30db052fe204f9731807b5b14962fc5bf692c348
4
+ data.tar.gz: fa880a599f57be5ae5ef7639b1522a49df636d3e6e6f07092fa5494104ae5ebf
5
5
  SHA512:
6
- metadata.gz: 396d4945e02d3a341a6e027e54b666986fdb110b3af1d754275e4f228435b2216dffbf9c604cde2637d7ba1f48e46b99a0361817dfde6e257f73f5e087af63e3
7
- data.tar.gz: cd2717008db8734ffeeed6bd73ae1d2fe2f49a89e0a8c6522c004354d913e10a56f40a953cb62abe2534cdb89f3d98e6a880b43575d709626d5204e569a8e6ab
6
+ metadata.gz: 571aca6b5383e656433f5695c2d07ab86eea7ef58a0d55e2b9bd2c9d5cb96632935ea46de41551c87b9492f6ee38ee7b0a88f44801b90a849691abce1f686de2
7
+ data.tar.gz: bfa9e1fda8ad295db24f187aaeea22bbc7d591e1e7680ae3fcaee171fb3439673af2fec76ad0d37d18cd6656dd433984e0dad261be430f4776bfd1b304a6901c
@@ -3,24 +3,55 @@ require "drb/drb"
3
3
 
4
4
  module ParallelRspecProgress
5
5
  class Controller
6
- attr_reader :progressbar
6
+ def initialize
7
+ @failed = []
8
+ @passed = []
9
+ @pending = []
10
+ @total = 0
11
+ end
7
12
 
8
13
  def stop
9
14
  DRb.stop_service
10
15
  end
11
16
 
12
- def progressbar?
13
- @progressbar
17
+ def put_total(val)
18
+ if @progressbar
19
+ @total += val
20
+ @progressbar.total = @total
21
+ else
22
+ @total = val
23
+ create_progressbar
24
+ end
14
25
  end
15
26
 
16
- def create_progressbar(total)
17
- @progressbar = ProgressBar.create(
18
- format: "%a %e %P% Processed: %c from %C %b\u{15E7}%i %p%% %t",
19
- progress_mark: ' ',
20
- remainder_mark: "\u{FF65}",
21
- starting_at: 0,
22
- total: total,
23
- )
27
+ def add(key:, item:)
28
+ case key
29
+ when :failed
30
+ @failed << item
31
+ when :passed
32
+ @passed << item
33
+ when :pending
34
+ @pending << item
35
+ end
36
+
37
+ @progressbar.increment
38
+ @progressbar.title = compose_title
24
39
  end
40
+
41
+ private
42
+
43
+ def create_progressbar
44
+ @progressbar = ProgressBar.create(
45
+ format: "%a %e %P% Processed: %c from %C %b\u{15E7}%i %p%% %t",
46
+ progress_mark: ' ',
47
+ remainder_mark: "\u{FF65}",
48
+ starting_at: 0,
49
+ total: @total
50
+ )
51
+ end
52
+
53
+ def compose_title
54
+ "passed: #{@passed.count} failed: #{@failed.count} pending: #{@pending.count}"
55
+ end
25
56
  end
26
57
  end
@@ -1,5 +1,5 @@
1
- require 'parallel_tests'
2
- require 'drb/drb'
1
+ require "parallel_tests"
2
+ require "drb/drb"
3
3
 
4
4
  class ParallelProgressFormatter
5
5
  RSpec::Core::Formatters.register self,
@@ -17,11 +17,7 @@ class ParallelProgressFormatter
17
17
  end
18
18
 
19
19
  def start(notification)
20
- if controller.progressbar?
21
- controller.progressbar.total += notification.count
22
- else
23
- controller.create_progressbar(notification.count)
24
- end
20
+ controller.put_total(notification.count)
25
21
  end
26
22
 
27
23
  def close(notification)
@@ -33,14 +29,14 @@ class ParallelProgressFormatter
33
29
  end
34
30
 
35
31
  def example_passed(notification)
36
- controller.progressbar.increment
32
+ controller.add(key: :passed, item: 1)
37
33
  end
38
34
 
39
35
  def example_failed(notification)
40
- controller.progressbar.increment
36
+ controller.add(key: :failed, item: 1)
41
37
  end
42
38
 
43
39
  def example_pending(notification)
44
- controller.progressbar.increment
40
+ controller.add(key: :pending, item: 1)
45
41
  end
46
42
  end
@@ -1,3 +1,3 @@
1
1
  module ParallelRspecProgress
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel_rspec_progress
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Viktor Sych