tapioca 0.8.3 → 0.9.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.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +5 -2
  3. data/README.md +182 -36
  4. data/lib/tapioca/cli.rb +122 -65
  5. data/lib/tapioca/commands/annotations.rb +165 -33
  6. data/lib/tapioca/commands/check_shims.rb +91 -0
  7. data/lib/tapioca/commands/{init.rb → configure.rb} +1 -1
  8. data/lib/tapioca/commands/dsl.rb +1 -1
  9. data/lib/tapioca/commands/gem.rb +5 -5
  10. data/lib/tapioca/commands.rb +2 -1
  11. data/lib/tapioca/dsl/compiler.rb +1 -13
  12. data/lib/tapioca/dsl/compilers/active_model_attributes.rb +1 -1
  13. data/lib/tapioca/dsl/compilers/active_record_relations.rb +17 -0
  14. data/lib/tapioca/dsl/compilers/active_record_typed_store.rb +5 -4
  15. data/lib/tapioca/dsl/compilers/protobuf.rb +6 -0
  16. data/lib/tapioca/dsl/compilers.rb +0 -4
  17. data/lib/tapioca/dsl/helpers/active_record_column_type_helper.rb +2 -2
  18. data/lib/tapioca/dsl/pipeline.rb +0 -2
  19. data/lib/tapioca/dsl.rb +8 -0
  20. data/lib/tapioca/executor.rb +0 -3
  21. data/lib/tapioca/gem/events.rb +16 -2
  22. data/lib/tapioca/gem/listeners/base.rb +11 -0
  23. data/lib/tapioca/gem/listeners/dynamic_mixins.rb +5 -0
  24. data/lib/tapioca/gem/listeners/foreign_constants.rb +65 -0
  25. data/lib/tapioca/gem/listeners/methods.rb +6 -17
  26. data/lib/tapioca/gem/listeners/mixins.rb +31 -10
  27. data/lib/tapioca/gem/listeners/remove_empty_payload_scopes.rb +5 -0
  28. data/lib/tapioca/gem/listeners/sorbet_enums.rb +5 -0
  29. data/lib/tapioca/gem/listeners/sorbet_helpers.rb +5 -0
  30. data/lib/tapioca/gem/listeners/sorbet_props.rb +5 -0
  31. data/lib/tapioca/gem/listeners/sorbet_required_ancestors.rb +5 -0
  32. data/lib/tapioca/gem/listeners/sorbet_signatures.rb +6 -1
  33. data/lib/tapioca/gem/listeners/sorbet_type_variables.rb +5 -0
  34. data/lib/tapioca/gem/listeners/subconstants.rb +5 -0
  35. data/lib/tapioca/gem/listeners/yard_doc.rb +5 -0
  36. data/lib/tapioca/gem/listeners.rb +1 -0
  37. data/lib/tapioca/gem/pipeline.rb +58 -15
  38. data/lib/tapioca/gem.rb +6 -0
  39. data/lib/tapioca/gemfile.rb +7 -6
  40. data/lib/tapioca/helpers/cli_helper.rb +8 -2
  41. data/lib/tapioca/helpers/config_helper.rb +0 -2
  42. data/lib/tapioca/helpers/env_helper.rb +16 -0
  43. data/lib/tapioca/helpers/rbi_files_helper.rb +252 -0
  44. data/lib/tapioca/helpers/rbi_helper.rb +74 -94
  45. data/lib/tapioca/helpers/sorbet_helper.rb +2 -3
  46. data/lib/tapioca/helpers/test/content.rb +0 -2
  47. data/lib/tapioca/helpers/test/template.rb +0 -2
  48. data/lib/tapioca/internal.rb +34 -12
  49. data/lib/tapioca/rbi_ext/model.rb +2 -15
  50. data/lib/tapioca/runtime/dynamic_mixin_compiler.rb +18 -16
  51. data/lib/tapioca/runtime/reflection.rb +27 -0
  52. data/lib/tapioca/runtime/trackers/constant_definition.rb +17 -7
  53. data/lib/tapioca/runtime/trackers/mixin.rb +49 -14
  54. data/lib/tapioca/sorbet_ext/generic_name_patch.rb +1 -4
  55. data/lib/tapioca/static/requires_compiler.rb +0 -2
  56. data/lib/tapioca/static/symbol_loader.rb +26 -30
  57. data/lib/tapioca/static/symbol_table_parser.rb +0 -3
  58. data/lib/tapioca/version.rb +1 -1
  59. data/lib/tapioca.rb +3 -0
  60. metadata +22 -7
  61. data/lib/tapioca/dsl/helpers/param_helper.rb +0 -55
  62. data/lib/tapioca/helpers/shims_helper.rb +0 -115
  63. data/lib/tapioca/helpers/signatures_helper.rb +0 -17
  64. data/lib/tapioca/helpers/type_variable_helper.rb +0 -43
