tapioca 0.17.10 → 0.19.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 (112) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -2
  3. data/lib/tapioca/bundler_ext/auto_require_hook.rb +0 -3
  4. data/lib/tapioca/cli.rb +1 -3
  5. data/lib/tapioca/commands/annotations.rb +0 -2
  6. data/lib/tapioca/commands/check_shims.rb +0 -1
  7. data/lib/tapioca/commands/command.rb +0 -1
  8. data/lib/tapioca/dsl/compiler.rb +7 -6
  9. data/lib/tapioca/dsl/compilers/aasm.rb +4 -5
  10. data/lib/tapioca/dsl/compilers/action_controller_helpers.rb +0 -4
  11. data/lib/tapioca/dsl/compilers/action_mailer.rb +0 -4
  12. data/lib/tapioca/dsl/compilers/action_text.rb +0 -4
  13. data/lib/tapioca/dsl/compilers/active_job.rb +0 -4
  14. data/lib/tapioca/dsl/compilers/active_model_attributes.rb +0 -4
  15. data/lib/tapioca/dsl/compilers/active_model_secure_password.rb +0 -4
  16. data/lib/tapioca/dsl/compilers/active_model_validations_confirmation.rb +0 -2
  17. data/lib/tapioca/dsl/compilers/active_record_associations.rb +0 -5
  18. data/lib/tapioca/dsl/compilers/active_record_columns.rb +0 -3
  19. data/lib/tapioca/dsl/compilers/active_record_delegated_types.rb +0 -3
  20. data/lib/tapioca/dsl/compilers/active_record_enum.rb +0 -4
  21. data/lib/tapioca/dsl/compilers/active_record_fixtures.rb +0 -4
  22. data/lib/tapioca/dsl/compilers/active_record_relations.rb +33 -6
  23. data/lib/tapioca/dsl/compilers/active_record_scope.rb +0 -1
  24. data/lib/tapioca/dsl/compilers/active_record_secure_token.rb +0 -3
  25. data/lib/tapioca/dsl/compilers/active_record_store.rb +0 -3
  26. data/lib/tapioca/dsl/compilers/active_record_typed_store.rb +0 -4
  27. data/lib/tapioca/dsl/compilers/active_resource.rb +0 -4
  28. data/lib/tapioca/dsl/compilers/active_storage.rb +0 -4
  29. data/lib/tapioca/dsl/compilers/active_support_concern.rb +0 -4
  30. data/lib/tapioca/dsl/compilers/active_support_current_attributes.rb +3 -18
  31. data/lib/tapioca/dsl/compilers/active_support_environment_inquirer.rb +60 -0
  32. data/lib/tapioca/dsl/compilers/active_support_time_ext.rb +0 -4
  33. data/lib/tapioca/dsl/compilers/config.rb +0 -4
  34. data/lib/tapioca/dsl/compilers/frozen_record.rb +0 -4
  35. data/lib/tapioca/dsl/compilers/graphql_input_object.rb +0 -4
  36. data/lib/tapioca/dsl/compilers/graphql_mutation.rb +0 -4
  37. data/lib/tapioca/dsl/compilers/identity_cache.rb +0 -4
  38. data/lib/tapioca/dsl/compilers/json_api_client_resource.rb +3 -17
  39. data/lib/tapioca/dsl/compilers/kredis.rb +0 -4
  40. data/lib/tapioca/dsl/compilers/mixed_in_class_attributes.rb +0 -4
  41. data/lib/tapioca/dsl/compilers/protobuf.rb +0 -4
  42. data/lib/tapioca/dsl/compilers/rails_generators.rb +0 -4
  43. data/lib/tapioca/dsl/compilers/sidekiq_worker.rb +0 -4
  44. data/lib/tapioca/dsl/compilers/smart_properties.rb +0 -4
  45. data/lib/tapioca/dsl/compilers/state_machines.rb +0 -4
  46. data/lib/tapioca/dsl/compilers/url_helpers.rb +0 -3
  47. data/lib/tapioca/dsl/helpers/active_model_type_helper.rb +0 -2
  48. data/lib/tapioca/dsl/helpers/active_record_column_type_helper.rb +0 -5
  49. data/lib/tapioca/dsl/helpers/active_record_constants_helper.rb +0 -2
  50. data/lib/tapioca/dsl/helpers/graphql_type_helper.rb +0 -2
  51. data/lib/tapioca/dsl/pipeline.rb +0 -2
  52. data/lib/tapioca/executor.rb +0 -2
  53. data/lib/tapioca/gem/events.rb +0 -15
  54. data/lib/tapioca/gem/listeners/base.rb +0 -1
  55. data/lib/tapioca/gem/listeners/documentation.rb +94 -0
  56. data/lib/tapioca/gem/listeners/dynamic_mixins.rb +0 -2
  57. data/lib/tapioca/gem/listeners/foreign_constants.rb +0 -2
  58. data/lib/tapioca/gem/listeners/methods.rb +0 -2
  59. data/lib/tapioca/gem/listeners/mixins.rb +0 -2
  60. data/lib/tapioca/gem/listeners/remove_empty_payload_scopes.rb +0 -2
  61. data/lib/tapioca/gem/listeners/sorbet_enums.rb +0 -2
  62. data/lib/tapioca/gem/listeners/sorbet_helpers.rb +0 -2
  63. data/lib/tapioca/gem/listeners/sorbet_props.rb +0 -1
  64. data/lib/tapioca/gem/listeners/sorbet_required_ancestors.rb +0 -2
  65. data/lib/tapioca/gem/listeners/sorbet_signatures.rb +1 -7
  66. data/lib/tapioca/gem/listeners/sorbet_type_variables.rb +0 -2
  67. data/lib/tapioca/gem/listeners/source_location.rb +6 -7
  68. data/lib/tapioca/gem/listeners/subconstants.rb +0 -2
  69. data/lib/tapioca/gem/listeners.rb +1 -1
  70. data/lib/tapioca/gem/pipeline.rb +2 -4
  71. data/lib/tapioca/gemfile.rb +0 -18
  72. data/lib/tapioca/helpers/cli_helper.rb +0 -1
  73. data/lib/tapioca/helpers/config_helper.rb +0 -1
  74. data/lib/tapioca/helpers/env_helper.rb +0 -1
  75. data/lib/tapioca/helpers/gem_helper.rb +0 -2
  76. data/lib/tapioca/helpers/git_attributes.rb +0 -2
  77. data/lib/tapioca/helpers/package_url.rb +416 -0
  78. data/lib/tapioca/helpers/rbi_files_helper.rb +0 -1
  79. data/lib/tapioca/helpers/rbi_helper.rb +7 -3
  80. data/lib/tapioca/helpers/sorbet_helper.rb +0 -2
  81. data/lib/tapioca/helpers/test/content.rb +0 -1
  82. data/lib/tapioca/helpers/test/dsl_compiler.rb +0 -3
  83. data/lib/tapioca/helpers/test/isolation.rb +0 -6
  84. data/lib/tapioca/helpers/test/template.rb +1 -9
  85. data/lib/tapioca/internal.rb +2 -2
  86. data/lib/tapioca/loaders/dsl.rb +0 -4
  87. data/lib/tapioca/loaders/gem.rb +0 -4
  88. data/lib/tapioca/loaders/loader.rb +0 -1
  89. data/lib/tapioca/rbi_ext/model.rb +4 -5
  90. data/lib/tapioca/rbi_formatter.rb +0 -2
  91. data/lib/tapioca/repo_index.rb +0 -3
  92. data/lib/tapioca/runtime/dynamic_mixin_compiler.rb +0 -3
  93. data/lib/tapioca/runtime/generic_type_registry.rb +0 -4
  94. data/lib/tapioca/runtime/reflection.rb +14 -13
  95. data/lib/tapioca/runtime/trackers/autoload.rb +0 -3
  96. data/lib/tapioca/runtime/trackers/constant_definition.rb +27 -5
  97. data/lib/tapioca/runtime/trackers/method_definition.rb +0 -1
  98. data/lib/tapioca/runtime/trackers/mixin.rb +0 -3
  99. data/lib/tapioca/runtime/trackers/required_ancestor.rb +0 -2
  100. data/lib/tapioca/runtime/trackers/tracker.rb +0 -3
  101. data/lib/tapioca/runtime/trackers.rb +0 -4
  102. data/lib/tapioca/sorbet_ext/generic_name_patch.rb +0 -2
  103. data/lib/tapioca/static/requires_compiler.rb +0 -2
  104. data/lib/tapioca/static/symbol_loader.rb +13 -6
  105. data/lib/tapioca/static/symbol_table_parser.rb +0 -4
  106. data/lib/tapioca/version.rb +1 -1
  107. data/lib/tapioca.rb +0 -2
  108. metadata +28 -15
  109. data/lib/tapioca/gem/listeners/yard_doc.rb +0 -112
  110. data/lib/tapioca/helpers/source_uri.rb +0 -84
  111. data/lib/tapioca/runtime/attached_class_of_32.rb +0 -20
  112. data/lib/tapioca/runtime/attached_class_of_legacy.rb +0 -24
