sus 0.11.0 → 0.12.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: 1e40571705fc5474aff2158cee00b9fd9b80778fa9d5e7caa30da9d039095368
4
- data.tar.gz: 94cb197a3d237636360f5e62c1b5095352fb2956c7a4a01c49388d4dceab065d
3
+ metadata.gz: 4c4e40f000e1811b16c1718c123e165cafbb2fe8b576954f6c8824ea61097985
4
+ data.tar.gz: 42a5387eae3f2588b13ed33b3e75a1df5193b6d636a3a730c4454e9b3ad81a16
5
5
  SHA512:
6
- metadata.gz: 9cda6d03170da4badb665d704afe42f02f80f162f51891dad475c9a6ad7539c4b76a315f655293a686ccf24338c4d7128722cabb30e3671018b20ca0959c3373
7
- data.tar.gz: e4a0f447efe11fcc9a7417277faf55100903b711703a363532f28dedebed0b6d3cb0b13bc6675a8ac1b0c5d8eaa21566cbf305ab9b90cea05c9f77d05d2902c1
6
+ metadata.gz: 4af49c129c2acef1b1884e3bf3f7269f4340f47a264e6eab595eaf967d5f4dda14ce74a24adaf0bfc85bf362846c27c6e469218da5b32917bbd8c4d418477329
7
+ data.tar.gz: 20da00aa7d81f0e5444af2938f1bc346a1e5dd958b9ebea2826d26d637af64bfbbab5c21002b2e85afbffcc904c59c4a709c67f36562254e20e508860fa53a01
checksums.yaml.gz.sig CHANGED
Binary file
@@ -130,6 +130,10 @@ module Sus
130
130
  end
131
131
  end
132
132
 
133
+ def inform(message)
134
+ @output.puts(:indent, :inform, inform_prefix, message)
135
+ end
136
+
133
137
  # Add deferred assertions.
134
138
  def defer(&block)
135
139
  @deferred << block
@@ -266,5 +270,9 @@ module Sus
266
270
  def fail_prefix
267
271
  "✗ "
268
272
  end
273
+
274
+ def inform_prefix
275
+ "ℹ "
276
+ end
269
277
  end
270
278
  end
data/lib/sus/base.rb CHANGED
@@ -34,8 +34,8 @@ module Sus
34
34
  @__assertions__.assert(...)
35
35
  end
36
36
 
37
- def refute(...)
38
- @__assertions__.refute(...)
37
+ def inform(...)
38
+ @__assertions__.inform(...)
39
39
  end
40
40
  end
41
41
 
data/lib/sus/clock.rb CHANGED
@@ -7,27 +7,41 @@ module Sus
7
7
  class Clock
8
8
  include Comparable
9
9
 
10
+ def self.start!
11
+ self.new.tap(&:start!)
12
+ end
13
+
10
14
  def initialize(duration = 0.0)
11
15
  @duration = duration
12
16
  end
13
17
 
14
- attr :duration
18
+ def duration
19
+ if @start_time
20
+ now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
21
+ @duration += now - @start_time
22
+ @start_time = now
23
+ end
24
+
25
+ return @duration
26
+ end
15
27
 
16
28
  def <=>(other)
17
- @duration <=> other.to_f
29
+ duration <=> other.to_f
18
30
  end
19
31
 
20
32
  def to_f
21
- @duration
33
+ duration
22
34
  end
23
35
 
24
36
  def to_s
25
- if @duration < 0.001
26
- "#{(@duration * 1_000_000).round(1)}µs"
27
- elsif @duration < 1.0
28
- "#{(@duration * 1_000).round(1)}ms"
37
+ duration = self.duration
38
+
39
+ if duration < 0.001
40
+ "#{(duration * 1_000_000).round(1)}µs"
41
+ elsif duration < 1.0
42
+ "#{(duration * 1_000).round(1)}ms"
29
43
  else
30
- "#{@duration.round(1)}s"
44
+ "#{duration.round(1)}s"
31
45
  end
32
46
  end
33
47
 
@@ -37,9 +51,12 @@ module Sus
37
51
 
38
52
  def stop!
39
53
  if @start_time
40
- @duration += Process.clock_gettime(Process::CLOCK_MONOTONIC) - @start_time
54
+ now = Process.clock_gettime(Process::CLOCK_MONOTONIC)
55
+ @duration += now - @start_time
41
56
  @start_time = nil
42
57
  end
58
+
59
+ return duration
43
60
  end
44
61
  end
45
62
  end
data/lib/sus/output.rb CHANGED
@@ -40,6 +40,7 @@ module Sus
40
40
  output[:passed] = output.style(:green)
41
41
  output[:failed] = output.style(:red)
42
42
  output[:error] = output.style(:red)
43
+ # output[:inform] = output.style(nil, nil, :bold)
43
44
 
44
45
  return output
45
46
  end
data/lib/sus/version.rb CHANGED
@@ -4,5 +4,5 @@
4
4
  # Copyright, 2021-2022, by Samuel Williams.
5
5
 
6
6
  module Sus
7
- VERSION = "0.11.0"
7
+ VERSION = "0.12.0"
8
8
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
metadata.gz.sig CHANGED
Binary file