u-struct 1.0.0 → 1.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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +5 -5
- data/.rubocop.yml +129 -0
- data/.rubocop_todo.yml +10 -0
- data/.tool-versions +1 -0
- data/CHANGELOG.md +115 -27
- data/Gemfile +14 -3
- data/README.md +166 -62
- data/Rakefile +5 -5
- data/bin/console +3 -3
- data/bin/prepare_coverage +7 -9
- data/bin/run_ci +17 -0
- data/bin/tapioca +28 -0
- data/examples/rgb/number.rb +1 -1
- data/examples/rgb_1.rb +3 -3
- data/examples/rgb_2.rb +2 -2
- data/examples/rgb_3.rb +1 -1
- data/lib/micro/struct/factory/create_struct.rb +12 -5
- data/lib/micro/struct/factory/members.rb +1 -0
- data/lib/micro/struct/factory.rb +10 -5
- data/lib/micro/struct/features.rb +18 -23
- data/lib/micro/struct/normalize_names.rb +4 -3
- data/lib/micro/struct/version.rb +2 -1
- data/lib/micro/struct.rb +32 -5
- data/lib/u-struct.rb +2 -0
- data/rbi/micro/struct/factory/create_struct.rbi +60 -0
- data/rbi/micro/struct/factory/members.rbi +67 -0
- data/rbi/micro/struct/factory.rbi +41 -0
- data/rbi/micro/struct/features.rbi +41 -0
- data/rbi/micro/struct/normalize_names.rbi +20 -0
- data/rbi/micro/struct/version.rbi +3 -0
- data/rbi/micro/struct.rbi +68 -0
- data/sorbet/config +8 -0
- data/sorbet/rbi/gems/ast@2.4.2.rbi +54 -0
- data/sorbet/rbi/gems/coderay@1.1.3.rbi +8 -0
- data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +11 -0
- data/sorbet/rbi/gems/docile@1.4.0.rbi +54 -0
- data/sorbet/rbi/gems/method_source@1.0.0.rbi +8 -0
- data/sorbet/rbi/gems/minitest@5.15.0.rbi +345 -0
- data/sorbet/rbi/gems/parser@3.1.0.0.rbi +1196 -0
- data/sorbet/rbi/gems/pry@0.14.1.rbi +8 -0
- data/sorbet/rbi/gems/rake@13.0.6.rbi +806 -0
- data/sorbet/rbi/gems/rbi@0.0.9.rbi +1602 -0
- data/sorbet/rbi/gems/simplecov-html@0.12.3.rbi +89 -0
- data/sorbet/rbi/gems/simplecov@0.21.2.rbi +577 -0
- data/sorbet/rbi/gems/simplecov_json_formatter@0.1.3.rbi +8 -0
- data/sorbet/rbi/gems/spoom@1.1.8.rbi +1252 -0
- data/sorbet/rbi/gems/tapioca@0.6.2.rbi +1232 -0
- data/sorbet/rbi/gems/thor@1.2.1.rbi +844 -0
- data/sorbet/rbi/gems/unparser@0.6.3.rbi +8 -0
- data/sorbet/rbi/gems/webrick@1.7.0.rbi +601 -0
- data/sorbet/rbi/gems/yard-sorbet@0.6.1.rbi +199 -0
- data/sorbet/rbi/gems/yard@0.9.27.rbi +4112 -0
- data/sorbet/tapioca/config.yml +13 -0
- data/sorbet/tapioca/require.rb +4 -0
- data/u-struct.gemspec +3 -3
- metadata +37 -3
- data/bin/test +0 -8
@@ -1,3 +1,4 @@
|
|
1
|
+
# typed: true
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Micro::Struct
|
@@ -5,11 +6,11 @@ module Micro::Struct
|
|
5
6
|
module CreateStruct
|
6
7
|
extend self
|
7
8
|
|
8
|
-
def with(members,
|
9
|
-
struct =
|
9
|
+
def with(members, features, struct_block)
|
10
|
+
struct = create_struct(members)
|
10
11
|
|
11
12
|
ClassScope.def_new(struct, members)
|
12
|
-
|
13
|
+
|
13
14
|
ClassScope.def_features(struct, features) if features.is_a?(Features::Exposed)
|
14
15
|
ClassScope.def_to_proc(struct) if features.option?(:to_proc)
|
15
16
|
ClassScope.def_private_writers(struct) if features.option?(:readonly)
|
@@ -18,11 +19,17 @@ module Micro::Struct
|
|
18
19
|
InstanceScope.def_to_ary(struct) if features.option?(:to_ary)
|
19
20
|
InstanceScope.def_to_hash(struct) if features.option?(:to_hash)
|
20
21
|
|
21
|
-
ClassScope.evaluate(struct,
|
22
|
+
ClassScope.evaluate(struct, struct_block)
|
22
23
|
|
23
24
|
struct
|
24
25
|
end
|
25
26
|
|
27
|
+
private
|
28
|
+
|
29
|
+
def create_struct(members)
|
30
|
+
::Struct.new(*members.required_and_optional)
|
31
|
+
end
|
32
|
+
|
26
33
|
module ClassScope
|
27
34
|
def self.def_new(struct, members)
|
28
35
|
# The .new() method will require all required keyword arguments.
|
@@ -67,7 +74,7 @@ module Micro::Struct
|
|
67
74
|
|
68
75
|
def self.def_private_writers(struct)
|
69
76
|
struct.send(:private, :[]=)
|
70
|
-
struct.
|
77
|
+
struct.members.each { |member| struct.send(:private, "#{member}=") }
|
71
78
|
end
|
72
79
|
|
73
80
|
def self.evaluate(struct, block)
|
data/lib/micro/struct/factory.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# typed: true
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Micro::Struct
|
@@ -5,18 +6,22 @@ module Micro::Struct
|
|
5
6
|
require_relative 'factory/members'
|
6
7
|
require_relative 'factory/create_struct'
|
7
8
|
|
8
|
-
def initialize(
|
9
|
-
@features = Features.config(
|
9
|
+
def initialize(feature_names)
|
10
|
+
@features = Features.config(feature_names)
|
10
11
|
end
|
11
12
|
|
12
|
-
def
|
13
|
+
def __create__(required_members, required, optional, struct_block) # :nodoc:
|
13
14
|
members = Members.new(required_members, required, optional)
|
14
15
|
|
15
|
-
CreateStruct.with(members,
|
16
|
+
CreateStruct.with(members, @features, struct_block)
|
17
|
+
end
|
18
|
+
|
19
|
+
def new(*required_members, required: nil, optional: nil, &struct_block)
|
20
|
+
__create__(required_members, required, optional, struct_block)
|
16
21
|
end
|
17
22
|
|
18
23
|
def instance(**members, &block)
|
19
|
-
|
24
|
+
__create__(members.keys, nil, nil, block).new(**members)
|
20
25
|
end
|
21
26
|
end
|
22
27
|
|
@@ -1,29 +1,20 @@
|
|
1
|
+
# typed: true
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Micro::Struct
|
4
5
|
module Features
|
5
|
-
Names = ->(values) do
|
6
|
-
NormalizeNames::AsSymbols.(values, context: 'feature')
|
7
|
-
end
|
8
|
-
|
9
6
|
module Options
|
10
|
-
def self.
|
11
|
-
{
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
DISABLED = With.(false, method(:check).parameters.map(&:last)).freeze
|
22
|
-
|
23
|
-
def self.from_names(values)
|
24
|
-
enabled = With.(true, values)
|
25
|
-
|
26
|
-
check(**DISABLED.merge(enabled))
|
7
|
+
def self.from(names:)
|
8
|
+
options = names.each_with_object({}) { |name, memo| memo[name] = true }
|
9
|
+
|
10
|
+
{
|
11
|
+
to_ary: options.fetch(:to_ary, false),
|
12
|
+
to_hash: options.fetch(:to_hash, false),
|
13
|
+
to_proc: options.fetch(:to_proc, false),
|
14
|
+
readonly: options.fetch(:readonly, false),
|
15
|
+
instance_copy: options.fetch(:instance_copy, false),
|
16
|
+
exposed_features: options.fetch(:exposed_features, false)
|
17
|
+
}
|
27
18
|
end
|
28
19
|
end
|
29
20
|
|
@@ -31,7 +22,7 @@ module Micro::Struct
|
|
31
22
|
def option?(name)
|
32
23
|
options.fetch(name)
|
33
24
|
end
|
34
|
-
|
25
|
+
|
35
26
|
def options?(*names)
|
36
27
|
names.all? { |name| option?(name) }
|
37
28
|
end
|
@@ -39,9 +30,13 @@ module Micro::Struct
|
|
39
30
|
|
40
31
|
Exposed = Class.new(Config)
|
41
32
|
|
33
|
+
Names = ->(values) do
|
34
|
+
NormalizeNames::AsSymbols.(values, context: 'feature')
|
35
|
+
end
|
36
|
+
|
42
37
|
def self.config(values)
|
43
38
|
names = Names[values]
|
44
|
-
options = Options.
|
39
|
+
options = Options.from(names: names)
|
45
40
|
|
46
41
|
return Config.new(names, options) unless options[:exposed_features]
|
47
42
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
# typed: true
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Micro::Struct
|
@@ -5,10 +6,10 @@ module Micro::Struct
|
|
5
6
|
module AsSymbols
|
6
7
|
REGEXP = /\A[_A-Za-z]\w*\z/.freeze
|
7
8
|
Invalid = ->(context, val) { raise NameError.new("invalid #{context} name: #{val}") }
|
8
|
-
AsSymbol = ->(context, val) { REGEXP =~ val ? val.to_sym : Invalid[context, val] }
|
9
|
+
AsSymbol = ->(context, val) { REGEXP =~ val ? val.to_sym : Invalid[context, val] }
|
9
10
|
|
10
|
-
def self.call(
|
11
|
-
Array(
|
11
|
+
def self.call(arg, context:)
|
12
|
+
Array(arg).map { |values| AsSymbol[context, values] }
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
data/lib/micro/struct/version.rb
CHANGED
data/lib/micro/struct.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# typed: true
|
1
2
|
# frozen_string_literal: true
|
2
3
|
|
3
4
|
require_relative 'struct/version'
|
@@ -58,16 +59,42 @@ module Micro
|
|
58
59
|
#
|
59
60
|
# Micro::Struct.with(*features).new(...) {}
|
60
61
|
module Struct
|
61
|
-
|
62
|
-
|
62
|
+
extend self
|
63
|
+
|
64
|
+
def with(*feature_names)
|
65
|
+
factory(feature_names)
|
63
66
|
end
|
64
67
|
|
65
|
-
|
66
|
-
|
68
|
+
alias_method :[], :with
|
69
|
+
|
70
|
+
def new(*members, required: nil, optional: nil, &block)
|
71
|
+
with.__create__(members, required, optional, block)
|
67
72
|
end
|
68
73
|
|
69
|
-
def
|
74
|
+
def instance(**members, &block)
|
70
75
|
with.instance(**members, &block)
|
71
76
|
end
|
77
|
+
|
78
|
+
READONLY = [:readonly].freeze
|
79
|
+
IMMUTABLE = [:readonly, :instance_copy].freeze
|
80
|
+
EMPTY_ARRAY = [].freeze
|
81
|
+
|
82
|
+
def readonly(with: EMPTY_ARRAY)
|
83
|
+
factory(with, READONLY)
|
84
|
+
end
|
85
|
+
|
86
|
+
def immutable(with: EMPTY_ARRAY)
|
87
|
+
factory(with, IMMUTABLE)
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def factory(names, defaults = EMPTY_ARRAY)
|
93
|
+
features = ::Kernel.Array(names)
|
94
|
+
|
95
|
+
Factory.new(defaults.empty? ? features : defaults + features)
|
96
|
+
end
|
97
|
+
|
98
|
+
private_constant :READONLY, :IMMUTABLE, :EMPTY_ARRAY
|
72
99
|
end
|
73
100
|
end
|
data/lib/u-struct.rb
CHANGED
@@ -0,0 +1,60 @@
|
|
1
|
+
# typed: true
|
2
|
+
|
3
|
+
module Micro::Struct::Factory::CreateStruct
|
4
|
+
extend self
|
5
|
+
|
6
|
+
STRUCT_BLOCK = T.type_alias { T.nilable(T.proc.params(arg0: T.untyped).returns(T.untyped)) }
|
7
|
+
STRUCT_MEMBERS = T.type_alias { Micro::Struct::Factory::Members }
|
8
|
+
FEATURES_EXPOSED = T.type_alias { Micro::Struct::Features::Exposed }
|
9
|
+
FEATURES_CONFIG = T.type_alias { T.any(Micro::Struct::Features::Config, FEATURES_EXPOSED) }
|
10
|
+
|
11
|
+
sig {
|
12
|
+
params(
|
13
|
+
members: STRUCT_MEMBERS,
|
14
|
+
features: FEATURES_CONFIG,
|
15
|
+
struct_block: STRUCT_BLOCK
|
16
|
+
).returns(T.class_of(Struct))
|
17
|
+
}
|
18
|
+
def with(members, features, struct_block)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def create_struct(members); end
|
24
|
+
|
25
|
+
module ClassScope
|
26
|
+
sig { params(struct: T.class_of(Struct), members: STRUCT_MEMBERS).void }
|
27
|
+
def self.def_new(struct, members)
|
28
|
+
end
|
29
|
+
|
30
|
+
sig { params(struct: T.untyped, features: FEATURES_EXPOSED).void }
|
31
|
+
def self.def_features(struct, features)
|
32
|
+
end
|
33
|
+
|
34
|
+
sig { params(struct: T.class_of(Struct)).void }
|
35
|
+
def self.def_to_proc(struct)
|
36
|
+
end
|
37
|
+
|
38
|
+
sig { params(struct: T.class_of(Struct)).void }
|
39
|
+
def self.def_private_writers(struct)
|
40
|
+
end
|
41
|
+
|
42
|
+
sig { params(struct: T.class_of(Struct), block: STRUCT_BLOCK).void }
|
43
|
+
def self.evaluate(struct, block)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
module InstanceScope
|
48
|
+
sig { params(struct: T.class_of(Struct)).void }
|
49
|
+
def self.def_to_ary(struct)
|
50
|
+
end
|
51
|
+
|
52
|
+
sig { params(struct: T.class_of(Struct)).void }
|
53
|
+
def self.def_to_hash(struct)
|
54
|
+
end
|
55
|
+
|
56
|
+
sig { params(struct: T.class_of(Struct)).void }
|
57
|
+
def self.def_with(struct)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
class Micro::Struct::Factory::Members
|
4
|
+
STR_OR_SYMBOL = T.type_alias { T.any(String, Symbol) }
|
5
|
+
MEMBER_NAMES = T.type_alias { T.any(STR_OR_SYMBOL, T::Array[STR_OR_SYMBOL]) }
|
6
|
+
|
7
|
+
sig { returns(T::Array[Symbol]) }
|
8
|
+
attr_reader :required_and_optional
|
9
|
+
|
10
|
+
Names = T.let(T.unsafe, T.proc.params(arg0: T.nilable(MEMBER_NAMES)).returns(T::Array[Symbol]))
|
11
|
+
|
12
|
+
sig {
|
13
|
+
params(
|
14
|
+
required_members: T::Array[STR_OR_SYMBOL],
|
15
|
+
required_option: T.nilable(MEMBER_NAMES),
|
16
|
+
optional_option: T.nilable(MEMBER_NAMES)
|
17
|
+
).void
|
18
|
+
}
|
19
|
+
def initialize(required_members, required_option, optional_option)
|
20
|
+
end
|
21
|
+
|
22
|
+
class ToEval < ::Struct
|
23
|
+
extend T::Generic
|
24
|
+
|
25
|
+
sig {
|
26
|
+
params(
|
27
|
+
required: T::Array[Symbol],
|
28
|
+
optional: T::Array[Symbol],
|
29
|
+
required_and_optional: T::Array[Symbol]
|
30
|
+
).void
|
31
|
+
}
|
32
|
+
def initialize(required, optional, required_and_optional)
|
33
|
+
end
|
34
|
+
|
35
|
+
sig { returns(T::Array[Symbol]) }
|
36
|
+
def required
|
37
|
+
end
|
38
|
+
|
39
|
+
sig { returns(T::Array[Symbol]) }
|
40
|
+
def optional
|
41
|
+
end
|
42
|
+
|
43
|
+
sig { returns(T::Array[Symbol]) }
|
44
|
+
def required_and_optional
|
45
|
+
end
|
46
|
+
|
47
|
+
sig { params(name: Symbol).returns(T::Boolean) }
|
48
|
+
def option?(name)
|
49
|
+
end
|
50
|
+
|
51
|
+
sig { params(names: Symbol).returns(T::Boolean) }
|
52
|
+
def options?(*names)
|
53
|
+
end
|
54
|
+
|
55
|
+
sig { returns(String) }
|
56
|
+
def keyword_args
|
57
|
+
end
|
58
|
+
|
59
|
+
sig { returns(String) }
|
60
|
+
def positional_args
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
sig { returns(ToEval) }
|
65
|
+
def to_eval
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
class Micro::Struct::Factory
|
4
|
+
STR_OR_SYMBOL = T.type_alias { T.any(String, Symbol) }
|
5
|
+
MEMBER_NAMES = T.type_alias { T.any(STR_OR_SYMBOL, T::Array[STR_OR_SYMBOL]) }
|
6
|
+
STRUCT_BLOCK = T.type_alias { T.nilable(T.proc.params(arg0: T.untyped).returns(T.untyped)) }
|
7
|
+
|
8
|
+
sig {
|
9
|
+
params(feature_names: T::Array[T.any(String, Symbol)]).void
|
10
|
+
}
|
11
|
+
def initialize(feature_names)
|
12
|
+
end
|
13
|
+
|
14
|
+
sig { params(members: T.untyped, block: STRUCT_BLOCK).returns(Struct) }
|
15
|
+
def instance(**members, &block)
|
16
|
+
end
|
17
|
+
|
18
|
+
sig {
|
19
|
+
params(
|
20
|
+
required_members: STR_OR_SYMBOL,
|
21
|
+
required: T.nilable(MEMBER_NAMES),
|
22
|
+
optional: T.nilable(MEMBER_NAMES),
|
23
|
+
struct_block: STRUCT_BLOCK
|
24
|
+
)
|
25
|
+
.returns(T.class_of(Struct))
|
26
|
+
}
|
27
|
+
def new(*required_members, required: nil, optional: nil, &struct_block)
|
28
|
+
end
|
29
|
+
|
30
|
+
sig {
|
31
|
+
params(
|
32
|
+
required_members: T::Array[STR_OR_SYMBOL],
|
33
|
+
required: T.nilable(MEMBER_NAMES),
|
34
|
+
optional: T.nilable(MEMBER_NAMES),
|
35
|
+
struct_block: STRUCT_BLOCK
|
36
|
+
)
|
37
|
+
.returns(T.class_of(Struct))
|
38
|
+
}
|
39
|
+
def __create__(required_members, required, optional, struct_block)
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Micro::Struct::Features
|
4
|
+
FEAT_NAMES = T.type_alias { T::Array[Symbol] }
|
5
|
+
FEAT_OPTIONS = T.type_alias { T::Hash[Symbol, T::Boolean] }
|
6
|
+
STR_OR_SYMBOL = T.type_alias { T.any(String, Symbol) }
|
7
|
+
|
8
|
+
module Options
|
9
|
+
sig { params(names: FEAT_NAMES).returns(FEAT_OPTIONS) }
|
10
|
+
def from(names:)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Config < ::Struct
|
15
|
+
extend T::Generic
|
16
|
+
|
17
|
+
sig { params(names: FEAT_NAMES, options: FEAT_OPTIONS).void }
|
18
|
+
def initialize(names, options)
|
19
|
+
end
|
20
|
+
|
21
|
+
sig { returns(FEAT_NAMES) }
|
22
|
+
def names; end
|
23
|
+
|
24
|
+
sig { returns(FEAT_OPTIONS) }
|
25
|
+
def options; end
|
26
|
+
|
27
|
+
sig { params(name: Symbol).returns(T::Boolean) }
|
28
|
+
def option?(name); end
|
29
|
+
|
30
|
+
sig { params(names: Symbol).returns(T::Boolean) }
|
31
|
+
def options?(*names); end
|
32
|
+
end
|
33
|
+
|
34
|
+
Names = T.let(T.unsafe, T.proc.params(arg0: T::Array[STR_OR_SYMBOL]).returns(FEAT_NAMES))
|
35
|
+
|
36
|
+
sig {
|
37
|
+
params(values: T::Array[STR_OR_SYMBOL]).returns(T.any(Config, Exposed))
|
38
|
+
}
|
39
|
+
def self.config(values)
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Micro::Struct::NormalizeNames
|
4
|
+
module AsSymbols
|
5
|
+
STR_OR_SYMBOL = T.type_alias { T.any(String, Symbol) }
|
6
|
+
|
7
|
+
REGEXP = T.let(T.unsafe, Regexp)
|
8
|
+
Invalid = T.let(T.unsafe, T.proc.params(arg0: String, arg1: T.any(STR_OR_SYMBOL)).void)
|
9
|
+
AsSymbol = T.let(T.unsafe, T.proc.params(arg0: String, arg1: T.any(STR_OR_SYMBOL)).returns(Symbol))
|
10
|
+
|
11
|
+
sig {
|
12
|
+
params(
|
13
|
+
values: T.nilable(T.any(STR_OR_SYMBOL, T::Array[STR_OR_SYMBOL])),
|
14
|
+
context: String
|
15
|
+
).returns(T::Array[Symbol])
|
16
|
+
}
|
17
|
+
def self.call(values, context:)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Micro::Struct
|
4
|
+
STR_OR_SYMBOL = T.type_alias { T.any(String, Symbol) }
|
5
|
+
STRUCT_BLOCK = T.type_alias { T.nilable(T.proc.params(arg0: T.untyped).returns(T.untyped)) }
|
6
|
+
|
7
|
+
sig {
|
8
|
+
params(feature_names: Symbol).returns(Micro::Struct::Factory)
|
9
|
+
}
|
10
|
+
def self.with(*feature_names)
|
11
|
+
end
|
12
|
+
|
13
|
+
sig {
|
14
|
+
params(feature_names: Symbol).returns(Micro::Struct::Factory)
|
15
|
+
}
|
16
|
+
def self.[](*feature_names)
|
17
|
+
end
|
18
|
+
|
19
|
+
sig {
|
20
|
+
params(
|
21
|
+
members: STR_OR_SYMBOL,
|
22
|
+
required: T.nilable(T.any(STR_OR_SYMBOL, T::Array[STR_OR_SYMBOL])),
|
23
|
+
optional: T.nilable(T.any(STR_OR_SYMBOL, T::Array[STR_OR_SYMBOL])),
|
24
|
+
block: STRUCT_BLOCK
|
25
|
+
)
|
26
|
+
.returns(T.class_of(Struct))
|
27
|
+
}
|
28
|
+
def self.new(*members, required: nil, optional: nil, &block)
|
29
|
+
end
|
30
|
+
|
31
|
+
sig {
|
32
|
+
params(
|
33
|
+
members: T.untyped,
|
34
|
+
block: STRUCT_BLOCK
|
35
|
+
)
|
36
|
+
.returns(Struct)
|
37
|
+
}
|
38
|
+
def self.instance(**members, &block)
|
39
|
+
end
|
40
|
+
|
41
|
+
READONLY = T.let(T::Array[Symbol])
|
42
|
+
IMMUTABLE = T.let(T::Array[Symbol])
|
43
|
+
EMPTY_ARRAY = T.let(T::Array)
|
44
|
+
|
45
|
+
sig {
|
46
|
+
params(with: T::Array[Symbol]).returns(Micro::Struct::Factory)
|
47
|
+
}
|
48
|
+
def readonly(with: EMPTY_ARRAY)
|
49
|
+
end
|
50
|
+
|
51
|
+
sig {
|
52
|
+
params(with: T::Array[Symbol]).returns(Micro::Struct::Factory)
|
53
|
+
}
|
54
|
+
def immutable(with: EMPTY_ARRAY)
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
sig {
|
60
|
+
params(
|
61
|
+
names: T.nilable(T::Array[Symbol]),
|
62
|
+
defaults: T::Array[Symbol]
|
63
|
+
)
|
64
|
+
.returns(Micro::Struct::Factory)
|
65
|
+
}
|
66
|
+
def factory(names, defaults = EMPTY_ARRAY)
|
67
|
+
end
|
68
|
+
end
|
data/sorbet/config
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# typed: true
|
2
|
+
|
3
|
+
# DO NOT EDIT MANUALLY
|
4
|
+
# This is an autogenerated file for types exported from the `ast` gem.
|
5
|
+
# Please instead update this file by running `bin/tapioca gem ast`.
|
6
|
+
|
7
|
+
module AST; end
|
8
|
+
|
9
|
+
class AST::Node
|
10
|
+
def initialize(type, children = T.unsafe(nil), properties = T.unsafe(nil)); end
|
11
|
+
|
12
|
+
def +(array); end
|
13
|
+
def <<(element); end
|
14
|
+
def ==(other); end
|
15
|
+
def append(element); end
|
16
|
+
def children; end
|
17
|
+
def clone; end
|
18
|
+
def concat(array); end
|
19
|
+
def deconstruct; end
|
20
|
+
def dup; end
|
21
|
+
def eql?(other); end
|
22
|
+
def hash; end
|
23
|
+
def inspect(indent = T.unsafe(nil)); end
|
24
|
+
def to_a; end
|
25
|
+
def to_ast; end
|
26
|
+
def to_s(indent = T.unsafe(nil)); end
|
27
|
+
def to_sexp(indent = T.unsafe(nil)); end
|
28
|
+
def to_sexp_array; end
|
29
|
+
def type; end
|
30
|
+
def updated(type = T.unsafe(nil), children = T.unsafe(nil), properties = T.unsafe(nil)); end
|
31
|
+
|
32
|
+
protected
|
33
|
+
|
34
|
+
def assign_properties(properties); end
|
35
|
+
def fancy_type; end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def original_dup; end
|
40
|
+
end
|
41
|
+
|
42
|
+
class AST::Processor
|
43
|
+
include ::AST::Processor::Mixin
|
44
|
+
end
|
45
|
+
|
46
|
+
module AST::Processor::Mixin
|
47
|
+
def handler_missing(node); end
|
48
|
+
def process(node); end
|
49
|
+
def process_all(nodes); end
|
50
|
+
end
|
51
|
+
|
52
|
+
module AST::Sexp
|
53
|
+
def s(type, *children); end
|
54
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# typed: true
|
2
|
+
|
3
|
+
# DO NOT EDIT MANUALLY
|
4
|
+
# This is an autogenerated file for types exported from the `coderay` gem.
|
5
|
+
# Please instead update this file by running `bin/tapioca gem coderay`.
|
6
|
+
|
7
|
+
# THIS IS AN EMPTY RBI FILE.
|
8
|
+
# see https://github.com/Shopify/tapioca/wiki/Manual-Gem-Requires
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# typed: true
|
2
|
+
|
3
|
+
# DO NOT EDIT MANUALLY
|
4
|
+
# This is an autogenerated file for types exported from the `diff-lcs` gem.
|
5
|
+
# Please instead update this file by running `bin/tapioca gem diff-lcs`.
|
6
|
+
|
7
|
+
class Integer < ::Numeric
|
8
|
+
include ::JSON::Ext::Generator::GeneratorMethods::Integer
|
9
|
+
end
|
10
|
+
|
11
|
+
Integer::GMP_VERSION = T.let(T.unsafe(nil), String)
|
@@ -0,0 +1,54 @@
|
|
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
|
+
module Docile
|
8
|
+
extend ::Docile::Execution
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def dsl_eval(dsl, *args, &block); end
|
13
|
+
def dsl_eval_immutable(dsl, *args, &block); end
|
14
|
+
def dsl_eval_with_block_return(dsl, *args, &block); end
|
15
|
+
|
16
|
+
class << self
|
17
|
+
def dsl_eval(dsl, *args, &block); end
|
18
|
+
def dsl_eval_immutable(dsl, *args, &block); end
|
19
|
+
def dsl_eval_with_block_return(dsl, *args, &block); end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
module Docile::BacktraceFilter
|
24
|
+
def backtrace; end
|
25
|
+
def backtrace_locations; end
|
26
|
+
end
|
27
|
+
|
28
|
+
Docile::BacktraceFilter::FILTER_PATTERN = T.let(T.unsafe(nil), Regexp)
|
29
|
+
|
30
|
+
class Docile::ChainingFallbackContextProxy < ::Docile::FallbackContextProxy
|
31
|
+
def method_missing(method, *args, &block); end
|
32
|
+
end
|
33
|
+
|
34
|
+
module Docile::Execution
|
35
|
+
private
|
36
|
+
|
37
|
+
def exec_in_proxy_context(dsl, proxy_type, *args, &block); end
|
38
|
+
|
39
|
+
class << self
|
40
|
+
def exec_in_proxy_context(dsl, proxy_type, *args, &block); end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
class Docile::FallbackContextProxy
|
45
|
+
def initialize(receiver, fallback); end
|
46
|
+
|
47
|
+
def instance_variables; end
|
48
|
+
def method_missing(method, *args, &block); end
|
49
|
+
end
|
50
|
+
|
51
|
+
Docile::FallbackContextProxy::NON_FALLBACK_METHODS = T.let(T.unsafe(nil), Set)
|
52
|
+
Docile::FallbackContextProxy::NON_PROXIED_INSTANCE_VARIABLES = T.let(T.unsafe(nil), Set)
|
53
|
+
Docile::FallbackContextProxy::NON_PROXIED_METHODS = T.let(T.unsafe(nil), Set)
|
54
|
+
Docile::VERSION = T.let(T.unsafe(nil), String)
|