@@ -1,9 +1,6 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- require "pathname"
5
- require "shellwords"
6
-
7
4
  module Tapioca
8
5
  module SorbetHelper
9
6
  extend T::Sig
@@ -20,6 +17,8 @@ module Tapioca
20
17
 
21
18
  SORBET_EXE_PATH_ENV_VAR = "TAPIOCA_SORBET_EXE"
22
19
 
20
+ SORBET_PAYLOAD_URL = "https://github.com/sorbet/sorbet/tree/master/rbi"
21
+
23
22
  FEATURE_REQUIREMENTS = T.let({
24
23
  to_ary_nil_support: ::Gem::Requirement.new(">= 0.5.9220"), # https://github.com/sorbet/sorbet/pull/4706
25
24
  print_payload_sources: ::Gem::Requirement.new(">= 0.5.9818"), # https://github.com/sorbet/sorbet/pull/5504
@@ -1,8 +1,6 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- require "fileutils"
5
-
6
4
  module Tapioca
7
5
  module Helpers
8
6
  module Test
@@ -1,8 +1,6 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- require "erb"
5
-
6
4
  module Tapioca
7
5
  module Helpers
8
6
  module Test
@@ -1,32 +1,54 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
+ require "set"
5
+
4
6
  require "tapioca"
5
7
  require "tapioca/runtime/reflection"
6
8
  require "tapioca/runtime/trackers"
9
+
10
+ require "bundler"
11
+ require "erb"
12
+ require "etc"
13
+ require "fileutils"
14
+ require "json"
15
+ require "logger"
16
+ require "net/http"
17
+ require "netrc"
18
+ require "parallel"
19
+ require "pathname"
20
+ require "shellwords"
21
+ require "spoom"
22
+ require "tempfile"
23
+ require "thor"
24
+ require "yaml"
25
+ require "yard-sorbet"
26
+
7
27
  require "tapioca/runtime/dynamic_mixin_compiler"
8
28
  require "tapioca/helpers/gem_helper"
9
29
  require "tapioca/runtime/loader"
30
+
10
31
  require "tapioca/helpers/sorbet_helper"
11
- require "tapioca/helpers/type_variable_helper"
12
- require "tapioca/sorbet_ext/generic_name_patch"
32
+ require "tapioca/helpers/rbi_helper"
13
33
  require "tapioca/sorbet_ext/fixed_hash_patch"
34
+ require "tapioca/sorbet_ext/name_patch"
35
+ require "tapioca/sorbet_ext/generic_name_patch"
14
36
  require "tapioca/runtime/generic_type_registry"
37
+
15
38
  require "tapioca/helpers/cli_helper"
16
39
  require "tapioca/helpers/config_helper"
17
- require "tapioca/helpers/signatures_helper"
18
- require "tapioca/helpers/rbi_helper"
19
- require "tapioca/helpers/shims_helper"
40
+ require "tapioca/helpers/rbi_files_helper"
41
+ require "tapioca/helpers/env_helper"
42
+
20
43
  require "tapioca/repo_index"
21
- require "tapioca/commands"
22
- require "tapioca/cli"
23
44
  require "tapioca/gemfile"
24
45
  require "tapioca/executor"
46
+
25
47
  require "tapioca/static/symbol_table_parser"
26
48
  require "tapioca/static/symbol_loader"
27
- require "tapioca/gem/events"
28
- require "tapioca/gem/listeners"
29
- require "tapioca/gem/pipeline"
30
- require "tapioca/dsl/compiler"
31
- require "tapioca/dsl/pipeline"
32
49
  require "tapioca/static/requires_compiler"
50
+
51
+ require "tapioca/gem"
52
+ require "tapioca/dsl"
53
+ require "tapioca/commands"
54
+ require "tapioca/cli"
@@ -72,7 +72,7 @@ module RBI
72
72
  ).void
73
73
  end
74
74
  def create_type_variable(name, type:, variance: :invariant, fixed: nil, upper: nil, lower: nil)
75
- value = Tapioca::TypeVariableHelper.serialize_type_variable(type, variance, fixed, upper, lower)
75
+ value = Tapioca::RBIHelper.serialize_type_variable(type, variance, fixed, upper, lower)
76
76
  create_node(RBI::TypeMember.new(name, value))
77
77
  end
78
78
 
@@ -86,7 +86,7 @@ module RBI
86
86
  ).void
