rspec-go-go-go 0.1.2 → 0.1.3
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/rspec/go_go_go/progress_framer.rb +47 -10
- data/lib/rspec/go_go_go/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bcee5cca4a0494e03982e14f604be2481981e65589dbc991285ad173c6f44d7
|
4
|
+
data.tar.gz: f6bc0fd95992d2f90d95c8d89896a0f6f8ebd329b5cfbf96757bc78f1fc6ff50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 687bb2301164578171bab2dbd176c90d2aed5f97faa68e211b69ef5f5958de930420f8c5f513b53890211667c4fd9e88bd8294e73a9276fc828ab79073d9dad9
|
7
|
+
data.tar.gz: 356d35aa763c40d3ca850b85eb42f8f7f90cf542bfe191c9b1c5f9cf013b54bab2621baddfc0edd2289ef74a71bf8b252fa3b6594237cdd26604f5c6aed62d7f
|
data/Gemfile.lock
CHANGED
@@ -1,28 +1,65 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
module RSpec
|
3
4
|
module GoGoGo
|
4
5
|
module ProgressFramer
|
6
|
+
module_function
|
7
|
+
|
8
|
+
def cal_width(counter)
|
9
|
+
@cal_width ||= begin
|
10
|
+
width = terminal_width # terminal width
|
11
|
+
width -= result(counter).length
|
12
|
+
width -= rate(counter).length
|
13
|
+
width -= 5 # blank * 3 and "|" * 2
|
14
|
+
width
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def terminal_width
|
19
|
+
`tput cols`.to_i
|
20
|
+
end
|
21
|
+
|
5
22
|
def display(counter)
|
6
23
|
"\r #{result(counter)} #{bar(counter)} #{rate(counter)}"
|
7
24
|
end
|
8
|
-
|
9
|
-
|
25
|
+
|
10
26
|
def bar(counter)
|
11
|
-
|
12
|
-
|
27
|
+
width = cal_width(counter)
|
28
|
+
progress_bar = if counter.rate >= 1
|
29
|
+
completed_progress_bar(width)
|
30
|
+
elsif counter.rate <= 0
|
31
|
+
no_progress_bar(width)
|
32
|
+
else
|
33
|
+
in_progress_bar(counter, width)
|
34
|
+
end
|
35
|
+
"|#{progress_bar}|"
|
13
36
|
end
|
14
|
-
|
15
|
-
|
37
|
+
|
16
38
|
def result(counter)
|
17
|
-
|
39
|
+
max = counter.total.to_s.length
|
40
|
+
format("%#{max}s examples, %#{max}s failures", counter.checks, counter.failures)
|
18
41
|
end
|
19
|
-
|
20
|
-
|
42
|
+
|
21
43
|
def rate(counter)
|
22
44
|
percent = (counter.rate * 100.0).to_int
|
23
45
|
"#{format("%3s", percent)}%"
|
24
46
|
end
|
25
|
-
|
47
|
+
|
48
|
+
# bar: ----------
|
49
|
+
def no_progress_bar(width)
|
50
|
+
"-" * width
|
51
|
+
end
|
52
|
+
|
53
|
+
# bar: ====>-----
|
54
|
+
def in_progress_bar(counter, width)
|
55
|
+
bar_len = counter.rate * width.to_f
|
56
|
+
"#{"=" * (bar_len - 1)}>".ljust(width, "-")
|
57
|
+
end
|
58
|
+
|
59
|
+
# bar: ==========
|
60
|
+
def completed_progress_bar(width)
|
61
|
+
"=" * width
|
62
|
+
end
|
26
63
|
end
|
27
64
|
end
|
28
65
|
end
|