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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd14bc3ee1a5a274215d2cbedfe0c3c3acf4109f55004588dfe04dd5a88ea94c
4
- data.tar.gz: 22e02babcae990861b74a5d1efa144289f7520010704618ae11ad4b76d4b1ff7
3
+ metadata.gz: 5bcee5cca4a0494e03982e14f604be2481981e65589dbc991285ad173c6f44d7
4
+ data.tar.gz: f6bc0fd95992d2f90d95c8d89896a0f6f8ebd329b5cfbf96757bc78f1fc6ff50
5
5
  SHA512:
6
- metadata.gz: f02f7f5532a0aeec18474d1834f71745d922e91dff26ab9e9a0ee6823656905c6e2fa5185aa206dbdeb83844651e6996d0fce496db4b69eeeb3cc6994a90815b
7
- data.tar.gz: 33530428f9c4391fed679155b9d05d03b6b24819b2c5d22a366286838664353bb6f2b121cd69e95cc973e3b1cb3469791973ea8a06a8e405f831b394dcd7a585
6
+ metadata.gz: 687bb2301164578171bab2dbd176c90d2aed5f97faa68e211b69ef5f5958de930420f8c5f513b53890211667c4fd9e88bd8294e73a9276fc828ab79073d9dad9
7
+ data.tar.gz: 356d35aa763c40d3ca850b85eb42f8f7f90cf542bfe191c9b1c5f9cf013b54bab2621baddfc0edd2289ef74a71bf8b252fa3b6594237cdd26604f5c6aed62d7f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-go-go-go (0.1.2)
4
+ rspec-go-go-go (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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
- module_function :display
9
-
25
+
10
26
  def bar(counter)
11
- bar_len = counter.rate * 60.to_f
12
- "|#{("=" * bar_len).ljust(60)}|"
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
- module_function :bar
15
-
37
+
16
38
  def result(counter)
17
- "#{counter.checks} examples, #{counter.failures} failures"
39
+ max = counter.total.to_s.length
40
+ format("%#{max}s examples, %#{max}s failures", counter.checks, counter.failures)
18
41
  end
19
- module_function :result
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
- module_function :rate
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module GoGoGo
5
- VERSION = "0.1.2"
5
+ VERSION = "0.1.3"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-go-go-go
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - fukurose