87
87
  end
88
88
  def create_method(name, parameters: [], return_type: "T.untyped", class_method: false, visibility: RBI::Public.new)
89
- return unless valid_method_name?(name)
89
+ return unless Tapioca::RBIHelper.valid_method_name?(name)
90
90
 
91
91
  sig = RBI::Sig.new(return_type: return_type)
92
92
  method = RBI::Method.new(name, sigs: [sig], is_singleton: class_method, visibility: visibility)
@@ -99,19 +99,6 @@ module RBI
99
99
 
100
100
  private
101
101
 
102
- SPECIAL_METHOD_NAMES = T.let(
103
- ["!", "~", "+@", "**", "-@", "*", "/", "%", "+", "-", "<<", ">>", "&", "|", "^", "<", "<=", "=>", ">", ">=",
104
- "==", "===", "!=", "=~", "!~", "<=>", "[]", "[]=", "`",].freeze,
105
- T::Array[String]
106
- )
107
-
108
- sig { params(name: String).returns(T::Boolean) }
109
- def valid_method_name?(name)
110
- return true if SPECIAL_METHOD_NAMES.include?(name)
111
-
112
- !!name.match(/^[a-zA-Z_][[:word:]]*[?!=]?$/)
113
- end
114
-
115
102
  sig { returns(T::Hash[String, RBI::Node]) }
116
103
  def nodes_cache
117
104
  T.must(@nodes_cache ||= T.let({}, T.nilable(T::Hash[String, Node])))
@@ -35,22 +35,24 @@ module Tapioca
35
35
  # before the actual include
36
36
  before = singleton_class.ancestors
37
37
  # Call the actual `include` method with the supplied module
