mangrove 0.18.0 → 0.19.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/mangrove/result.rb +92 -3
- data/lib/mangrove/version.rb +1 -1
- data/sorbet/rbi/annotations/.gitattributes +1 -0
- data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +1 -5
- data/sorbet/rbi/gems/docile@1.4.0.rbi +376 -0
- data/sorbet/rbi/gems/json@2.6.3.rbi +73 -65
- data/sorbet/rbi/gems/prism@0.15.1.rbi +23916 -2
- data/sorbet/rbi/gems/rake@13.0.6.rbi +1 -141
- data/sorbet/rbi/gems/{rbi@0.1.1.rbi → rbi@0.1.3.rbi} +53 -57
- data/sorbet/rbi/gems/regexp_parser@2.8.2.rbi +37 -37
- data/sorbet/rbi/gems/rexml@3.2.6.rbi +2 -2
- data/sorbet/rbi/gems/rspec-core@3.12.2.rbi +8 -39
- data/sorbet/rbi/gems/rspec-expectations@3.12.3.rbi +25 -25
- data/sorbet/rbi/gems/rspec-mocks@3.12.6.rbi +4 -8
- data/sorbet/rbi/gems/rspec-sorbet@1.9.2.rbi +2 -2
- data/sorbet/rbi/gems/rspec-support@3.12.1.rbi +2 -2
- data/sorbet/rbi/gems/rspec@3.12.0.rbi +1 -1
- data/sorbet/rbi/gems/rubocop-ast@1.29.0.rbi +263 -176
- data/sorbet/rbi/gems/rubocop@1.57.1.rbi +1019 -719
- data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +5 -5
- data/sorbet/rbi/gems/simplecov-html@0.12.3.rbi +216 -0
- data/sorbet/rbi/gems/simplecov@0.21.2.rbi +2135 -0
- data/sorbet/rbi/gems/simplecov_json_formatter@0.1.4.rbi +8 -0
- data/sorbet/rbi/gems/spoom@1.2.4.rbi +15 -15
- data/sorbet/rbi/gems/{tapioca@0.11.9.rbi → tapioca@0.11.10.rbi} +40 -29
- data/sorbet/rbi/gems/yard-sorbet@0.8.1.rbi +1 -1
- data/sorbet/rbi/gems/yard@0.9.34.rbi +46 -50
- data/sorbet/tapioca/require.rb +6 -1
- metadata +9 -34
- data/docs/Mangrove/ControlFlow/ControlSignal.html +0 -223
- data/docs/Mangrove/ControlFlow/Handler/ClassMethods.html +0 -563
- data/docs/Mangrove/ControlFlow/Handler.html +0 -139
- data/docs/Mangrove/ControlFlow/Rewriter.html +0 -331
- data/docs/Mangrove/ControlFlow.html +0 -115
- data/docs/Mangrove/Option/ControlSignal.html +0 -434
- data/docs/Mangrove/Option/None.html +0 -1085
- data/docs/Mangrove/Option/Some.html +0 -1202
- data/docs/Mangrove/Option.html +0 -1145
- data/docs/Mangrove/Result/ControlSignal.html +0 -434
- data/docs/Mangrove/Result/Err.html +0 -2254
- data/docs/Mangrove/Result/Ok.html +0 -2219
- data/docs/Mangrove/Result.html +0 -2475
- data/docs/Mangrove.html +0 -144
- data/docs/_index.html +0 -225
- data/docs/class_list.html +0 -51
- data/docs/css/common.css +0 -1
- data/docs/css/full_list.css +0 -58
- data/docs/css/style.css +0 -497
- data/docs/file.README.html +0 -245
- data/docs/file_list.html +0 -56
- data/docs/frames.html +0 -17
- data/docs/index.html +0 -245
- data/docs/js/app.js +0 -314
- data/docs/js/full_list.js +0 -216
- data/docs/js/jquery.js +0 -4
- data/docs/method_list.html +0 -939
- data/docs/top-level-namespace.html +0 -110
- data/sorbet/rbi/gems/yarp@0.13.0.rbi +0 -21646
- data/sorbet/rbi/shims/mangrove/option.rbi +0 -15
- data/sorbet/rbi/shims/mangrove/result.rbi +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01155ce389be568b548bdbf4fa40a029c4ff6575f9dfa41bba52c1f75bb2d6c5
|
4
|
+
data.tar.gz: 6af2e06f168ca3406e884e3d751b3c21fecf0fbfc0487bca24fa8e7fca08839d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12df1c2a68dd9ffdc95a24a3db8ef1d651da0bdc557ec608ed2240d2f1efd2728f831a31a3843eb2dc34eb25559787e3dc6e09f1aad5c6aecd0a38d26eee7fa2
|
7
|
+
data.tar.gz: 29e3d2fe898d9c5a7376001b2b6f7844ad7ecd55a49efd18caed98fc4ddf09cbd05dc274f118486d7fc5ba491944d055c9dc319949ee001e5339c45b8d674639
|
data/README.md
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
Mangrove provides type utility to use with Sorbet.
|
3
3
|
use `rubocop-mangrove` to statically check rescuing ControlSignal is done
|
4
4
|
|
5
|
+
- [Documentation](https://kazzix14.github.io/mangrove/docs/)
|
6
|
+
- [Coverage](https://kazzix14.github.io/mangrove/coverage/index.html#_AllFiles)
|
7
|
+
|
5
8
|
You can do something like this with the gem.
|
6
9
|
```ruby
|
7
10
|
class TransposeExample
|
data/lib/mangrove/result.rb
CHANGED
@@ -69,6 +69,18 @@ module Mangrove
|
|
69
69
|
sig { abstract.type_parameters(:NewOkType).params(_t_new_ok: T::Class[T.type_parameter(:NewOkType)], block: T.proc.params(this: OkType).returns(Result[T.type_parameter(:NewOkType), ErrType])).returns(Result[T.type_parameter(:NewOkType), ErrType]) }
|
70
70
|
def and_then_wt(_t_new_ok, &block); end
|
71
71
|
|
72
|
+
sig {
|
73
|
+
abstract
|
74
|
+
.params(
|
75
|
+
new_err_inner: ErrType,
|
76
|
+
condition: T.proc.params(inner: OkType).returns(T::Boolean)
|
77
|
+
)
|
78
|
+
.returns(
|
79
|
+
Result[OkType, ErrType]
|
80
|
+
)
|
81
|
+
}
|
82
|
+
def and_err_if(new_err_inner, &condition); end
|
83
|
+
|
72
84
|
sig { abstract.params(other: Result[OkType, ErrType]).returns(Result[OkType, ErrType]) }
|
73
85
|
def or(other); end
|
74
86
|
|
@@ -78,6 +90,18 @@ module Mangrove
|
|
78
90
|
sig { abstract.type_parameters(:NewErrType).params(_t_new_err: T::Class[T.type_parameter(:NewErrType)], block: T.proc.params(this: ErrType).returns(Result[OkType, T.type_parameter(:NewErrType)])).returns(Result[OkType, T.type_parameter(:NewErrType)]) }
|
79
91
|
def or_else_wt(_t_new_err, &block); end
|
80
92
|
|
93
|
+
sig {
|
94
|
+
abstract
|
95
|
+
.params(
|
96
|
+
new_ok_inner: OkType,
|
97
|
+
condition: T.proc.params(inner: ErrType).returns(T::Boolean)
|
98
|
+
)
|
99
|
+
.returns(
|
100
|
+
Result[OkType, ErrType]
|
101
|
+
)
|
102
|
+
}
|
103
|
+
def or_ok_if(new_ok_inner, &condition); end
|
104
|
+
|
81
105
|
class << self
|
82
106
|
extend T::Sig
|
83
107
|
extend T::Generic
|
@@ -198,7 +222,7 @@ module Mangrove
|
|
198
222
|
Result::Ok[T.type_parameter(:NewOkType), ErrType].new(block.call(@inner))
|
199
223
|
end
|
200
224
|
|
201
|
-
# Because sorbet deduct types from return values well. This method takes a type of new inner values.
|
225
|
+
# Because sorbet does not deduct types from return values well. This method takes a type of new inner values.
|
202
226
|
sig { override.type_parameters(:NewOkType).params(_t_new_ok: T::Class[T.type_parameter(:NewOkType)], block: T.proc.params(this: OkType).returns(T.type_parameter(:NewOkType))).returns(Result[T.type_parameter(:NewOkType), ErrType]) }
|
203
227
|
def map_ok_wt(_t_new_ok, &block)
|
204
228
|
Result::Ok[T.type_parameter(:NewOkType), ErrType].new(block.call(@inner))
|
@@ -209,7 +233,7 @@ module Mangrove
|
|
209
233
|
T.cast(self, Result::Ok[OkType, T.type_parameter(:NewErrType)])
|
210
234
|
end
|
211
235
|
|
212
|
-
# Because sorbet deduct types from return values well. This method takes a type of new inner values.
|
236
|
+
# Because sorbet does not deduct types from return values well. This method takes a type of new inner values.
|
213
237
|
sig { override.type_parameters(:NewErrType).params(_t_new_err: T::Class[T.type_parameter(:NewErrType)], _block: T.proc.params(this: ErrType).returns(T.type_parameter(:NewErrType))).returns(Result[OkType, T.type_parameter(:NewErrType)]) }
|
214
238
|
def map_err_wt(_t_new_err, &_block)
|
215
239
|
T.cast(self, Result::Ok[OkType, T.type_parameter(:NewErrType)])
|
@@ -230,6 +254,24 @@ module Mangrove
|
|
230
254
|
block.call(@inner)
|
231
255
|
end
|
232
256
|
|
257
|
+
sig {
|
258
|
+
override
|
259
|
+
.params(
|
260
|
+
new_err_inner: ErrType,
|
261
|
+
condition: T.proc.params(inner: OkType).returns(T::Boolean)
|
262
|
+
)
|
263
|
+
.returns(
|
264
|
+
Result[OkType, ErrType]
|
265
|
+
)
|
266
|
+
}
|
267
|
+
def and_err_if(new_err_inner, &condition)
|
268
|
+
if condition.call(@inner)
|
269
|
+
Result::Err[OkType, ErrType].new(new_err_inner)
|
270
|
+
else
|
271
|
+
self
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
233
275
|
sig { override.params(_other: Result[OkType, ErrType]).returns(Result[OkType, ErrType]) }
|
234
276
|
def or(_other)
|
235
277
|
self
|
@@ -245,6 +287,20 @@ module Mangrove
|
|
245
287
|
T.cast(self, Result::Ok[OkType, T.type_parameter(:NewErrType)])
|
246
288
|
end
|
247
289
|
|
290
|
+
sig {
|
291
|
+
override
|
292
|
+
.params(
|
293
|
+
_new_ok_inner: OkType,
|
294
|
+
_condition: T.proc.params(inner: ErrType).returns(T::Boolean)
|
295
|
+
)
|
296
|
+
.returns(
|
297
|
+
Result::Ok[OkType, ErrType]
|
298
|
+
)
|
299
|
+
}
|
300
|
+
def or_ok_if(_new_ok_inner, &_condition)
|
301
|
+
self
|
302
|
+
end
|
303
|
+
|
248
304
|
sig { returns(String) }
|
249
305
|
def to_s
|
250
306
|
"#{super}: inner=`#{@inner}`"
|
@@ -330,7 +386,7 @@ module Mangrove
|
|
330
386
|
T.cast(self, Result::Err[T.type_parameter(:NewOkType), ErrType])
|
331
387
|
end
|
332
388
|
|
333
|
-
# Because sorbet deduct types from return values well. This method takes a type of new inner values.
|
389
|
+
# Because sorbet does not deduct types from return values well. This method takes a type of new inner values.
|
334
390
|
sig { override.type_parameters(:NewOkType).params(_t_new_ok: T::Class[T.type_parameter(:NewOkType)], _block: T.proc.params(this: OkType).returns(T.type_parameter(:NewOkType))).returns(Result[T.type_parameter(:NewOkType), ErrType]) }
|
335
391
|
def map_ok_wt(_t_new_ok, &_block)
|
336
392
|
T.cast(self, Result::Err[T.type_parameter(:NewOkType), ErrType])
|
@@ -341,6 +397,7 @@ module Mangrove
|
|
341
397
|
Result::Err[OkType, T.type_parameter(:NewErrType)].new(block.call(@inner))
|
342
398
|
end
|
343
399
|
|
400
|
+
# Because sorbet does not deduct types from return values well. This method takes a type of new inner values.
|
344
401
|
sig { override.type_parameters(:NewErrType).params(_t_new_err: T::Class[T.type_parameter(:NewErrType)], block: T.proc.params(this: ErrType).returns(T.type_parameter(:NewErrType))).returns(Result[OkType, T.type_parameter(:NewErrType)]) }
|
345
402
|
def map_err_wt(_t_new_err, &block)
|
346
403
|
Result::Err[OkType, T.type_parameter(:NewErrType)].new(block.call(@inner))
|
@@ -361,6 +418,20 @@ module Mangrove
|
|
361
418
|
T.cast(self, Result::Err[T.type_parameter(:NewOkType), ErrType])
|
362
419
|
end
|
363
420
|
|
421
|
+
sig {
|
422
|
+
override
|
423
|
+
.params(
|
424
|
+
_new_err_inner: ErrType,
|
425
|
+
_condition: T.proc.params(inner: OkType).returns(T::Boolean)
|
426
|
+
)
|
427
|
+
.returns(
|
428
|
+
Result::Err[OkType, ErrType]
|
429
|
+
)
|
430
|
+
}
|
431
|
+
def and_err_if(_new_err_inner, &_condition)
|
432
|
+
self
|
433
|
+
end
|
434
|
+
|
364
435
|
sig { override.params(other: Result[OkType, ErrType]).returns(Result[OkType, ErrType]) }
|
365
436
|
def or(other)
|
366
437
|
other
|
@@ -376,6 +447,24 @@ module Mangrove
|
|
376
447
|
block.call(@inner)
|
377
448
|
end
|
378
449
|
|
450
|
+
sig {
|
451
|
+
override
|
452
|
+
.params(
|
453
|
+
new_ok_inner: OkType,
|
454
|
+
condition: T.proc.params(inner: ErrType).returns(T::Boolean)
|
455
|
+
)
|
456
|
+
.returns(
|
457
|
+
Result[OkType, ErrType]
|
458
|
+
)
|
459
|
+
}
|
460
|
+
def or_ok_if(new_ok_inner, &condition)
|
461
|
+
if condition.call(@inner)
|
462
|
+
Result::Ok[OkType, ErrType].new(new_ok_inner)
|
463
|
+
else
|
464
|
+
self
|
465
|
+
end
|
466
|
+
end
|
467
|
+
|
379
468
|
sig { returns(String) }
|
380
469
|
def to_s
|
381
470
|
"#{super}: inner=`#{@inner}`"
|
data/lib/mangrove/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
**/*.rbi linguist-vendored=true
|
@@ -522,7 +522,7 @@ Diff::LCS::Change::VALID_ACTIONS = T.let(T.unsafe(nil), Array)
|
|
522
522
|
# elements in the old and the new sequenced enumerables as well as the action
|
523
523
|
# taken.
|
524
524
|
#
|
525
|
-
# source://diff-lcs//lib/diff/lcs/change.rb#
|
525
|
+
# source://diff-lcs//lib/diff/lcs/change.rb#101
|
526
526
|
class Diff::LCS::ContextChange < ::Diff::LCS::Change
|
527
527
|
# @return [ContextChange] a new instance of ContextChange
|
528
528
|
#
|
@@ -692,10 +692,6 @@ class Diff::LCS::DefaultCallbacks
|
|
692
692
|
#
|
693
693
|
# source://diff-lcs//lib/diff/lcs/callbacks.rb#17
|
694
694
|
def match(event); end
|
695
|
-
|
696
|
-
private
|
697
|
-
|
698
|
-
def new(*_arg0); end
|
699
695
|
end
|
700
696
|
end
|
701
697
|
|
@@ -0,0 +1,376 @@
|
|
1
|
+
# typed: true
|
2
|
+
|
3
|
+
# DO NOT EDIT MANUALLY
|
4
|
+
# This is an autogenerated file for types exported from the `docile` gem.
|
5
|
+
# Please instead update this file by running `bin/tapioca gem docile`.
|
6
|
+
|
7
|
+
# Docile keeps your Ruby DSLs tame and well-behaved.
|
8
|
+
#
|
9
|
+
# source://docile//lib/docile/version.rb#3
|
10
|
+
module Docile
|
11
|
+
extend ::Docile::Execution
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
# Execute a block in the context of an object whose methods represent the
|
16
|
+
# commands in a DSL.
|
17
|
+
#
|
18
|
+
# Use this method to execute an *imperative* DSL, which means that:
|
19
|
+
#
|
20
|
+
# 1. Each command mutates the state of the DSL context object
|
21
|
+
# 2. The return value of each command is ignored
|
22
|
+
# 3. The final return value is the original context object
|
23
|
+
#
|
24
|
+
# @example Use a String as a DSL
|
25
|
+
# Docile.dsl_eval("Hello, world!") do
|
26
|
+
# reverse!
|
27
|
+
# upcase!
|
28
|
+
# end
|
29
|
+
# #=> "!DLROW ,OLLEH"
|
30
|
+
# @example Use an Array as a DSL
|
31
|
+
# Docile.dsl_eval([]) do
|
32
|
+
# push 1
|
33
|
+
# push 2
|
34
|
+
# pop
|
35
|
+
# push 3
|
36
|
+
# end
|
37
|
+
# #=> [1, 3]
|
38
|
+
# @note Use with an *imperative* DSL (commands modify the context object)
|
39
|
+
# @param dsl [Object] context object whose methods make up the DSL
|
40
|
+
# @param args [Array] arguments to be passed to the block
|
41
|
+
# @param block [Proc] the block of DSL commands to be executed against the
|
42
|
+
# `dsl` context object
|
43
|
+
# @return [Object] the `dsl` context object after executing the block
|
44
|
+
#
|
45
|
+
# source://docile//lib/docile.rb#45
|
46
|
+
def dsl_eval(dsl, *args, **_arg2, &block); end
|
47
|
+
|
48
|
+
# Execute a block in the context of an immutable object whose methods,
|
49
|
+
# and the methods of their return values, represent the commands in a DSL.
|
50
|
+
#
|
51
|
+
# Use this method to execute a *functional* DSL, which means that:
|
52
|
+
#
|
53
|
+
# 1. The original DSL context object is never mutated
|
54
|
+
# 2. Each command returns the next DSL context object
|
55
|
+
# 3. The final return value is the value returned by the last command
|
56
|
+
#
|
57
|
+
# @example Use a frozen String as a DSL
|
58
|
+
# Docile.dsl_eval_immutable("I'm immutable!".freeze) do
|
59
|
+
# reverse
|
60
|
+
# upcase
|
61
|
+
# end
|
62
|
+
# #=> "!ELBATUMMI M'I"
|
63
|
+
# @example Use a Float as a DSL
|
64
|
+
# Docile.dsl_eval_immutable(84.5) do
|
65
|
+
# fdiv(2)
|
66
|
+
# floor
|
67
|
+
# end
|
68
|
+
# #=> 42
|
69
|
+
# @note Use with a *functional* DSL (commands return successor
|
70
|
+
# context objects)
|
71
|
+
# @param dsl [Object] immutable context object whose methods make up the
|
72
|
+
# initial DSL
|
73
|
+
# @param args [Array] arguments to be passed to the block
|
74
|
+
# @param block [Proc] the block of DSL commands to be executed against the
|
75
|
+
# `dsl` context object and successor return values
|
76
|
+
# @return [Object] the return value of the final command in the block
|
77
|
+
#
|
78
|
+
# source://docile//lib/docile.rb#128
|
79
|
+
def dsl_eval_immutable(dsl, *args, **_arg2, &block); end
|
80
|
+
|
81
|
+
# Execute a block in the context of an object whose methods represent the
|
82
|
+
# commands in a DSL, and return *the block's return value*.
|
83
|
+
#
|
84
|
+
# Use this method to execute an *imperative* DSL, which means that:
|
85
|
+
#
|
86
|
+
# 1. Each command mutates the state of the DSL context object
|
87
|
+
# 2. The return value of each command is ignored
|
88
|
+
# 3. The final return value is the original context object
|
89
|
+
#
|
90
|
+
# @example Use a String as a DSL
|
91
|
+
# Docile.dsl_eval_with_block_return("Hello, world!") do
|
92
|
+
# reverse!
|
93
|
+
# upcase!
|
94
|
+
# first
|
95
|
+
# end
|
96
|
+
# #=> "!"
|
97
|
+
# @example Use an Array as a DSL
|
98
|
+
# Docile.dsl_eval_with_block_return([]) do
|
99
|
+
# push "a"
|
100
|
+
# push "b"
|
101
|
+
# pop
|
102
|
+
# push "c"
|
103
|
+
# length
|
104
|
+
# end
|
105
|
+
# #=> 2
|
106
|
+
# @note Use with an *imperative* DSL (commands modify the context object)
|
107
|
+
# @param dsl [Object] context object whose methods make up the DSL
|
108
|
+
# @param args [Array] arguments to be passed to the block
|
109
|
+
# @param block [Proc] the block of DSL commands to be executed against the
|
110
|
+
# `dsl` context object
|
111
|
+
# @return [Object] the return value from executing the block
|
112
|
+
#
|
113
|
+
# source://docile//lib/docile.rb#87
|
114
|
+
def dsl_eval_with_block_return(dsl, *args, **_arg2, &block); end
|
115
|
+
|
116
|
+
class << self
|
117
|
+
# Execute a block in the context of an object whose methods represent the
|
118
|
+
# commands in a DSL.
|
119
|
+
#
|
120
|
+
# Use this method to execute an *imperative* DSL, which means that:
|
121
|
+
#
|
122
|
+
# 1. Each command mutates the state of the DSL context object
|
123
|
+
# 2. The return value of each command is ignored
|
124
|
+
# 3. The final return value is the original context object
|
125
|
+
#
|
126
|
+
# @example Use a String as a DSL
|
127
|
+
# Docile.dsl_eval("Hello, world!") do
|
128
|
+
# reverse!
|
129
|
+
# upcase!
|
130
|
+
# end
|
131
|
+
# #=> "!DLROW ,OLLEH"
|
132
|
+
# @example Use an Array as a DSL
|
133
|
+
# Docile.dsl_eval([]) do
|
134
|
+
# push 1
|
135
|
+
# push 2
|
136
|
+
# pop
|
137
|
+
# push 3
|
138
|
+
# end
|
139
|
+
# #=> [1, 3]
|
140
|
+
# @note Use with an *imperative* DSL (commands modify the context object)
|
141
|
+
# @param dsl [Object] context object whose methods make up the DSL
|
142
|
+
# @param args [Array] arguments to be passed to the block
|
143
|
+
# @param block [Proc] the block of DSL commands to be executed against the
|
144
|
+
# `dsl` context object
|
145
|
+
# @return [Object] the `dsl` context object after executing the block
|
146
|
+
#
|
147
|
+
# source://docile//lib/docile.rb#45
|
148
|
+
def dsl_eval(dsl, *args, **_arg2, &block); end
|
149
|
+
|
150
|
+
# Execute a block in the context of an immutable object whose methods,
|
151
|
+
# and the methods of their return values, represent the commands in a DSL.
|
152
|
+
#
|
153
|
+
# Use this method to execute a *functional* DSL, which means that:
|
154
|
+
#
|
155
|
+
# 1. The original DSL context object is never mutated
|
156
|
+
# 2. Each command returns the next DSL context object
|
157
|
+
# 3. The final return value is the value returned by the last command
|
158
|
+
#
|
159
|
+
# @example Use a frozen String as a DSL
|
160
|
+
# Docile.dsl_eval_immutable("I'm immutable!".freeze) do
|
161
|
+
# reverse
|
162
|
+
# upcase
|
163
|
+
# end
|
164
|
+
# #=> "!ELBATUMMI M'I"
|
165
|
+
# @example Use a Float as a DSL
|
166
|
+
# Docile.dsl_eval_immutable(84.5) do
|
167
|
+
# fdiv(2)
|
168
|
+
# floor
|
169
|
+
# end
|
170
|
+
# #=> 42
|
171
|
+
# @note Use with a *functional* DSL (commands return successor
|
172
|
+
# context objects)
|
173
|
+
# @param dsl [Object] immutable context object whose methods make up the
|
174
|
+
# initial DSL
|
175
|
+
# @param args [Array] arguments to be passed to the block
|
176
|
+
# @param block [Proc] the block of DSL commands to be executed against the
|
177
|
+
# `dsl` context object and successor return values
|
178
|
+
# @return [Object] the return value of the final command in the block
|
179
|
+
#
|
180
|
+
# source://docile//lib/docile.rb#128
|
181
|
+
def dsl_eval_immutable(dsl, *args, **_arg2, &block); end
|
182
|
+
|
183
|
+
# Execute a block in the context of an object whose methods represent the
|
184
|
+
# commands in a DSL, and return *the block's return value*.
|
185
|
+
#
|
186
|
+
# Use this method to execute an *imperative* DSL, which means that:
|
187
|
+
#
|
188
|
+
# 1. Each command mutates the state of the DSL context object
|
189
|
+
# 2. The return value of each command is ignored
|
190
|
+
# 3. The final return value is the original context object
|
191
|
+
#
|
192
|
+
# @example Use a String as a DSL
|
193
|
+
# Docile.dsl_eval_with_block_return("Hello, world!") do
|
194
|
+
# reverse!
|
195
|
+
# upcase!
|
196
|
+
# first
|
197
|
+
# end
|
198
|
+
# #=> "!"
|
199
|
+
# @example Use an Array as a DSL
|
200
|
+
# Docile.dsl_eval_with_block_return([]) do
|
201
|
+
# push "a"
|
202
|
+
# push "b"
|
203
|
+
# pop
|
204
|
+
# push "c"
|
205
|
+
# length
|
206
|
+
# end
|
207
|
+
# #=> 2
|
208
|
+
# @note Use with an *imperative* DSL (commands modify the context object)
|
209
|
+
# @param dsl [Object] context object whose methods make up the DSL
|
210
|
+
# @param args [Array] arguments to be passed to the block
|
211
|
+
# @param block [Proc] the block of DSL commands to be executed against the
|
212
|
+
# `dsl` context object
|
213
|
+
# @return [Object] the return value from executing the block
|
214
|
+
#
|
215
|
+
# source://docile//lib/docile.rb#87
|
216
|
+
def dsl_eval_with_block_return(dsl, *args, **_arg2, &block); end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
# This is used to remove entries pointing to Docile's source files
|
221
|
+
# from {Exception#backtrace} and {Exception#backtrace_locations}.
|
222
|
+
#
|
223
|
+
# If {NoMethodError} is caught then the exception object will be extended
|
224
|
+
# by this module to add filter functionalities.
|
225
|
+
#
|
226
|
+
# @api private
|
227
|
+
#
|
228
|
+
# source://docile//lib/docile/backtrace_filter.rb#11
|
229
|
+
module Docile::BacktraceFilter
|
230
|
+
# @api private
|
231
|
+
#
|
232
|
+
# source://docile//lib/docile/backtrace_filter.rb#14
|
233
|
+
def backtrace; end
|
234
|
+
|
235
|
+
# @api private
|
236
|
+
#
|
237
|
+
# source://docile//lib/docile/backtrace_filter.rb#19
|
238
|
+
def backtrace_locations; end
|
239
|
+
end
|
240
|
+
|
241
|
+
# @api private
|
242
|
+
#
|
243
|
+
# source://docile//lib/docile/backtrace_filter.rb#12
|
244
|
+
Docile::BacktraceFilter::FILTER_PATTERN = T.let(T.unsafe(nil), Regexp)
|
245
|
+
|
246
|
+
# Operates in the same manner as {FallbackContextProxy}, but replacing
|
247
|
+
# the primary `receiver` object with the result of each proxied method.
|
248
|
+
#
|
249
|
+
# This is useful for implementing DSL evaluation for immutable context
|
250
|
+
# objects.
|
251
|
+
#
|
252
|
+
#
|
253
|
+
# @api private
|
254
|
+
# @see Docile.dsl_eval_immutable
|
255
|
+
#
|
256
|
+
# source://docile//lib/docile/chaining_fallback_context_proxy.rb#19
|
257
|
+
class Docile::ChainingFallbackContextProxy < ::Docile::FallbackContextProxy
|
258
|
+
# Proxy methods as in {FallbackContextProxy#method_missing}, replacing
|
259
|
+
# `receiver` with the returned value.
|
260
|
+
#
|
261
|
+
# @api private
|
262
|
+
#
|
263
|
+
# source://docile//lib/docile/chaining_fallback_context_proxy.rb#20
|
264
|
+
def method_missing(method, *args, **_arg2, &block); end
|
265
|
+
end
|
266
|
+
|
267
|
+
# A namespace for functions relating to the execution of a block against a
|
268
|
+
# proxy object.
|
269
|
+
#
|
270
|
+
# @api private
|
271
|
+
#
|
272
|
+
# source://docile//lib/docile/execution.rb#8
|
273
|
+
module Docile::Execution
|
274
|
+
private
|
275
|
+
|
276
|
+
# Execute a block in the context of an object whose methods represent the
|
277
|
+
# commands in a DSL, using a specific proxy class.
|
278
|
+
#
|
279
|
+
# @api private
|
280
|
+
# @param dsl [Object] context object whose methods make up the
|
281
|
+
# (initial) DSL
|
282
|
+
# @param proxy_type [FallbackContextProxy, ChainingFallbackContextProxy] which class to instantiate as proxy context
|
283
|
+
# @param args [Array] arguments to be passed to the block
|
284
|
+
# @param block [Proc] the block of DSL commands to be executed
|
285
|
+
# @return [Object] the return value of the block
|
286
|
+
#
|
287
|
+
# source://docile//lib/docile/execution.rb#19
|
288
|
+
def exec_in_proxy_context(dsl, proxy_type, *args, **_arg3, &block); end
|
289
|
+
|
290
|
+
class << self
|
291
|
+
# Execute a block in the context of an object whose methods represent the
|
292
|
+
# commands in a DSL, using a specific proxy class.
|
293
|
+
#
|
294
|
+
# @api private
|
295
|
+
# @param dsl [Object] context object whose methods make up the
|
296
|
+
# (initial) DSL
|
297
|
+
# @param proxy_type [FallbackContextProxy, ChainingFallbackContextProxy] which class to instantiate as proxy context
|
298
|
+
# @param args [Array] arguments to be passed to the block
|
299
|
+
# @param block [Proc] the block of DSL commands to be executed
|
300
|
+
# @return [Object] the return value of the block
|
301
|
+
#
|
302
|
+
# source://docile//lib/docile/execution.rb#19
|
303
|
+
def exec_in_proxy_context(dsl, proxy_type, *args, **_arg3, &block); end
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
# A proxy object with a primary receiver as well as a secondary
|
308
|
+
# fallback receiver.
|
309
|
+
#
|
310
|
+
# Will attempt to forward all method calls first to the primary receiver,
|
311
|
+
# and then to the fallback receiver if the primary does not handle that
|
312
|
+
# method.
|
313
|
+
#
|
314
|
+
# This is useful for implementing DSL evaluation in the context of an object.
|
315
|
+
#
|
316
|
+
#
|
317
|
+
# @api private
|
318
|
+
# @see Docile.dsl_eval
|
319
|
+
#
|
320
|
+
# source://docile//lib/docile/fallback_context_proxy.rb#20
|
321
|
+
class Docile::FallbackContextProxy
|
322
|
+
# @api private
|
323
|
+
# @param receiver [Object] the primary proxy target to which all methods
|
324
|
+
# initially will be forwarded
|
325
|
+
# @param fallback [Object] the fallback proxy target to which any methods
|
326
|
+
# not handled by `receiver` will be forwarded
|
327
|
+
# @return [FallbackContextProxy] a new instance of FallbackContextProxy
|
328
|
+
#
|
329
|
+
# source://docile//lib/docile/fallback_context_proxy.rb#46
|
330
|
+
def initialize(receiver, fallback); end
|
331
|
+
|
332
|
+
# @api private
|
333
|
+
# @return [Array<Symbol>] Instance variable names, excluding
|
334
|
+
# {NON_PROXIED_INSTANCE_VARIABLES}
|
335
|
+
#
|
336
|
+
# source://docile//lib/docile/fallback_context_proxy.rb#85
|
337
|
+
def instance_variables; end
|
338
|
+
|
339
|
+
# Proxy all methods, excluding {NON_PROXIED_METHODS}, first to `receiver`
|
340
|
+
# and then to `fallback` if not found.
|
341
|
+
#
|
342
|
+
# @api private
|
343
|
+
#
|
344
|
+
# source://docile//lib/docile/fallback_context_proxy.rb#91
|
345
|
+
def method_missing(method, *args, **_arg2, &block); end
|
346
|
+
end
|
347
|
+
|
348
|
+
# The set of methods which will **not** fallback from the block's context
|
349
|
+
# to the dsl object.
|
350
|
+
#
|
351
|
+
# @api private
|
352
|
+
#
|
353
|
+
# source://docile//lib/docile/fallback_context_proxy.rb#30
|
354
|
+
Docile::FallbackContextProxy::NON_FALLBACK_METHODS = T.let(T.unsafe(nil), Set)
|
355
|
+
|
356
|
+
# The set of instance variables which are local to this object and hidden.
|
357
|
+
# All other instance variables will be copied in and out of this object
|
358
|
+
# from the scope in which this proxy was created.
|
359
|
+
#
|
360
|
+
# @api private
|
361
|
+
#
|
362
|
+
# source://docile//lib/docile/fallback_context_proxy.rb#35
|
363
|
+
Docile::FallbackContextProxy::NON_PROXIED_INSTANCE_VARIABLES = T.let(T.unsafe(nil), Set)
|
364
|
+
|
365
|
+
# The set of methods which will **not** be proxied, but instead answered
|
366
|
+
# by this object directly.
|
367
|
+
#
|
368
|
+
# @api private
|
369
|
+
#
|
370
|
+
# source://docile//lib/docile/fallback_context_proxy.rb#23
|
371
|
+
Docile::FallbackContextProxy::NON_PROXIED_METHODS = T.let(T.unsafe(nil), Set)
|
372
|
+
|
373
|
+
# The current version of this library
|
374
|
+
#
|
375
|
+
# source://docile//lib/docile/version.rb#5
|
376
|
+
Docile::VERSION = T.let(T.unsafe(nil), String)
|