stable 1.5.1 → 1.7.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/stable/spec.rb +31 -11
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 04f5edbc2d167df3bc6a5057291e567562f2e07b6885140ec96f3cf87b601032
4
- data.tar.gz: 6da1a393e4f367fe1fcb284198f4f0a31e70df9537a8d910c4901e6b863c60f3
3
+ metadata.gz: 705f529d889248982d60df5c8257a80ddca578714403e68b8a60f7f88478223a
4
+ data.tar.gz: e8ace2f93edb08e1981750332c6034408a9d12cc08e2b7a0c1b07b64ca032496
5
5
  SHA512:
6
- metadata.gz: 95eb8713130c459485d8024fb7c5cef3b80d5e973b81534ee1cc43c11d617e573b3dedec3256bc4aafd3510915baf77498d6f83c096a3fb8ce921e9fd733b78b
7
- data.tar.gz: bb5156a92198985700e2624d47f9c34f84a2d608c4192a2672550a0111fceac1d12ba71fef6949787bb2cdcaf514581f313535a160f6664a6f2b17a989970fbd
6
+ metadata.gz: f51fb0d25f5b0318a8a5759d0849b16d93bd8187bf5ddd97fa2aad4a584e3a18c1f5e24374d164d8f07ad03edc79a4127341bf47099c600544fed0bffb866671
7
+ data.tar.gz: da63baa93a76c20c46b51ed5c9fff23671797a46b698d7b277e8db5dafa03c924afe5f32f296051755738613d4c25d8e8dfd35af6b6c951327580eddb10e2296
data/lib/stable/spec.rb CHANGED
@@ -8,15 +8,14 @@ module Stable
8
8
  # outputs. it's a self-contained, serializable representation of a method's
9
9
  # behavior at a specific point in time.
10
10
  class Spec
11
- attr_reader :class_name, :method_name, :args, :result, :error, :timestamp, :actual_result, :actual_error, :status, :uuid, :signature
11
+ attr_reader :class_name, :method_name, :args, :result, :error, :actual_result, :actual_error, :status, :uuid, :signature
12
12
 
13
- def initialize(class_name:, method_name:, args:, result: nil, error: nil, timestamp: Time.now.iso8601, uuid: SecureRandom.uuid)
13
+ def initialize(class_name:, method_name:, args:, result: nil, error: nil, uuid: SecureRandom.uuid)
14
14
  @class_name = class_name
15
15
  @method_name = method_name
16
16
  @args = args
17
17
  @result = result
18
18
  @error = error
19
- @timestamp = timestamp
20
19
  @status = :pending
21
20
  @uuid = uuid
22
21
  @signature = Digest::SHA256.hexdigest("#{class_name}##{method_name}:#{args.to_json}")
@@ -51,14 +50,14 @@ module Stable
51
50
  short_sig = signature[0..6]
52
51
  desc = "#{short_uuid}/#{short_sig}"
53
52
  call = "#{class_name}##{method_name}(#{args.join(', ')})"
53
+ status_code = _status_code
54
+ error_code = _error_code
54
55
 
55
56
  case status
56
- when :passed
57
- "#{desc} #{_green('P')} #{call}"
58
- when :passed_with_error
59
- "#{desc} #{_green('P')} (error) #{call}"
57
+ when :passed, :passed_with_error
58
+ "#{desc} #{status_code}#{error_code} #{call}"
60
59
  when :failed
61
- lines = ["#{desc} #{_red('F')} #{call}"]
60
+ lines = ["#{desc} #{status_code}#{error_code} #{call}"]
62
61
  if actual_error
63
62
  if error
64
63
  lines << " Expected error: #{error['class']}"
@@ -78,7 +77,7 @@ module Stable
78
77
  end
79
78
  lines.join("\n")
80
79
  else
81
- "#{desc} #{_yellow('?')} #{call}"
80
+ "#{desc} #{status_code}#{error_code} #{call}"
82
81
  end
83
82
  end
84
83
 
@@ -89,7 +88,6 @@ module Stable
89
88
  args: args,
90
89
  result: result,
91
90
  error: error,
92
- timestamp: timestamp,
93
91
  uuid: uuid,
94
92
  signature: signature
95
93
  }.compact.to_json
@@ -103,7 +101,6 @@ module Stable
103
101
  args: data['args'],
104
102
  result: data['result'],
105
103
  error: data['error'],
106
- timestamp: data['timestamp'],
107
104
  uuid: data['uuid']
108
105
  )
109
106
  end
@@ -119,5 +116,28 @@ module Stable
119
116
  def _yellow(text)
120
117
  "\e[33m#{text}\e[0m"
121
118
  end
119
+
120
+ def _light_blue(text)
121
+ "\e[94m#{text}\e[0m"
122
+ end
123
+
124
+ def _status_code
125
+ case status
126
+ when :passed, :passed_with_error
127
+ _green('P')
128
+ when :failed
129
+ _red('F')
130
+ else
131
+ _yellow('?')
132
+ end
133
+ end
134
+
135
+ def _error_code
136
+ if error || actual_error
137
+ _light_blue('E')
138
+ else
139
+ _green('N')
140
+ end
141
+ end
122
142
  end
123
143
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Lunt