38
- super(mod).tap do
39
- # Take a snapshot of the list of singleton class ancestors
40
- # after the actual include
41
- after = singleton_class.ancestors
42
- # The difference is the modules that are added to the list
43
- # of ancestors of the singleton class. Those are all the
44
- # modules that were `extend`ed due to the `include` call.
45
- #
46
- # We record those modules on our lookup table keyed by
47
- # the included module with the values being all the modules
48
- # that that module pulls into the singleton class.
49
- #
50
- # We need to reverse the order, since the extend order should
51
- # be the inverse of the ancestor order. That is, earlier
52
- # extended modules would be later in the ancestor chain.
53
- mixins_from_modules[mod] = (after - before).reverse!
38
+ ::Tapioca::Runtime::Trackers::Mixin.with_disabled_registration do
39
+ super(mod).tap do
40
+ # Take a snapshot of the list of singleton class ancestors
41
+ # after the actual include
42
+ after = singleton_class.ancestors
43
+ # The difference is the modules that are added to the list
44
+ # of ancestors of the singleton class. Those are all the
45
+ # modules that were `extend`ed due to the `include` call.
46
+ #
47
+ # We record those modules on our lookup table keyed by
48
+ # the included module with the values being all the modules
49
+ # that that module pulls into the singleton class.
50
+ #
51
+ # We need to reverse the order, since the extend order should
52
+ # be the inverse of the ancestor order. That is, earlier
53
+ # extended modules would be later in the ancestor chain.
54
+ mixins_from_modules[mod] = (after - before).reverse!
55
+ end
54
56
  end
55
57
  rescue Exception # rubocop:disable Lint/RescueException
56
58
  # this is a best effort, bail if we can't perform this
@@ -20,6 +20,8 @@ module Tapioca
20
20
  PRIVATE_INSTANCE_METHODS_METHOD = T.let(Module.instance_method(:private_instance_methods), UnboundMethod)
21
21
  METHOD_METHOD = T.let(Kernel.instance_method(:method), UnboundMethod)
22
22
 
23
+ REQUIRED_FROM_LABELS = T.let(["<top (required)>", "<main>"].freeze, T::Array[String])
24
+
23
25
  sig do
24
26
  params(
25
27
  symbol: String,
@@ -152,6 +154,31 @@ module Tapioca
152
154
 
153
155
  T.unsafe(result)
154
156
  end
157
+
158
+ # Examines the call stack to identify the closest location where a "require" is performed
159
+ # by searching for the label "<top (required)>". If none is found, it returns the location
160
+ # labeled "<main>", which is the original call site.
161
+ sig { returns(String) }
162
+ def required_from_location
163
+ locations = Kernel.caller_locations
164
+ return "" unless locations
165
+
166
+ required_location = locations.find { |loc| REQUIRED_FROM_LABELS.include?(loc.label) }
167
+ return "" unless required_location
168
+
169
+ required_location.absolute_path || ""
170
+ end
171
+
172
+ sig { params(constant: Module).returns(T.nilable(String)) }
173
+ def constant_name_from_singleton_class(constant)
174
+ constant.to_s.match("#<Class:(.+)>")&.captures&.first
175
+ end
176
+
177
+ sig { params(constant: Module).returns(T.nilable(BasicObject)) }
178
+ def constant_from_singleton_class(constant)
179
+ constant_name = constant_name_from_singleton_class(constant)
180
+ constantize(constant_name) if constant_name
181
+ end
155
182
  end
156
183
  end
157
184
  end
@@ -1,8 +1,6 @@
1
1
  # typed: true
2
2
  # frozen_string_literal: true
3
3
 
4
- require "set"
5
-
6
4
  module Tapioca
7
5
  module Runtime
8
6
  module Trackers
@@ -12,6 +10,12 @@ module Tapioca
12
10
  # available in the ruby runtime without extra accounting.
13
11
  module ConstantDefinition
14
12
  extend Reflection
13
+ extend T::Sig
14
+
15
+ class ConstantLocation < T::Struct
16
+ const :lineno, Integer
17
+ const :path, String
18
+ end
15
19
 
16
20
  @class_files = {}
17
21
 
@@ -20,13 +24,19 @@ module Tapioca
20
24
  unless tp.self.singleton_class?
21
25
  key = name_of(tp.self)
22
26
  file = tp.path
27
+ lineno = tp.lineno
28
+
23
29
  if file == "(eval)"
24
- file = T.must(caller_locations)
30
+ caller_location = T.must(caller_locations)
25
31
  .drop_while { |loc| loc.path == "(eval)" }
26
- .first&.path
32
+ .first
33
+
34
+ file = caller_location&.path
35
+ lineno = caller_location&.lineno
27
36
  end
37
+
28
38
  @class_files[key] ||= Set.new
29
- @class_files[key] << file
39
+ @class_files[key] << ConstantLocation.new(path: T.must(file), lineno: T.must(lineno))
30
40
  end
31
41
  end
32
42
 
@@ -35,8 +45,8 @@ module Tapioca
35
45
  # or where metaprogramming was used via +eval+, etc.
36
46
  def self.files_for(klass)
37
47
  name = String === klass ? klass : name_of(klass)
38
- files = @class_files[name]
39
- files || Set.new
48
+ files = @class_files.fetch(name, [])
49
+ files.map(&:path).to_set
40
50
  end
41
51
  end
42
52
  end
@@ -7,7 +7,9 @@ module Tapioca
7
7
  module Mixin
8
8
  extend T::Sig
9
9
 
10
- @mixin_map = {}.compare_by_identity
10
+ @constants_to_mixin_locations = {}.compare_by_identity
11
+ @mixins_to_constants = {}.compare_by_identity
12
+ @enabled = true
11
13
 
12
14
  class Type < T::Enum
13
15
  enums do
@@ -17,24 +19,38 @@ module Tapioca
17
19
  end
18
20
  end
19
21
 
22
+ sig do
23
+ type_parameters(:Result)
24
+ .params(block: T.proc.returns(T.type_parameter(:Result)))
25
+ .returns(T.type_parameter(:Result))
26
+ end
27
+ def self.with_disabled_registration(&block)
28
+ @enabled = false
29
+
30
+ block.call
31
+ ensure
32
+ @enabled = true
33
+ end
34
+
20
35
  sig do
21
36
  params(
22
37
  constant: Module,
23
- mod: Module,
38
+ mixin: Module,
24
39
  mixin_type: Type,
25
- locations: T.nilable(T::Array[Thread::Backtrace::Location])
26
40
  ).void
27
41
  end
28
- def self.register(constant, mod, mixin_type, locations)
29
- locations ||= []
30
- locations.map!(&:absolute_path).uniq!
31
- locs = mixin_locations_for(constant)
32
- locs.fetch(mixin_type).store(mod, T.cast(locations, T::Array[String]))
42
+ def self.register(constant, mixin, mixin_type)
43
+ return unless @enabled
44
+
45
+ location = Reflection.required_from_location
46
+
47
+ constants = constants_with_mixin(mixin)
48
+ constants.fetch(mixin_type).store(constant, location)
33
49
  end
34
50
 
35
- sig { params(constant: Module).returns(T::Hash[Type, T::Hash[Module, T::Array[String]]]) }
36
- def self.mixin_locations_for(constant)
37
- @mixin_map[constant] ||= {
51
+ sig { params(mixin: Module).returns(T::Hash[Type, T::Hash[Module, String]]) }
52
+ def self.constants_with_mixin(mixin)
53
+ @mixins_to_constants[mixin] ||= {
38
54
  Type::Prepend => {}.compare_by_identity,
39
55
  Type::Include => {}.compare_by_identity,
40
56
  Type::Extend => {}.compare_by_identity,
@@ -52,8 +68,10 @@ class Module
52
68
  constant,
53
69
  self,
54
70
  Tapioca::Runtime::Trackers::Mixin::Type::Prepend,
55
- caller_locations
56
71
  )
72
+
73
+ register_extend_on_attached_class(constant) if constant.singleton_class?
74
+
57
75
  super
58
76
  end
59
77
 
@@ -62,8 +80,10 @@ class Module
62
80
  constant,
63
81
  self,
64
82
  Tapioca::Runtime::Trackers::Mixin::Type::Include,
65
- caller_locations
66
83
  )
84
+
85
+ register_extend_on_attached_class(constant) if constant.singleton_class?
86
+
67
87
  super
68
88
  end
69
89
 
@@ -72,9 +92,24 @@ class Module
72
92
  obj,
73
93
  self,
74
94
  Tapioca::Runtime::Trackers::Mixin::Type::Extend,
75
- caller_locations
76
95
  ) if Module === obj
