bitfab 0.67.0 → 0.67.1

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: 455ac9a2dfa11b39c17550b3f86f6ffa87f3ea0a9684fb032722184a705da7e0
4
- data.tar.gz: 11c0f2491a21515f3fc75f4f4f8eb98f544b7e6d5d3c9d1c7fc09e0728787b16
3
+ metadata.gz: e7edc2e37708c89dd56c11df5120665113225fb70203597f27d7f8248c6af03e
4
+ data.tar.gz: 32e6e61a1a662ad75b3ec42d7537fa2ccb902008bf5d0da9d8fec1d322afc4f2
5
5
  SHA512:
6
- metadata.gz: d1f41b10072dd2b9b52f2a91ef5265a91805d2aa8129a05a30a303f6f55831934c8206eca6fd215ac938a526f499e9bc2b38a2e74476c8aa06e6c675e14d9b7f
7
- data.tar.gz: d1e5d1ac8216e5505b5d5da628d6914349fe7ee6018fa55616b20a5ba3ca66e647484f4db176ee85feac28c476f702e831bfcf9ae3fa5ff5084d9d0570584ade
6
+ metadata.gz: d7658a55ed694fb16e3b6555da146212745e53297b6a071ab9713e7d73a2c5baa4dea4ec2362b63a7de6d7a62e305119749a0c41354220a00b2f4ee270d644ee
7
+ data.tar.gz: 462ad2286342a7d424478dc94273bcc1abda17ae397c964022fe8fd57c039cec50dc7c1a9bef447cbf9530ed271b0891951bbee97ffae1e8bd3c767da47538d2
@@ -6,6 +6,8 @@ module Bitfab
6
6
  class Traces
7
7
  UNSET = Object.new.freeze
8
8
  private_constant :UNSET
9
+ RECORDS_KEYS_IN_DATA = %w[records sources].freeze
10
+ private_constant :RECORDS_KEYS_IN_DATA
9
11
 
10
12
  def get_scenario(trace_id)
11
13
  @http_client.get(scenario_path(trace_id))["scenario"]
@@ -14,6 +16,8 @@ module Bitfab
14
16
  # Updates the scenario built from trace_id and returns the saved hash.
15
17
  #
16
18
  # name:, description:, trigger:, and data: each replace the saved value whole. Keywords left out are kept.
19
+ # data: has no records: its "records" and "sources" are left out of the request and the saved ones are kept,
20
+ # so a data hash read back from get_scenario can be sent as it is.
17
21
  # append_data: adds history and missing entries after the saved ones. Pass data: or append_data:, not both.
18
22
  #
19
23
  # actual_outcome: is what the run actually did in this one example, never what it should have done.
@@ -25,9 +29,32 @@ module Bitfab
25
29
  # Leave it out to keep the current set, and pass an empty array to clear it. The returned hash lists the
26
30
  # scenario's categories under "categories", each {"id", "title", "description"}, sorted by title.
27
31
  #
28
- # Raises ArgumentError before any request when nothing is passed, or when data: and append_data: are both passed.
32
+ # records: replaces the scenario's records whole. Each is
33
+ # {"kind", "ref", "at", "asOf" => "run" or "now", "title", "text", "quote"}, and Bitfab looks for its "quote",
34
+ # or failing that its "text", in the run's spans and saves the span it shows up in. Records are saved on their
35
+ # own, with only sources: beside them, and a non-empty array is refused while the scenario's trigger is empty.
36
+ # An empty array is a valid save. sources: says where the records came from, as
37
+ # {"frameAt", "capturedAt", "windows", "coverage"}. Leaving it out clears the saved sources.
38
+ #
39
+ # Raises ArgumentError before any request when nothing is passed, when data: and append_data: are both passed,
40
+ # when sources: is passed without records:, or when records: is passed beside any other field.
29
41
  def save_scenario(trace_id, name: nil, description: nil, trigger: nil, data: nil, append_data: nil, actual_outcome: UNSET,
30
- category_ids: nil)
42
+ category_ids: nil, records: nil, sources: nil)
43
+ if records.nil? && !sources.nil?
44
+ raise ArgumentError, "Pass sources only with records: sources describe where the records came from."
45
+ end
46
+
47
+ unless records.nil?
48
+ others = [name, description, trigger, data, append_data, category_ids]
49
+ if others.any? { |value| !value.nil? } || !actual_outcome.equal?(UNSET)
50
+ raise ArgumentError, "Pass records on their own, with only sources beside them: records are saved apart from the other fields."
51
+ end
52
+
53
+ payload = {"records" => records.to_a}
54
+ payload["sources"] = sources unless sources.nil?
55
+ return @http_client.request(scenario_path(trace_id), payload)["scenario"]
56
+ end
57
+
31
58
  if !data.nil? && !append_data.nil?
32
59
  raise ArgumentError, "Pass data or append_data, not both: data replaces the saved data whole."
33
60
  end
@@ -36,12 +63,12 @@ module Bitfab
36
63
  payload["name"] = name unless name.nil?
37
64
  payload["description"] = description unless description.nil?
38
65
  payload["trigger"] = trigger unless trigger.nil?
39
- payload["data"] = data unless data.nil?
66
+ payload["data"] = data.reject { |key, _| RECORDS_KEYS_IN_DATA.include?(key.to_s) } unless data.nil?
40
67
  payload["appendData"] = append_data unless append_data.nil?
41
68
  payload["actualOutcome"] = actual_outcome unless actual_outcome.equal?(UNSET)
42
69
  payload["categoryIds"] = category_ids.to_a unless category_ids.nil?
43
70
  if payload.empty?
44
- raise ArgumentError, "Pass at least one of name, description, trigger, data, append_data, actual_outcome, or category_ids: there is nothing to save otherwise."
71
+ raise ArgumentError, "Pass at least one of name, description, trigger, data, append_data, actual_outcome, category_ids, or records: there is nothing to save otherwise."
45
72
  end
46
73
 
47
74
  @http_client.request(scenario_path(trace_id), payload)["scenario"]
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bitfab
4
- VERSION = "0.67.0"
4
+ VERSION = "0.67.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bitfab
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.67.0
4
+ version: 0.67.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harvest Team