tapioca 0.4.27 → 0.5.3
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/Gemfile +15 -15
- data/README.md +2 -2
- data/Rakefile +5 -7
- data/exe/tapioca +2 -2
- data/lib/tapioca/cli.rb +172 -2
- data/lib/tapioca/compilers/dsl/aasm.rb +122 -0
- data/lib/tapioca/compilers/dsl/action_controller_helpers.rb +52 -12
- data/lib/tapioca/compilers/dsl/action_mailer.rb +6 -9
- data/lib/tapioca/compilers/dsl/active_job.rb +8 -12
- data/lib/tapioca/compilers/dsl/active_model_attributes.rb +131 -0
- data/lib/tapioca/compilers/dsl/active_model_secure_password.rb +101 -0
- data/lib/tapioca/compilers/dsl/active_record_associations.rb +33 -54
- data/lib/tapioca/compilers/dsl/active_record_columns.rb +10 -105
- data/lib/tapioca/compilers/dsl/active_record_enum.rb +8 -10
- data/lib/tapioca/compilers/dsl/active_record_fixtures.rb +86 -0
- data/lib/tapioca/compilers/dsl/active_record_scope.rb +7 -10
- data/lib/tapioca/compilers/dsl/active_record_typed_store.rb +5 -8
- data/lib/tapioca/compilers/dsl/active_resource.rb +9 -37
- data/lib/tapioca/compilers/dsl/active_storage.rb +98 -0
- data/lib/tapioca/compilers/dsl/active_support_concern.rb +106 -0
- data/lib/tapioca/compilers/dsl/active_support_current_attributes.rb +13 -8
- data/lib/tapioca/compilers/dsl/base.rb +108 -82
- data/lib/tapioca/compilers/dsl/config.rb +111 -0
- data/lib/tapioca/compilers/dsl/frozen_record.rb +5 -7
- data/lib/tapioca/compilers/dsl/identity_cache.rb +66 -29
- data/lib/tapioca/compilers/dsl/mixed_in_class_attributes.rb +74 -0
- data/lib/tapioca/compilers/dsl/protobuf.rb +19 -69
- data/lib/tapioca/compilers/dsl/sidekiq_worker.rb +25 -12
- data/lib/tapioca/compilers/dsl/smart_properties.rb +21 -33
- data/lib/tapioca/compilers/dsl/state_machines.rb +56 -78
- data/lib/tapioca/compilers/dsl/url_helpers.rb +7 -10
- data/lib/tapioca/compilers/dsl_compiler.rb +25 -40
- data/lib/tapioca/compilers/dynamic_mixin_compiler.rb +198 -0
- data/lib/tapioca/compilers/requires_compiler.rb +2 -2
- data/lib/tapioca/compilers/sorbet.rb +25 -5
- data/lib/tapioca/compilers/symbol_table/symbol_generator.rb +122 -206
- data/lib/tapioca/compilers/symbol_table/symbol_loader.rb +4 -4
- data/lib/tapioca/compilers/symbol_table_compiler.rb +5 -11
- data/lib/tapioca/compilers/todos_compiler.rb +1 -1
- data/lib/tapioca/config.rb +3 -0
- data/lib/tapioca/config_builder.rb +5 -2
- data/lib/tapioca/constant_locator.rb +6 -8
- data/lib/tapioca/gemfile.rb +14 -11
- data/lib/tapioca/generators/base.rb +61 -0
- data/lib/tapioca/generators/dsl.rb +362 -0
- data/lib/tapioca/generators/gem.rb +345 -0
- data/lib/tapioca/generators/init.rb +79 -0
- data/lib/tapioca/generators/require.rb +52 -0
- data/lib/tapioca/generators/todo.rb +76 -0
- data/lib/tapioca/generators.rb +9 -0
- data/lib/tapioca/generic_type_registry.rb +25 -98
- data/lib/tapioca/helpers/active_record_column_type_helper.rb +98 -0
- data/lib/tapioca/internal.rb +2 -10
- data/lib/tapioca/loader.rb +11 -31
- data/lib/tapioca/rbi_ext/model.rb +166 -0
- data/lib/tapioca/reflection.rb +138 -0
- data/lib/tapioca/sorbet_ext/fixed_hash_patch.rb +1 -1
- data/lib/tapioca/sorbet_ext/generic_name_patch.rb +72 -4
- data/lib/tapioca/sorbet_ext/name_patch.rb +1 -1
- data/lib/tapioca/version.rb +1 -1
- data/lib/tapioca.rb +3 -0
- metadata +45 -23
- data/lib/tapioca/cli/main.rb +0 -146
- data/lib/tapioca/core_ext/class.rb +0 -28
- data/lib/tapioca/core_ext/string.rb +0 -18
- data/lib/tapioca/generator.rb +0 -633
- data/lib/tapioca/rbi/model.rb +0 -405
- data/lib/tapioca/rbi/printer.rb +0 -410
- data/lib/tapioca/rbi/rewriters/group_nodes.rb +0 -106
- data/lib/tapioca/rbi/rewriters/nest_non_public_methods.rb +0 -65
- data/lib/tapioca/rbi/rewriters/nest_singleton_methods.rb +0 -42
- data/lib/tapioca/rbi/rewriters/sort_nodes.rb +0 -86
- data/lib/tapioca/rbi/visitor.rb +0 -21
@@ -23,16 +23,16 @@ module T
|
|
23
23
|
def type_member(variance = :invariant, fixed: nil, lower: T.untyped, upper: BasicObject)
|
24
24
|
# `T::Generic#type_member` just instantiates a `T::Type::TypeMember` instance and returns it.
|
25
25
|
# We use that when registering the type member and then later return it from this method.
|
26
|
-
type_member =
|
27
|
-
Tapioca::GenericTypeRegistry.
|
26
|
+
type_member = Tapioca::TypeMember.new(variance, fixed, lower, upper)
|
27
|
+
Tapioca::GenericTypeRegistry.register_type_variable(self, type_member)
|
28
28
|
type_member
|
29
29
|
end
|
30
30
|
|
31
31
|
def type_template(variance = :invariant, fixed: nil, lower: T.untyped, upper: BasicObject)
|
32
32
|
# `T::Generic#type_template` just instantiates a `T::Type::TypeTemplate` instance and returns it.
|
33
33
|
# We use that when registering the type template and then later return it from this method.
|
34
|
-
type_template =
|
35
|
-
Tapioca::GenericTypeRegistry.
|
34
|
+
type_template = Tapioca::TypeTemplate.new(variance, fixed, lower, upper)
|
35
|
+
Tapioca::GenericTypeRegistry.register_type_variable(self, type_template)
|
36
36
|
type_template
|
37
37
|
end
|
38
38
|
end
|
@@ -64,3 +64,71 @@ module T
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
67
|
+
|
68
|
+
module Tapioca
|
69
|
+
class TypeMember < T::Types::TypeMember
|
70
|
+
extend T::Sig
|
71
|
+
|
72
|
+
sig { returns(T.nilable(String)) }
|
73
|
+
attr_accessor :name
|
74
|
+
|
75
|
+
sig { returns(T.untyped) }
|
76
|
+
attr_reader :fixed, :lower, :upper
|
77
|
+
|
78
|
+
sig { params(variance: Symbol, fixed: T.untyped, lower: T.untyped, upper: T.untyped).void }
|
79
|
+
def initialize(variance, fixed, lower, upper)
|
80
|
+
super(variance)
|
81
|
+
@fixed = fixed
|
82
|
+
@lower = lower
|
83
|
+
@upper = upper
|
84
|
+
end
|
85
|
+
|
86
|
+
sig { returns(String) }
|
87
|
+
def serialize
|
88
|
+
parts = []
|
89
|
+
parts << ":#{@variance}" unless @variance == :invariant
|
90
|
+
parts << "fixed: #{@fixed}" if @fixed
|
91
|
+
parts << "lower: #{@lower}" unless @lower == T.untyped
|
92
|
+
parts << "upper: #{@upper}" unless @upper == BasicObject
|
93
|
+
|
94
|
+
parameters = parts.join(", ")
|
95
|
+
|
96
|
+
serialized = +"type_member"
|
97
|
+
serialized << "(#{parameters})" unless parameters.empty?
|
98
|
+
serialized
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
class TypeTemplate < T::Types::TypeTemplate
|
103
|
+
extend T::Sig
|
104
|
+
|
105
|
+
sig { returns(T.nilable(String)) }
|
106
|
+
attr_accessor :name
|
107
|
+
|
108
|
+
sig { returns(T.untyped) }
|
109
|
+
attr_reader :fixed, :lower, :upper
|
110
|
+
|
111
|
+
sig { params(variance: Symbol, fixed: T.untyped, lower: T.untyped, upper: T.untyped).void }
|
112
|
+
def initialize(variance, fixed, lower, upper)
|
113
|
+
super(variance)
|
114
|
+
@fixed = fixed
|
115
|
+
@lower = lower
|
116
|
+
@upper = upper
|
117
|
+
end
|
118
|
+
|
119
|
+
sig { returns(String) }
|
120
|
+
def serialize
|
121
|
+
parts = []
|
122
|
+
parts << ":#{@variance}" unless @variance == :invariant
|
123
|
+
parts << "fixed: #{@fixed}" if @fixed
|
124
|
+
parts << "lower: #{@lower}" unless @lower == T.untyped
|
125
|
+
parts << "upper: #{@upper}" unless @upper == BasicObject
|
126
|
+
|
127
|
+
parameters = parts.join(", ")
|
128
|
+
|
129
|
+
serialized = +"type_template"
|
130
|
+
serialized << "(#{parameters})" unless parameters.empty?
|
131
|
+
serialized
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
data/lib/tapioca/version.rb
CHANGED
data/lib/tapioca.rb
CHANGED
@@ -17,6 +17,9 @@ module Tapioca
|
|
17
17
|
class Error < StandardError; end
|
18
18
|
end
|
19
19
|
|
20
|
+
require "tapioca/reflection"
|
20
21
|
require "tapioca/constant_locator"
|
21
22
|
require "tapioca/compilers/dsl/base"
|
23
|
+
require "tapioca/compilers/dynamic_mixin_compiler"
|
24
|
+
require "tapioca/helpers/active_record_column_type_helper"
|
22
25
|
require "tapioca/version"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tapioca
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ufuk Kayserilioglu
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date: 2021-
|
14
|
+
date: 2021-10-21 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -42,47 +42,47 @@ dependencies:
|
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: 0.12.2
|
44
44
|
- !ruby/object:Gem::Dependency
|
45
|
-
name:
|
45
|
+
name: rbi
|
46
46
|
requirement: !ruby/object:Gem::Requirement
|
47
47
|
requirements:
|
48
48
|
- - ">="
|
49
49
|
- !ruby/object:Gem::Version
|
50
|
-
version: 0
|
50
|
+
version: '0'
|
51
51
|
type: :runtime
|
52
52
|
prerelease: false
|
53
53
|
version_requirements: !ruby/object:Gem::Requirement
|
54
54
|
requirements:
|
55
55
|
- - ">="
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: 0
|
57
|
+
version: '0'
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
|
-
name: sorbet-
|
59
|
+
name: sorbet-static
|
60
60
|
requirement: !ruby/object:Gem::Requirement
|
61
61
|
requirements:
|
62
62
|
- - ">="
|
63
63
|
- !ruby/object:Gem::Version
|
64
|
-
version:
|
64
|
+
version: 0.5.6200
|
65
65
|
type: :runtime
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
69
|
- - ">="
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version:
|
71
|
+
version: 0.5.6200
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
|
-
name:
|
73
|
+
name: sorbet-runtime
|
74
74
|
requirement: !ruby/object:Gem::Requirement
|
75
75
|
requirements:
|
76
76
|
- - ">="
|
77
77
|
- !ruby/object:Gem::Version
|
78
|
-
version:
|
78
|
+
version: '0'
|
79
79
|
type: :runtime
|
80
80
|
prerelease: false
|
81
81
|
version_requirements: !ruby/object:Gem::Requirement
|
82
82
|
requirements:
|
83
83
|
- - ">="
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version:
|
85
|
+
version: '0'
|
86
86
|
- !ruby/object:Gem::Dependency
|
87
87
|
name: spoom
|
88
88
|
requirement: !ruby/object:Gem::Requirement
|
@@ -111,6 +111,20 @@ dependencies:
|
|
111
111
|
- - ">="
|
112
112
|
- !ruby/object:Gem::Version
|
113
113
|
version: 0.19.2
|
114
|
+
- !ruby/object:Gem::Dependency
|
115
|
+
name: yard-sorbet
|
116
|
+
requirement: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
type: :runtime
|
122
|
+
prerelease: false
|
123
|
+
version_requirements: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
114
128
|
description:
|
115
129
|
email:
|
116
130
|
- ruby@shopify.com
|
@@ -125,26 +139,34 @@ files:
|
|
125
139
|
- exe/tapioca
|
126
140
|
- lib/tapioca.rb
|
127
141
|
- lib/tapioca/cli.rb
|
128
|
-
- lib/tapioca/
|
142
|
+
- lib/tapioca/compilers/dsl/aasm.rb
|
129
143
|
- lib/tapioca/compilers/dsl/action_controller_helpers.rb
|
130
144
|
- lib/tapioca/compilers/dsl/action_mailer.rb
|
131
145
|
- lib/tapioca/compilers/dsl/active_job.rb
|
146
|
+
- lib/tapioca/compilers/dsl/active_model_attributes.rb
|
147
|
+
- lib/tapioca/compilers/dsl/active_model_secure_password.rb
|
132
148
|
- lib/tapioca/compilers/dsl/active_record_associations.rb
|
133
149
|
- lib/tapioca/compilers/dsl/active_record_columns.rb
|
134
150
|
- lib/tapioca/compilers/dsl/active_record_enum.rb
|
151
|
+
- lib/tapioca/compilers/dsl/active_record_fixtures.rb
|
135
152
|
- lib/tapioca/compilers/dsl/active_record_scope.rb
|
136
153
|
- lib/tapioca/compilers/dsl/active_record_typed_store.rb
|
137
154
|
- lib/tapioca/compilers/dsl/active_resource.rb
|
155
|
+
- lib/tapioca/compilers/dsl/active_storage.rb
|
156
|
+
- lib/tapioca/compilers/dsl/active_support_concern.rb
|
138
157
|
- lib/tapioca/compilers/dsl/active_support_current_attributes.rb
|
139
158
|
- lib/tapioca/compilers/dsl/base.rb
|
159
|
+
- lib/tapioca/compilers/dsl/config.rb
|
140
160
|
- lib/tapioca/compilers/dsl/frozen_record.rb
|
141
161
|
- lib/tapioca/compilers/dsl/identity_cache.rb
|
162
|
+
- lib/tapioca/compilers/dsl/mixed_in_class_attributes.rb
|
142
163
|
- lib/tapioca/compilers/dsl/protobuf.rb
|
143
164
|
- lib/tapioca/compilers/dsl/sidekiq_worker.rb
|
144
165
|
- lib/tapioca/compilers/dsl/smart_properties.rb
|
145
166
|
- lib/tapioca/compilers/dsl/state_machines.rb
|
146
167
|
- lib/tapioca/compilers/dsl/url_helpers.rb
|
147
168
|
- lib/tapioca/compilers/dsl_compiler.rb
|
169
|
+
- lib/tapioca/compilers/dynamic_mixin_compiler.rb
|
148
170
|
- lib/tapioca/compilers/requires_compiler.rb
|
149
171
|
- lib/tapioca/compilers/sorbet.rb
|
150
172
|
- lib/tapioca/compilers/symbol_table/symbol_generator.rb
|
@@ -154,20 +176,20 @@ files:
|
|
154
176
|
- lib/tapioca/config.rb
|
155
177
|
- lib/tapioca/config_builder.rb
|
156
178
|
- lib/tapioca/constant_locator.rb
|
157
|
-
- lib/tapioca/core_ext/class.rb
|
158
|
-
- lib/tapioca/core_ext/string.rb
|
159
179
|
- lib/tapioca/gemfile.rb
|
160
|
-
- lib/tapioca/
|
180
|
+
- lib/tapioca/generators.rb
|
181
|
+
- lib/tapioca/generators/base.rb
|
182
|
+
- lib/tapioca/generators/dsl.rb
|
183
|
+
- lib/tapioca/generators/gem.rb
|
184
|
+
- lib/tapioca/generators/init.rb
|
185
|
+
- lib/tapioca/generators/require.rb
|
186
|
+
- lib/tapioca/generators/todo.rb
|
161
187
|
- lib/tapioca/generic_type_registry.rb
|
188
|
+
- lib/tapioca/helpers/active_record_column_type_helper.rb
|
162
189
|
- lib/tapioca/internal.rb
|
163
190
|
- lib/tapioca/loader.rb
|
164
|
-
- lib/tapioca/
|
165
|
-
- lib/tapioca/
|
166
|
-
- lib/tapioca/rbi/rewriters/group_nodes.rb
|
167
|
-
- lib/tapioca/rbi/rewriters/nest_non_public_methods.rb
|
168
|
-
- lib/tapioca/rbi/rewriters/nest_singleton_methods.rb
|
169
|
-
- lib/tapioca/rbi/rewriters/sort_nodes.rb
|
170
|
-
- lib/tapioca/rbi/visitor.rb
|
191
|
+
- lib/tapioca/rbi_ext/model.rb
|
192
|
+
- lib/tapioca/reflection.rb
|
171
193
|
- lib/tapioca/sorbet_ext/fixed_hash_patch.rb
|
172
194
|
- lib/tapioca/sorbet_ext/generic_name_patch.rb
|
173
195
|
- lib/tapioca/sorbet_ext/name_patch.rb
|
@@ -185,7 +207,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
185
207
|
requirements:
|
186
208
|
- - ">="
|
187
209
|
- !ruby/object:Gem::Version
|
188
|
-
version: '2.
|
210
|
+
version: '2.6'
|
189
211
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
190
212
|
requirements:
|
191
213
|
- - ">="
|
data/lib/tapioca/cli/main.rb
DELETED
@@ -1,146 +0,0 @@
|
|
1
|
-
# typed: true
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
module Tapioca
|
5
|
-
module Cli
|
6
|
-
class Main < Thor
|
7
|
-
include(Thor::Actions)
|
8
|
-
|
9
|
-
class_option :prerequire,
|
10
|
-
aliases: ["--pre", "-b"],
|
11
|
-
banner: "file",
|
12
|
-
desc: "A file to be required before Bundler.require is called"
|
13
|
-
class_option :postrequire,
|
14
|
-
aliases: ["--post", "-a"],
|
15
|
-
banner: "file",
|
16
|
-
desc: "A file to be required after Bundler.require is called"
|
17
|
-
class_option :outdir,
|
18
|
-
aliases: ["--out", "-o"],
|
19
|
-
banner: "directory",
|
20
|
-
desc: "The output directory for generated RBI files"
|
21
|
-
class_option :generate_command,
|
22
|
-
aliases: ["--cmd", "-c"],
|
23
|
-
banner: "command",
|
24
|
-
desc: "The command to run to regenerate RBI files"
|
25
|
-
class_option :exclude,
|
26
|
-
aliases: ["-x"],
|
27
|
-
type: :array,
|
28
|
-
banner: "gem [gem ...]",
|
29
|
-
desc: "Excludes the given gem(s) from RBI generation"
|
30
|
-
class_option :typed_overrides,
|
31
|
-
aliases: ["--typed", "-t"],
|
32
|
-
type: :hash,
|
33
|
-
banner: "gem:level [gem:level ...]",
|
34
|
-
desc: "Overrides for typed sigils for generated gem RBIs"
|
35
|
-
|
36
|
-
map T.unsafe(%w[--version -v] => :__print_version)
|
37
|
-
|
38
|
-
desc "init", "initializes folder structure"
|
39
|
-
def init
|
40
|
-
create_config
|
41
|
-
create_post_require
|
42
|
-
generate_binstub
|
43
|
-
end
|
44
|
-
|
45
|
-
desc "require", "generate the list of files to be required by tapioca"
|
46
|
-
def require
|
47
|
-
Tapioca.silence_warnings do
|
48
|
-
generator.build_requires
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
desc "todo", "generate the list of unresolved constants"
|
53
|
-
def todo
|
54
|
-
Tapioca.silence_warnings do
|
55
|
-
generator.build_todos
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
desc "dsl [constant...]", "generate RBIs for dynamic methods"
|
60
|
-
option :generators,
|
61
|
-
type: :array,
|
62
|
-
aliases: ["--gen", "-g"],
|
63
|
-
banner: "generator [generator ...]",
|
64
|
-
desc: "Only run supplied DSL generators"
|
65
|
-
option :verify,
|
66
|
-
type: :boolean,
|
67
|
-
default: false,
|
68
|
-
desc: "Verifies RBIs are up-to-date"
|
69
|
-
option :quiet,
|
70
|
-
aliases: ["-q"],
|
71
|
-
type: :boolean,
|
72
|
-
desc: "Supresses file creation output"
|
73
|
-
def dsl(*constants)
|
74
|
-
Tapioca.silence_warnings do
|
75
|
-
generator.build_dsl(constants, should_verify: options[:verify], quiet: options[:quiet])
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
desc "generate [gem...]", "generate RBIs from gems"
|
80
|
-
def generate(*gems)
|
81
|
-
Tapioca.silence_warnings do
|
82
|
-
generator.build_gem_rbis(gems)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
desc "sync", "sync RBIs to Gemfile"
|
87
|
-
def sync
|
88
|
-
Tapioca.silence_warnings do
|
89
|
-
generator.sync_rbis_with_gemfile
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
desc "--version, -v", "show version"
|
94
|
-
def __print_version
|
95
|
-
puts "Tapioca v#{Tapioca::VERSION}"
|
96
|
-
end
|
97
|
-
|
98
|
-
private
|
99
|
-
|
100
|
-
def create_config
|
101
|
-
create_file(Config::SORBET_CONFIG, skip: true) do
|
102
|
-
<<~CONTENT
|
103
|
-
--dir
|
104
|
-
.
|
105
|
-
CONTENT
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def create_post_require
|
110
|
-
create_file(Config::DEFAULT_POSTREQUIRE, skip: true) do
|
111
|
-
<<~CONTENT
|
112
|
-
# typed: false
|
113
|
-
# frozen_string_literal: true
|
114
|
-
|
115
|
-
# Add your extra requires here
|
116
|
-
CONTENT
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def generate_binstub
|
121
|
-
bin_stub_exists = File.exist?("bin/tapioca")
|
122
|
-
installer = Bundler::Installer.new(Bundler.root, Bundler.definition)
|
123
|
-
spec = Bundler.definition.specs.find { |s| s.name == "tapioca" }
|
124
|
-
installer.generate_bundler_executable_stubs(spec, { force: true })
|
125
|
-
if bin_stub_exists
|
126
|
-
shell.say_status(:force, "bin/tapioca", :yellow)
|
127
|
-
else
|
128
|
-
shell.say_status(:create, "bin/tapioca", :green)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
no_commands do
|
133
|
-
def self.exit_on_failure?
|
134
|
-
true
|
135
|
-
end
|
136
|
-
|
137
|
-
def generator
|
138
|
-
current_command = T.must(current_command_chain.first)
|
139
|
-
@generator ||= Generator.new(
|
140
|
-
ConfigBuilder.from_options(current_command, options)
|
141
|
-
)
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
class Class
|
5
|
-
extend T::Sig
|
6
|
-
|
7
|
-
# Returns an array with all classes that are < than its receiver.
|
8
|
-
#
|
9
|
-
# class C; end
|
10
|
-
# C.descendants # => []
|
11
|
-
#
|
12
|
-
# class B < C; end
|
13
|
-
# C.descendants # => [B]
|
14
|
-
#
|
15
|
-
# class A < B; end
|
16
|
-
# C.descendants # => [B, A]
|
17
|
-
#
|
18
|
-
# class D < C; end
|
19
|
-
# C.descendants # => [B, A, D]
|
20
|
-
sig { returns(T::Array[Class]) }
|
21
|
-
def descendants
|
22
|
-
result = ObjectSpace.each_object(singleton_class).reject do |k|
|
23
|
-
T.cast(k, Module).singleton_class? || k == self
|
24
|
-
end
|
25
|
-
|
26
|
-
T.cast(result, T::Array[Class])
|
27
|
-
end
|
28
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# typed: strict
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
class String
|
5
|
-
extend T::Sig
|
6
|
-
|
7
|
-
sig { returns(String) }
|
8
|
-
def underscore
|
9
|
-
return self unless /[A-Z-]|::/.match?(self)
|
10
|
-
|
11
|
-
word = to_s.gsub("::", "/")
|
12
|
-
word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
|
13
|
-
word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
|
14
|
-
word.tr!("-", "_")
|
15
|
-
word.downcase!
|
16
|
-
word
|
17
|
-
end
|
18
|
-
end
|