rspec-parallel-go-go-go 0.1.0 → 0.2.0

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: 164bfb6c1e3b2c9778eed578bbe09d1dec5fa44f8dba0be35181605b75203cbf
4
- data.tar.gz: eb12562baea3d1cf88bd425d6e797e29a856f4d35cb19c2b38e067b338016750
3
+ metadata.gz: 4b77beaad2d1a8376700f6177a390928fa77c246108bb9bf0a07eaee51b230f2
4
+ data.tar.gz: fe17dc417729624d26545add743b5b0264cefbe78e69126831ef7741bf8dd43f
5
5
  SHA512:
6
- metadata.gz: 38a10916d759b3404b1b630a20ba5720e457d4838a81cfc87e4ee5d0910f096792adca7fa0f1ffb68584acbbd20565407f0958d7f778113e2721c678a0016339
7
- data.tar.gz: 265b37bb08b7070f9b940a86e8bf7874140c0b02a7de1c5870f604d2d83a365894b2b5c2550f8394bd7db2824717e438e14411daf20971c594c54ac28ff915c2
6
+ metadata.gz: ba712ec607ecfe19052704040d5d705a5fa32d4d4c7c2b2b2139eb2ebf371a595bc44d9cef99a64d89c2bda48f0695eca48a63611cfafe55d13a278bdc3da631
7
+ data.tar.gz: 36d9d7ed820fa173ed63132a73b06f5d6220659f46b32faf328b43ff50b383bceca920c95d001a8443655372cecd602fac50a864654788014fa69dde7450b723
@@ -4,45 +4,34 @@ module RSpec
4
4
  module Parallel
5
5
  module GoGoGo
6
6
  module ProgressFramer
7
- module_function
8
-
9
- def cal_width(counter)
10
- @cal_width ||= begin
11
- width = terminal_width # terminal width
12
- width -= result(counter).length
13
- width -= rate(counter).length
14
- width -= 5 # blank * 3 and "|" * 2
15
- width
16
- end
17
- end
7
+ BAR_WIDTH = 5
8
+ BAR_CHAR = "oGo"
9
+ BAR_CHAR_LEN = BAR_CHAR.length
18
10
 
19
- def terminal_width
20
- @terminal_width ||= `tput cols`.to_i
21
- end
11
+ module_function
22
12
 
23
13
  def init_display(total_processes)
24
14
  "\n" * total_processes
25
15
  end
26
16
 
27
17
  def display(counter, move_number)
28
- "\r\e[#{move_number}E" + "#{result(counter)} #{bar(counter)} #{rate(counter)}" + "\e[#{move_number}F"
18
+ "\r\e[#{move_number}E" + "#{rate(counter)} #{bar(counter)} #{result(counter)}" + "\e[#{move_number}F"
29
19
  end
30
20
 
31
21
  def bar(counter)
32
- width = cal_width(counter)
33
22
  progress_bar = if counter.rate >= 1
34
- completed_progress_bar(width)
35
- elsif counter.rate <= 0
36
- no_progress_bar(width)
23
+ completed_progress_bar
37
24
  else
38
- in_progress_bar(counter, width)
25
+ in_progress_bar(counter)
39
26
  end
40
27
  RSpec::Core::Formatters::ConsoleCodes.wrap("|#{progress_bar}|", :magenta)
41
28
  end
42
29
 
43
30
  def result(counter)
44
- max = counter.total.to_s.length
45
- format("%#{max}s examples, %#{max}s failures", counter.checks, counter.failures)
31
+ checks = counter.checks
32
+ failures = counter.failures
33
+
34
+ format("%#{checks.to_s.length}s examples, %#{failures.to_s.length}s failures", checks, failures)
46
35
  end
47
36
 
48
37
  def rate(counter)
@@ -50,20 +39,26 @@ module RSpec
50
39
  "#{format("%3s", percent)}%"
51
40
  end
52
41
 
53
- # bar: ----------
54
- def no_progress_bar(width)
55
- "-" * width
42
+ def in_progress_bar(counter)
43
+ width = BAR_WIDTH + BAR_CHAR_LEN + BAR_CHAR_LEN
44
+ blank_bar = (" " * blank_len(counter))
45
+ bar = "#{blank_bar}#{BAR_CHAR}".ljust(width, " ")
46
+ bar.slice(BAR_CHAR_LEN, BAR_WIDTH)
56
47
  end
57
48
 
58
- # bar: GoGoGo-----
59
- def in_progress_bar(counter, width)
60
- bar_len = counter.rate * width.to_f / 2
61
- ("Go" * bar_len).ljust(width, "-")
49
+ def blank_len(counter)
50
+ v_len = (BAR_WIDTH + BAR_CHAR_LEN) * 2
51
+ len = counter.checks % v_len
52
+ if len > BAR_WIDTH + BAR_CHAR_LEN
53
+ # reverse
54
+ v_len - len
55
+ else
56
+ len
57
+ end
62
58
  end
63
59
 
64
- # bar: ==========
65
- def completed_progress_bar(width)
66
- "=" * width
60
+ def completed_progress_bar
61
+ "=" * BAR_WIDTH
67
62
  end
68
63
  end
69
64
  end
@@ -3,7 +3,7 @@
3
3
  module RSpec
4
4
  module Parallel
5
5
  module GoGoGo
6
- VERSION = "0.1.0"
6
+ VERSION = "0.2.0"
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-parallel-go-go-go
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - fukurose
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-01-12 00:00:00.000000000 Z
11
+ date: 2023-01-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This gem is a kind of rspec format. You can run rspec with progress bar.
14
14
  email: