benchdog 0.1.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.
data/sig/benchdog.rbs ADDED
@@ -0,0 +1,127 @@
1
+ module Benchdog
2
+ VERSION: String
3
+ SPEC_VERSION: String
4
+
5
+ type json = untyped
6
+ type json_hash = Hash[String, json]
7
+ type decision = { variation: String?, reason: String, gate: String?, rule_id: String?, error_code: String? }
8
+
9
+ BOOLEAN_VARIATIONS: Array[json_hash]
10
+
11
+ def self.bucket: (untyped text) -> Integer
12
+ def self.evaluate: (json_hash flag_set, String key, json_hash context, json default, ?Hash[Symbol, untyped] options) -> Result
13
+ def self.check: (json_hash? flag, String? expected_type) -> String?
14
+ def self.variation_value: (json_hash flag, String? key) -> json
15
+ def self.apply_schedule: (json_hash flag, Numeric now) -> json_hash
16
+ def self.due_steps: (json_hash flag, Numeric now) -> Array[json_hash]
17
+ def self.apply_step: (json_hash flag, json_hash set) -> json_hash
18
+
19
+ class InvalidFlag < StandardError
20
+ end
21
+
22
+ class Result
23
+ attr_reader value: json
24
+ attr_reader variation: String?
25
+ attr_reader reason: String
26
+ attr_reader gate: String?
27
+ attr_reader rule_id: String?
28
+ attr_reader error_code: String?
29
+ def initialize: (json value, Hash[Symbol, untyped] decision) -> void
30
+ def self.error: (json default, String code) -> Result
31
+ def to_h: () -> json_hash
32
+ end
33
+
34
+ class Evaluator
35
+ STEPS: Array[Symbol]
36
+ @set: json_hash
37
+ @actor: json_hash?
38
+ @now: Numeric
39
+ @random: Numeric
40
+ @groups: Hash[String, ^(json_hash) -> untyped]
41
+ @flag: json_hash
42
+ @visiting: Array[String]
43
+
44
+ def initialize: (json_hash flag_set, json_hash context, Hash[Symbol, untyped] options) -> void
45
+ def inner: (json_hash flag, Array[String] visiting) -> Hash[Symbol, untyped]
46
+
47
+ private
48
+
49
+ def start_time: (json_hash context, (^() -> Numeric)? clock) -> Numeric
50
+ def gates: () -> json_hash
51
+ def off: () -> String
52
+ def on: () -> String
53
+ def decide: (String variation, String reason, String gate, ?String? rule_id) -> Hash[Symbol, untyped]
54
+ def truthy?: (json expression) -> bool
55
+ def kill_switch: () -> Hash[Symbol, untyped]?
56
+ def prerequisites: () -> Hash[Symbol, untyped]?
57
+ def met?: (json_hash pre) -> bool
58
+ def boolean_gate: () -> Hash[Symbol, untyped]?
59
+ def actor_gate: () -> Hash[Symbol, untyped]?
60
+ def group_gate: () -> Hash[Symbol, untyped]?
61
+ def expression_gate: () -> Hash[Symbol, untyped]?
62
+ def rules: () -> Hash[Symbol, untyped]?
63
+ def percentage_of_actors: () -> Hash[Symbol, untyped]?
64
+ def percentage_of_time: () -> Hash[Symbol, untyped]?
65
+ def fallthrough: () -> Hash[Symbol, untyped]
66
+ def serve: (json_hash target, String gate, String? rule_id) -> Hash[Symbol, untyped]
67
+ def rollout: (Array[json_hash] items, String salt, json_hash actor) -> String
68
+ end
69
+
70
+ module Values
71
+ class TimeValue
72
+ attr_reader seconds: Numeric
73
+ def initialize: (Numeric seconds) -> void
74
+ end
75
+
76
+ DECIMAL: Regexp
77
+
78
+ def self?.to_number: (json value) -> Numeric?
79
+ def self?.to_time: (json value) -> TimeValue?
80
+ def self?.string_of: (json value) -> String
81
+ end
82
+
83
+ module Expression
84
+ TimeValue: singleton(Values::TimeValue)
85
+ TRUTHY_BOOLEANS: Array[json]
86
+
87
+ class Scope
88
+ attr_reader flag_key: String
89
+ attr_reader actor: json_hash?
90
+ attr_reader now: Numeric
91
+ attr_reader segments: json_hash
92
+ def initialize: (String flag_key, json_hash? actor, Numeric now, json_hash segments) -> void
93
+ end
94
+
95
+ type function = ^(Array[json] args, Scope scope, Array[String] visiting) -> json
96
+
97
+ FUNCTIONS: Hash[String, [Integer?, function]]
98
+
99
+ def self?.truthy?: (json value) -> bool
100
+ def self?.evaluate: (json expression, Scope scope) -> json
101
+ def self?.run: (json expression, Scope scope, Array[String] visiting) -> json
102
+ def self?.call: (String name, Array[json] args, Scope scope, Array[String] visiting) -> json
103
+ def self?.number?: (json value) -> bool
104
+ def self?.equal?: (json left, json right) -> bool
105
+ def self?.time_equal?: (json left, json right) -> bool
106
+ def self?.compare: (json left, json right) -> Integer?
107
+ def self?.ordered: (Array[json] args) { (Integer diff) -> bool } -> bool
108
+ def self?.property: (Scope scope, String name) -> json
109
+ def self?.in_percentage?: (Scope scope, json text, json pct) -> bool
110
+ def self?.segment: (Scope scope, String name, Array[String] visiting) -> json
111
+ end
112
+
113
+ module Audit
114
+ GENESIS_HASH: String
115
+
116
+ def self?.canonical_json: (json value) -> String
117
+ def self?.canonical_object: (json_hash hash) -> String
118
+ def self?.canonical_float: (Float value) -> String
119
+ def self?.hash_entry: (json_hash entry) -> String
120
+ def self?.verify_chain: (Array[json_hash] entries) -> json_hash
121
+ CSV_COLUMNS: Array[String]
122
+
123
+ def self?.csv: (Array[json_hash] entries) -> String
124
+ def self?.csv_cell: (json value) -> String
125
+ def self?.entry_error: (json_hash entry, Integer index, String prev) -> String?
126
+ end
127
+ end
@@ -0,0 +1,10 @@
1
+ # The parts of the json_schemer gem that Benchdog uses.
2
+ module JSONSchemer
3
+ class Schema
4
+ def validate: (untyped data) -> Enumerator[Hash[String, untyped], void]
5
+ def valid?: (untyped data) -> bool
6
+ def ref: (String pointer) -> Schema
7
+ end
8
+
9
+ def self.schema: (Pathname schema) -> Schema
10
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: benchdog
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Joe Gaudet
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-12-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json_schemer
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.4'
27
+ description:
28
+ email:
29
+ - joe@joegaudet.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - LICENSE
35
+ - README.md
36
+ - lib/benchdog.rb
37
+ - lib/benchdog/admin_api.rb
38
+ - lib/benchdog/admin_api/audit_routes.rb
39
+ - lib/benchdog/admin_api/flag_routes.rb
40
+ - lib/benchdog/admin_api/meta_routes.rb
41
+ - lib/benchdog/admin_api/request.rb
42
+ - lib/benchdog/approvals.rb
43
+ - lib/benchdog/audit.rb
44
+ - lib/benchdog/bucket.rb
45
+ - lib/benchdog/client.rb
46
+ - lib/benchdog/evaluator.rb
47
+ - lib/benchdog/expression.rb
48
+ - lib/benchdog/flag.schema.json
49
+ - lib/benchdog/payload.rb
50
+ - lib/benchdog/schedule.rb
51
+ - lib/benchdog/spec/store_examples.rb
52
+ - lib/benchdog/store.rb
53
+ - lib/benchdog/usage.rb
54
+ - lib/benchdog/validation.rb
55
+ - lib/benchdog/values.rb
56
+ - lib/benchdog/version.rb
57
+ - sig/admin_api.rbs
58
+ - sig/benchdog.rbs
59
+ - sig/json_schemer.rbs
60
+ homepage: https://joegaudet.com/benchdog/
61
+ licenses:
62
+ - MIT
63
+ metadata:
64
+ source_code_uri: https://github.com/joegaudet/benchdog/tree/main/ruby/benchdog
65
+ bug_tracker_uri: https://github.com/joegaudet/benchdog/issues
66
+ rubygems_mfa_required: 'true'
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '3.3'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubygems_version: 3.5.11
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: 'Feature flags for Ruby: gates, rollouts, variants and audit.'
86
+ test_files: []