Skip to content

Commit 5eb2429

Browse files
committed
Add RBI
1 parent 054d3ca commit 5eb2429

File tree

3 files changed

+188
-1
lines changed

3 files changed

+188
-1
lines changed

.rubocop.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins:
44
- rubocop-performance
55

66
AllCops:
7-
TargetRubyVersion: 4.0
7+
TargetRubyVersion: 3.1
88
DisplayCopNames: true
99
DisplayStyleGuide: true
1010
NewCops: enable

.vscode/project-words.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ Kodkod
66
kwargs
77
libsqlite
88
nilable
9+
noreturn
910
rubocop

rbi/operandi.rbi

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
# typed: strict
2+
# frozen_string_literal: true
3+
4+
# RBI signatures for Operandi gem.
5+
# These signatures provide Sorbet type checking without requiring sorbet-runtime as a dependency.
6+
7+
module Operandi
8+
class Base
9+
# Attributes
10+
sig { returns(Operandi::Collection::Base) }
11+
def outputs; end
12+
13+
sig { returns(Operandi::Collection::Base) }
14+
def arguments; end
15+
16+
sig { returns(Operandi::Messages) }
17+
def errors; end
18+
19+
sig { returns(Operandi::Messages) }
20+
def warnings; end
21+
22+
# Instance methods
23+
sig { returns(T::Boolean) }
24+
def success?; end
25+
26+
sig { returns(T::Boolean) }
27+
def successful?; end
28+
29+
sig { returns(T::Boolean) }
30+
def failed?; end
31+
32+
sig { returns(T::Boolean) }
33+
def errors?; end
34+
35+
sig { returns(T::Boolean) }
36+
def warnings?; end
37+
38+
sig { void }
39+
def stop!; end
40+
41+
sig { void }
42+
def done!; end
43+
44+
sig { returns(T::Boolean) }
45+
def stopped?; end
46+
47+
sig { returns(T::Boolean) }
48+
def done?; end
49+
50+
sig { returns(T.noreturn) }
51+
def stop_immediately!; end
52+
53+
sig { params(message: String).void }
54+
def fail!(message); end
55+
56+
sig { params(message: String).returns(T.noreturn) }
57+
def fail_immediately!(message); end
58+
59+
sig { void }
60+
def call; end
61+
62+
# Class methods
63+
class << self
64+
sig { returns(T.nilable(T::Hash[Symbol, T.untyped])) }
65+
def class_config; end
66+
67+
sig { params(class_config: T.nilable(T::Hash[Symbol, T.untyped])).returns(T.nilable(T::Hash[Symbol, T.untyped])) }
68+
def class_config=(class_config); end
69+
70+
sig { params(config: T::Hash[Symbol, T.untyped]).returns(T::Hash[Symbol, T.untyped]) }
71+
def config(config = {}); end
72+
73+
sig { params(kwargs: T.untyped).returns(T.attached_class) }
74+
def run(**kwargs); end
75+
76+
sig { params(kwargs: T.untyped).returns(T.attached_class) }
77+
def run!(**kwargs); end
78+
79+
sig {
80+
params(
81+
service_or_config: T.any(Operandi::Base, T::Hash[Symbol, T.untyped]),
82+
config: T::Hash[Symbol, T.untyped],
83+
).returns(Operandi::BaseWithContext)
84+
}
85+
def with(service_or_config, config = {}); end
86+
end
87+
end
88+
89+
class BaseWithContext
90+
sig {
91+
params(
92+
service_class: T.class_of(Operandi::Base),
93+
parent_service: T.nilable(Operandi::Base),
94+
config: T::Hash[Symbol, T.untyped],
95+
).void
96+
}
97+
def initialize(service_class, parent_service, config); end
98+
99+
sig { params(kwargs: T.untyped).returns(Operandi::Base) }
100+
def run(**kwargs); end
101+
102+
sig { params(kwargs: T.untyped).returns(Operandi::Base) }
103+
def run!(**kwargs); end
104+
end
105+
106+
class Messages
107+
sig { params(config: T::Hash[Symbol, T.untyped]).void }
108+
def initialize(config); end
109+
110+
sig { params(key: Symbol).returns(T.nilable(T::Array[Operandi::Message])) }
111+
def [](key); end
112+
113+
sig { returns(T::Boolean) }
114+
def any?; end
115+
116+
sig { returns(T::Boolean) }
117+
def empty?; end
118+
119+
sig { returns(Integer) }
120+
def size; end
121+
122+
sig { returns(Integer) }
123+
def count; end
124+
125+
sig { returns(T::Array[Symbol]) }
126+
def keys; end
127+
128+
sig { params(key: Symbol).returns(T::Boolean) }
129+
def key?(key); end
130+
131+
sig { params(key: Symbol).returns(T::Boolean) }
132+
def has_key?(key); end
133+
134+
sig {
135+
params(
136+
key: Symbol,
137+
texts: T.any(String, T::Array[String], Operandi::Message),
138+
opts: T::Hash[Symbol, T.untyped],
139+
).void
140+
}
141+
def add(key, texts, opts = {}); end
142+
143+
sig { returns(T::Boolean) }
144+
def break?; end
145+
146+
sig { params(entity: T.untyped, opts: T::Hash[Symbol, T.untyped]).void }
147+
def copy_from(entity, opts = {}); end
148+
149+
sig { params(entity: T.untyped, opts: T::Hash[Symbol, T.untyped]).void }
150+
def from_record(entity, opts = {}); end
151+
152+
sig { returns(T::Hash[Symbol, T::Array[String]]) }
153+
def to_h; end
154+
end
155+
156+
module Collection
157+
class Base
158+
sig { params(key: Symbol).returns(T::Boolean) }
159+
def key?(key); end
160+
161+
sig { returns(T::Hash[Symbol, T.untyped]) }
162+
def to_h; end
163+
164+
sig { params(key: Symbol, value: T.untyped).returns(T.untyped) }
165+
def set(key, value); end
166+
167+
sig { params(key: Symbol).returns(T.untyped) }
168+
def get(key); end
169+
170+
sig { params(key: Symbol).returns(T.untyped) }
171+
def [](key); end
172+
173+
sig { params(key: Symbol, value: T.untyped).returns(T.untyped) }
174+
def []=(key, value); end
175+
176+
sig { void }
177+
def load_defaults; end
178+
179+
sig { void }
180+
def validate!; end
181+
182+
sig { params(args: T::Hash[Symbol, T.untyped]).returns(T::Hash[Symbol, T.untyped]) }
183+
def extend_with_context(args); end
184+
end
185+
end
186+
end

0 commit comments

Comments
 (0)