77
96
  super
78
97
  end
98
+
99
+ private
100
+
101
+ # Including or prepending on a singleton class is functionally equivalent to extending the
102
+ # attached class. Registering the mixin as an extend on the attached class ensures that
103
+ # this mixin can be found whether searching for an include/prepend on the singleton class
104
+ # or an extend on the attached class.
105
+ def register_extend_on_attached_class(constant)
106
+ attached_class = Tapioca::Runtime::Reflection.constant_from_singleton_class(constant)
107
+
108
+ Tapioca::Runtime::Trackers::Mixin.register(
109
+ T.cast(attached_class, Module),
110
+ self,
111
+ Tapioca::Runtime::Trackers::Mixin::Type::Extend,
112
+ ) if attached_class
113
+ end
79
114
  end)
80
115
  end
@@ -1,9 +1,6 @@
1
1
  # typed: true
2
2
  # frozen_string_literal: true
3
3
 
4
- require "tapioca/sorbet_ext/name_patch"
5
- require "tapioca/helpers/sorbet_helper"
6
-
7
4
  module T
8
5
  module Generic
9
6
  # This module intercepts calls to generic type instantiations and type variable definitions.
@@ -174,7 +171,7 @@ module Tapioca
174
171
  lower = bounds[:lower].to_s if bounds.key?(:lower)
175
172
  upper = bounds[:upper].to_s if bounds.key?(:upper)
176
173
 
177
- TypeVariableHelper.serialize_type_variable(
174
+ RBIHelper.serialize_type_variable(
178
175
  @type.serialize,
179
176
  @variance,
180
177
  fixed,
@@ -1,8 +1,6 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- require "spoom"
5
-
6
4
  module Tapioca
7
5
  module Static
8
6
  class RequiresCompiler
@@ -1,9 +1,6 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- require "json"
5
- require "tempfile"
6
-
7
4
  module Tapioca
8
5
  module Static
9
6
  module SymbolLoader
@@ -22,12 +19,21 @@ module Tapioca
22
19
  T.must(@payload_symbols)
23
20
  end
24
21
 
25
- sig { returns(T::Set[String]) }
26
- def engine_symbols
27
- unless @engine_symbols
28
- @engine_symbols = T.let(load_engine_symbols, T.nilable(T::Set[String]))
22
+ sig { params(gem: Gemfile::GemSpec).returns(T::Set[String]) }
23
+ def engine_symbols(gem)
24
+ gem_engine = engines.find do |engine|
25
+ gem.contains_path?(engine.config.root.to_s)
26
+ end
27
+
28
+ return Set.new unless gem_engine
29
+
30
+ paths = gem_engine.config.eager_load_paths.flat_map do |load_path|
31
+ Pathname.glob("#{load_path}/**/*.rb")
29
32
  end
30
- T.must(@engine_symbols)
33
+
34
+ symbols_from_paths(paths)
35
+ rescue
36
+ Set.new
31
37
  end
32
38
 
33
39
  sig { params(gem: Gemfile::GemSpec).returns(T::Set[String]) }
@@ -37,31 +43,21 @@ module Tapioca
37
43
 
38
44
  private
39
45
 
40
- sig { params(input: String, table_type: String).returns(String) }
41
- def symbol_table_json_from(input, table_type: "symbol-table-json")
42
- sorbet("--no-config", "--quiet", "--print=#{table_type}", input).out
43
- end
44
-
45
- sig { returns(T::Set[String]) }
46
- def load_engine_symbols
47
- return Set.new unless Object.const_defined?("Rails::Engine")
48
-
49
- engine = descendants_of(Object.const_get("Rails::Engine"))
50
- .reject(&:abstract_railtie?)
51
- .find do |klass|
52
- name = name_of(klass)
53
- !name.nil? && payload_symbols.include?(name)
54
- end
46
+ sig { returns(T::Array[T.class_of(Rails::Engine)]) }
47
+ def engines
48
+ @engines = T.let(@engines, T.nilable(T::Array[T.class_of(Rails::Engine)]))
55
49
 
56
- return Set.new unless engine
57
-
58
- paths = engine.config.eager_load_paths.flat_map do |load_path|
59
- Pathname.glob("#{load_path}/**/*.rb")
50
+ @engines ||= if Object.const_defined?("Rails::Engine")
51
+ descendants_of(Object.const_get("Rails::Engine"))
52
+ .reject(&:abstract_railtie?)
53
+ else
54
+ []
60
55
  end
56
+ end
61
57
 
62
- symbols_from_paths(paths)
63
- rescue
64
- Set.new
58
+ sig { params(input: String, table_type: String).returns(String) }
59
+ def symbol_table_json_from(input, table_type: "symbol-table-json")
60
+ sorbet("--no-config", "--quiet", "--print=#{table_type}", input).out
65
61
  end
66
62
 
67
63
  sig { params(paths: T::Array[Pathname]).returns(T::Set[String]) }
@@ -1,9 +1,6 @@
1
1
  # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
- require "json"
5
- require "tempfile"
6
-
7
4
  module Tapioca
8
5
  module Static
9
6
  class SymbolTableParser
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Tapioca
5
- VERSION = "0.8.3"
5
+ VERSION = "0.9.0"
6
6
  end
data/lib/tapioca.rb CHANGED
@@ -43,6 +43,9 @@ module Tapioca
43
43
  "activesupport" => "false",
44
44
  }.freeze, T::Hash[String, String])
