u-struct 0.11.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +5 -5
  3. data/.rubocop.yml +129 -0
  4. data/.rubocop_todo.yml +10 -0
  5. data/.tool-versions +1 -0
  6. data/CHANGELOG.md +558 -13
  7. data/Gemfile +14 -3
  8. data/README.md +682 -16
  9. data/Rakefile +5 -5
  10. data/bin/console +3 -3
  11. data/bin/prepare_coverage +7 -9
  12. data/bin/run_ci +17 -0
  13. data/bin/tapioca +28 -0
  14. data/examples/rgb/number.rb +1 -1
  15. data/examples/rgb_1.rb +7 -6
  16. data/examples/rgb_2.rb +2 -2
  17. data/examples/rgb_3.rb +1 -1
  18. data/lib/micro/struct/factory/create_struct.rb +95 -69
  19. data/lib/micro/struct/factory/members.rb +1 -0
  20. data/lib/micro/struct/factory.rb +13 -4
  21. data/lib/micro/struct/features.rb +35 -16
  22. data/lib/micro/struct/normalize_names.rb +4 -3
  23. data/lib/micro/struct/version.rb +2 -1
  24. data/lib/micro/struct.rb +37 -5
  25. data/lib/u-struct.rb +2 -0
  26. data/rbi/micro/struct/factory/create_struct.rbi +60 -0
  27. data/rbi/micro/struct/factory/members.rbi +67 -0
  28. data/rbi/micro/struct/factory.rbi +41 -0
  29. data/rbi/micro/struct/features.rbi +41 -0
  30. data/rbi/micro/struct/normalize_names.rbi +20 -0
  31. data/rbi/micro/struct/version.rbi +3 -0
  32. data/rbi/micro/struct.rbi +68 -0
  33. data/sorbet/config +8 -0
  34. data/sorbet/rbi/gems/ast@2.4.2.rbi +54 -0
  35. data/sorbet/rbi/gems/coderay@1.1.3.rbi +8 -0
  36. data/sorbet/rbi/gems/diff-lcs@1.5.0.rbi +11 -0
  37. data/sorbet/rbi/gems/docile@1.4.0.rbi +54 -0
  38. data/sorbet/rbi/gems/method_source@1.0.0.rbi +8 -0
  39. data/sorbet/rbi/gems/minitest@5.15.0.rbi +345 -0
  40. data/sorbet/rbi/gems/parser@3.1.0.0.rbi +1196 -0
  41. data/sorbet/rbi/gems/pry@0.14.1.rbi +8 -0
  42. data/sorbet/rbi/gems/rake@13.0.6.rbi +806 -0
  43. data/sorbet/rbi/gems/rbi@0.0.9.rbi +1602 -0
  44. data/sorbet/rbi/gems/simplecov-html@0.12.3.rbi +89 -0
  45. data/sorbet/rbi/gems/simplecov@0.21.2.rbi +577 -0
  46. data/sorbet/rbi/gems/simplecov_json_formatter@0.1.3.rbi +8 -0
  47. data/sorbet/rbi/gems/spoom@1.1.8.rbi +1252 -0
  48. data/sorbet/rbi/gems/tapioca@0.6.2.rbi +1232 -0
  49. data/sorbet/rbi/gems/thor@1.2.1.rbi +844 -0
  50. data/sorbet/rbi/gems/unparser@0.6.3.rbi +8 -0
  51. data/sorbet/rbi/gems/webrick@1.7.0.rbi +601 -0
  52. data/sorbet/rbi/gems/yard-sorbet@0.6.1.rbi +199 -0
  53. data/sorbet/rbi/gems/yard@0.9.27.rbi +4112 -0
  54. data/sorbet/tapioca/config.yml +13 -0
  55. data/sorbet/tapioca/require.rb +4 -0
  56. data/u-struct.gemspec +3 -3
  57. metadata +38 -4
  58. data/bin/test +0 -8
@@ -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,3 @@
1
+ # typed: strong
2
+
3
+ Micro::Struct::VERSION = T.let(T.unsafe(nil), String)
@@ -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,8 @@
1
+ --dir
2
+ .
3
+
4
+ --ignore
5
+ examples
6
+
7
+ --ignore
8
+ vendor
@@ -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)
@@ -0,0 +1,8 @@
1
+ # typed: true
2
+
3
+ # DO NOT EDIT MANUALLY
4
+ # This is an autogenerated file for types exported from the `method_source` gem.
5
+ # Please instead update this file by running `bin/tapioca gem method_source`.
6
+
7
+ # THIS IS AN EMPTY RBI FILE.
8
+ # see https://github.com/Shopify/tapioca/wiki/Manual-Gem-Requires