@@ -1,112 +0,0 @@
1
- # typed: strict
2
- # frozen_string_literal: true
3
-
4
- module Tapioca
5
- module Gem
6
- module Listeners
7
- class YardDoc < Base
8
- extend T::Sig
9
-
10
- IGNORED_COMMENTS = [
11
- ":doc:",
12
- ":nodoc:",
13
- "typed:",
14
- "frozen_string_literal:",
15
- "encoding:",
16
- "warn_indent:",
17
- "shareable_constant_value:",
18
- "rubocop:",
19
- "@requires_ancestor:",
20
- ] #: Array[String]
21
-
22
- IGNORED_SIG_TAGS = ["param", "return"] #: Array[String]
23
-
24
- #: (Pipeline pipeline) -> void
25
- def initialize(pipeline)
26
- YARD::Registry.clear
27
- super(pipeline)
28
- pipeline.gem.parse_yard_docs
29
- end
30
-
31
- private
32
-
33
- #: (String line) -> bool
34
- def rbs_comment?(line)
35
- line.start_with?(": ", "| ")
36
- end
37
-
38
- # @override
39
- #: (ConstNodeAdded event) -> void
40
- def on_const(event)
41
- event.node.comments = documentation_comments(event.symbol)
42
- end
43
-
44
- # @override
45
- #: (ScopeNodeAdded event) -> void
46
- def on_scope(event)
47
- event.node.comments = documentation_comments(event.symbol)
48
- end
49
-
50
- # @override
51
- #: (MethodNodeAdded event) -> void
52
- def on_method(event)
53
- separator = event.constant.singleton_class? ? "." : "#"
54
- event.node.comments = documentation_comments(
55
- "#{event.symbol}#{separator}#{event.node.name}",
56
- sigs: event.node.sigs,
57
- )
58
- end
59
-
60
- #: (String name, ?sigs: Array[RBI::Sig]) -> Array[RBI::Comment]
61
- def documentation_comments(name, sigs: [])
62
- yard_docs = YARD::Registry.at(name)
63
- return [] unless yard_docs
64
-
65
- docstring = yard_docs.docstring
66
- return [] if /(copyright|license)/i.match?(docstring)
67
-
68
- comments = docstring.lines
69
- .reject { |line| IGNORED_COMMENTS.any? { |comment| line.include?(comment) } || rbs_comment?(line) }
70
- .map! { |line| RBI::Comment.new(line) }
71
-
72
- tags = yard_docs.tags
73
- tags.reject! { |tag| IGNORED_SIG_TAGS.include?(tag.tag_name) } unless sigs.empty?
74
-
75
- comments << RBI::Comment.new("") if comments.any? && tags.any?
76
-
77
- tags.sort_by { |tag| [tag.tag_name, tag.name.to_s] }.each do |tag|
78
- line = +"@#{tag.tag_name}"
79
-
80
- tag_name = tag.name
81
- line << " #{tag_name}" if tag_name
82
-
83
- tag_types = tag.types
84
- line << " [#{tag_types.join(", ")}]" if tag_types&.any?
85
-
86
- tag_text = tag.text
87
- if tag_text && !tag_text.empty?
88
- text_lines = tag_text.lines
89
-
90
- # Example are a special case because we want the text to start on the next line
91
- line << " #{text_lines.shift&.strip}" unless tag.tag_name == "example"
92
-
93
- text_lines.each do |text_line|
94
- line << "\n #{text_line.strip}"
95
- end
96
- end
97
-
98
- comments << RBI::Comment.new(line)
99
- end
100
-
101
- comments
102
- end
103
-
104
- # @override
105
- #: (NodeAdded event) -> bool
106
- def ignore?(event)
107
- event.is_a?(Tapioca::Gem::ForeignScopeNodeAdded)
108
- end
109
- end
110
- end
111
- end
112
- end
@@ -1,84 +0,0 @@
1
- # typed: true
2
- # frozen_string_literal: true
3
-
4
- require "uri/file"
5
-
6
- module Tapioca
7
- class SourceURI < URI::File
8
- extend T::Sig
9
-
10
- COMPONENT = [
11
- :scheme,
12
- :gem_name,
13
- :gem_version,
14
- :path,
15
- :line_number,
16
- ].freeze #: Array[Symbol]
17
-
18
- # `uri` for Ruby 3.4 switched the default parser from RFC2396 to RFC3986. The new parser emits a deprecation
19
- # warning on a few methods and delegates them to RFC2396, namely `extract`/`make_regexp`/`escape`/`unescape`.
20
- # On earlier versions of the uri gem, the RFC2396_PARSER constant doesn't exist, so it needs some special
21
- # handling to select a parser that doesn't emit deprecations. While it was backported to Ruby 3.1, users may
22
- # have the uri gem in their own bundle and thus not use a compatible version.
23
- PARSER = const_defined?(:RFC2396_PARSER) ? RFC2396_PARSER : DEFAULT_PARSER #: RFC2396_Parser
24
-
25
- #: String?
26
- attr_reader :gem_version
27
-
28
- class << self
29
- extend T::Sig
30
-
31
- #: (gem_name: String, gem_version: String?, path: String, line_number: String?) -> instance
32
- def build(gem_name:, gem_version:, path:, line_number:)
33
- super(
34
- {
35
- scheme: "source",
36
- host: gem_name,
37
- path: PARSER.escape("/#{gem_version}/#{path}"),
38
- fragment: line_number,
39
- }
40
- )
41
- end
42
- end
43
-
44
- #: -> String?
45
- def gem_name
46
- host
47
- end
48
-
49
- #: -> String?
50
- def line_number
51
- fragment
52
- end
53
-
54
- #: (String? v) -> void
55
- def set_path(v) # rubocop:disable Naming/AccessorMethodName
56
- return if v.nil?
57
-
58
- @gem_version, @path = v.split("/", 2)
59
- end
60
-
61
- #: (String? v) -> bool
62
- def check_host(v)
63
- return true unless v
64
-
65
- if /[A-Za-z][A-Za-z0-9\-_]*/ !~ v
66
- raise InvalidComponentError,
67
- "bad component(expected gem name): #{v}"
68
- end
69
-
70
- true
71
- end
72
-
73
- #: -> String
74
- def to_s
75
- "source://#{gem_name}/#{gem_version}#{path}##{line_number}"
76
- end
77
-
78
- if URI.respond_to?(:register_scheme)
79
- URI.register_scheme("SOURCE", self)
80
- else
81
- @@schemes["SOURCE"] = self
82
- end
83
- end
84
- end
@@ -1,20 +0,0 @@
1
- # typed: true
2
- # frozen_string_literal: true
3
-
4
- module Tapioca
5
- module Runtime
6
- # This module should only be included when running Ruby version 3.2
7
- # or newer. It relies on the Class#attached_object method, which was
8
- # added in Ruby 3.2 and fetches the attached object of a singleton
9
- # class without having to iterate through all of ObjectSpace.
10
- module AttachedClassOf
11
- extend T::Sig
12
-
13
- #: (Class singleton_class) -> T::Module[top]?
14
- def attached_class_of(singleton_class)
15
- result = singleton_class.attached_object
16
- Module === result ? result : nil
17
- end
18
- end
19
- end
20
- end
@@ -1,24 +0,0 @@
1
- # typed: true
2
- # frozen_string_literal: true
3
-
4
- module Tapioca
5
- module Runtime
6
- # This module should only be included when running versions of Ruby
7
- # older than 3.2. Because the Class#attached_object method is not
8
- # available, it implements finding the attached class of a singleton
9
- # class by iterating through ObjectSpace.
10
- # @requires_ancestor: Tapioca::Runtime::Reflection
11
- module AttachedClassOf
12
- extend T::Sig
13
- #: (Class singleton_class) -> T::Module[top]?
14
- def attached_class_of(singleton_class)
15
- # https://stackoverflow.com/a/36622320/98634
16
- result = ObjectSpace.each_object(singleton_class).find do |klass|
17
- singleton_class_of(T.cast(klass, Module)) == singleton_class
18
- end
19
-
20
- T.cast(result, T.nilable(Module))
21
- end
22
- end
23
- end
24
- end