45
45
 
46
+ DEFAULT_RBI_MAX_LINE_LENGTH = 120
47
+ DEFAULT_ENVIRONMENT = "development"
48
+
46
49
  CENTRAL_REPO_ROOT_URI = "https://raw.githubusercontent.com/Shopify/rbi-central/main"
47
50
  CENTRAL_REPO_INDEX_PATH = "index.json"
48
51
  CENTRAL_REPO_ANNOTATIONS_DIR = "rbi/annotations"
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.8.3
4
+ version: 0.9.0
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: 2022-06-28 00:00:00.000000000 Z
14
+ date: 2022-07-07 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -27,6 +27,20 @@ dependencies:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: 1.17.3
30
+ - !ruby/object:Gem::Dependency
31
+ name: netrc
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 0.11.0
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: 0.11.0
30
44
  - !ruby/object:Gem::Dependency
31
45
  name: parallel
32
46
  requirement: !ruby/object:Gem::Requirement
@@ -153,10 +167,11 @@ files:
153
167
  - lib/tapioca/cli.rb
154
168
  - lib/tapioca/commands.rb
155
169
  - lib/tapioca/commands/annotations.rb
170
+ - lib/tapioca/commands/check_shims.rb
156
171
  - lib/tapioca/commands/command.rb
172
+ - lib/tapioca/commands/configure.rb
157
173
  - lib/tapioca/commands/dsl.rb
158
174
  - lib/tapioca/commands/gem.rb
159
- - lib/tapioca/commands/init.rb
160
175
  - lib/tapioca/commands/require.rb
161
176
  - lib/tapioca/commands/todo.rb
162
177
  - lib/tapioca/dsl.rb
@@ -192,13 +207,14 @@ files:
192
207
  - lib/tapioca/dsl/extensions/frozen_record.rb
193
208
  - lib/tapioca/dsl/helpers/active_record_column_type_helper.rb
194
209
  - lib/tapioca/dsl/helpers/active_record_constants_helper.rb
195
- - lib/tapioca/dsl/helpers/param_helper.rb
196
210
  - lib/tapioca/dsl/pipeline.rb
197
211
  - lib/tapioca/executor.rb
212
+ - lib/tapioca/gem.rb
198
213
  - lib/tapioca/gem/events.rb
199
214
  - lib/tapioca/gem/listeners.rb
200
215
  - lib/tapioca/gem/listeners/base.rb
201
216
  - lib/tapioca/gem/listeners/dynamic_mixins.rb
217
+ - lib/tapioca/gem/listeners/foreign_constants.rb
202
218
  - lib/tapioca/gem/listeners/methods.rb
203
219
  - lib/tapioca/gem/listeners/mixins.rb
204
220
  - lib/tapioca/gem/listeners/remove_empty_payload_scopes.rb
@@ -214,16 +230,15 @@ files:
214
230
  - lib/tapioca/gemfile.rb
215
231
  - lib/tapioca/helpers/cli_helper.rb
216
232
  - lib/tapioca/helpers/config_helper.rb
233
+ - lib/tapioca/helpers/env_helper.rb
217
234
  - lib/tapioca/helpers/gem_helper.rb
235
+ - lib/tapioca/helpers/rbi_files_helper.rb
218
236
  - lib/tapioca/helpers/rbi_helper.rb
219
- - lib/tapioca/helpers/shims_helper.rb
220
- - lib/tapioca/helpers/signatures_helper.rb
221
237
  - lib/tapioca/helpers/sorbet_helper.rb
222
238
  - lib/tapioca/helpers/test/content.rb
223
239
  - lib/tapioca/helpers/test/dsl_compiler.rb
224
240
  - lib/tapioca/helpers/test/isolation.rb
225
241
  - lib/tapioca/helpers/test/template.rb
226
- - lib/tapioca/helpers/type_variable_helper.rb
227
242
  - lib/tapioca/internal.rb
228
243
  - lib/tapioca/rbi_ext/model.rb
229
244
  - lib/tapioca/rbi_formatter.rb
@@ -1,55 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- require "tapioca/helpers/signatures_helper"
5
-
6
- module Tapioca
7
- module Dsl
8
- module Helpers
9
- module ParamHelper
10
- extend T::Sig
11
- include SignaturesHelper
12
-
13
- sig { params(name: String, type: String).returns(RBI::TypedParam) }
14
- def create_param(name, type:)
15
- create_typed_param(RBI::Param.new(name), type)
16
- end
17
-
18
- sig { params(name: String, type: String, default: String).returns(RBI::TypedParam) }
19
- def create_opt_param(name, type:, default:)
20
- create_typed_param(RBI::OptParam.new(name, default), type)
21
- end
22
-
23
- sig { params(name: String, type: String).returns(RBI::TypedParam) }
24
- def create_rest_param(name, type:)
25
- create_typed_param(RBI::RestParam.new(name), type)
26
- end
27
-
28
- sig { params(name: String, type: String).returns(RBI::TypedParam) }
29
- def create_kw_param(name, type:)
30
- create_typed_param(RBI::KwParam.new(name), type)
31
- end
32
-
33
- sig { params(name: String, type: String, default: String).returns(RBI::TypedParam) }
34
- def create_kw_opt_param(name, type:, default:)
35
- create_typed_param(RBI::KwOptParam.new(name, default), type)
36
- end
37
-
38
- sig { params(name: String, type: String).returns(RBI::TypedParam) }
39
- def create_kw_rest_param(name, type:)
40
- create_typed_param(RBI::KwRestParam.new(name), type)
41
- end
42
-
43
- sig { params(name: String, type: String).returns(RBI::TypedParam) }
44
- def create_block_param(name, type:)
45
- create_typed_param(RBI::BlockParam.new(name), type)
46
- end
47
-
48
- sig { params(param: RBI::Param, type: String).returns(RBI::TypedParam) }
49
- def create_typed_param(param, type)
50
- RBI::TypedParam.new(param: param, type: sanitize_signature_types(type))
51
- end
52
- end
53
- end
54
- end
55
- end