Module: Spoom::Sorbet::Translate
- Defined in:
- lib/spoom/sorbet/translate.rb,
lib/spoom/sorbet/translate/translator.rb,
lib/spoom/sorbet/translate/strip_sorbet_sigs.rb,
lib/spoom/sorbet/translate/rbs_comments_to_sorbet_sigs.rb,
lib/spoom/sorbet/translate/sorbet_sigs_to_rbs_comments.rb,
lib/spoom/sorbet/translate/sorbet_assertions_to_rbs_comments.rb
Defined Under Namespace
Classes: Error, RBSCommentsToSorbetSigs, SorbetAssertionsToRBSComments, SorbetSigsToRBSComments, StripSorbetSigs, Translator
Class Method Summary collapse
-
.rbs_comments_to_sorbet_sigs(ruby_contents, file:, max_line_length: nil) ⇒ Object
Converts all the RBS comments in the given Ruby code to ‘sig` nodes.
-
.sorbet_assertions_to_rbs_comments(ruby_contents, file:, translate_t_let: true, translate_t_cast: true, translate_t_bind: true, translate_t_must: true, translate_t_unsafe: true) ⇒ Object
Converts all ‘T.let` and `T.cast` nodes to RBS comments in the given Ruby code.
-
.sorbet_sigs_to_rbs_comments(ruby_contents, file:, positional_names: true, max_line_length: nil, translate_generics: true, translate_helpers: true, translate_abstract_methods: true) ⇒ Object
Converts all ‘sig` nodes to RBS comments in the given Ruby code.
-
.strip_sorbet_sigs(ruby_contents, file:) ⇒ Object
Deletes all ‘sig` nodes from the given Ruby code.
Class Method Details
.rbs_comments_to_sorbet_sigs(ruby_contents, file:, max_line_length: nil) ⇒ Object
Converts all the RBS comments in the given Ruby code to ‘sig` nodes. It also handles type members and class annotations. : (String ruby_contents, file: String, ?max_line_length: Integer?) -> String
57 58 59 |
# File 'lib/spoom/sorbet/translate.rb', line 57 def rbs_comments_to_sorbet_sigs(ruby_contents, file:, max_line_length: nil) RBSCommentsToSorbetSigs.new(ruby_contents, file: file, max_line_length: max_line_length).rewrite end |
.sorbet_assertions_to_rbs_comments(ruby_contents, file:, translate_t_let: true, translate_t_cast: true, translate_t_bind: true, translate_t_must: true, translate_t_unsafe: true) ⇒ Object
Converts all ‘T.let` and `T.cast` nodes to RBS comments in the given Ruby code. It also handles type members and class annotations. : ( | String, | file: String, | ?translate_t_let: bool, | ?translate_t_cast: bool, | ?translate_t_bind: bool, | ?translate_t_must: bool, | ?translate_t_unsafe: bool | ) -> String
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/spoom/sorbet/translate.rb', line 72 def sorbet_assertions_to_rbs_comments( ruby_contents, file:, translate_t_let: true, translate_t_cast: true, translate_t_bind: true, translate_t_must: true, translate_t_unsafe: true ) SorbetAssertionsToRBSComments.new( ruby_contents, file: file, translate_t_let: translate_t_let, translate_t_cast: translate_t_cast, translate_t_bind: translate_t_bind, translate_t_must: translate_t_must, translate_t_unsafe: translate_t_unsafe, ).rewrite end |
.sorbet_sigs_to_rbs_comments(ruby_contents, file:, positional_names: true, max_line_length: nil, translate_generics: true, translate_helpers: true, translate_abstract_methods: true) ⇒ Object
Converts all ‘sig` nodes to RBS comments in the given Ruby code. It also handles type members and class annotations. : ( | String, | file: String, | ?positional_names: bool, | ?max_line_length: Integer?, | ?translate_generics: bool, | ?translate_helpers: bool, | ?translate_abstract_methods: bool | ) -> String
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/spoom/sorbet/translate.rb', line 37 def sorbet_sigs_to_rbs_comments( ruby_contents, file:, positional_names: true, max_line_length: nil, translate_generics: true, translate_helpers: true, translate_abstract_methods: true ) SorbetSigsToRBSComments.new( ruby_contents, file: file, positional_names: positional_names, max_line_length: max_line_length, translate_generics: translate_generics, translate_helpers: translate_helpers, translate_abstract_methods: translate_abstract_methods, ).rewrite end |
.strip_sorbet_sigs(ruby_contents, file:) ⇒ Object
Deletes all ‘sig` nodes from the given Ruby code. It doesn’t handle type members and class annotations. : (String ruby_contents, file: String) -> String
22 23 24 |
# File 'lib/spoom/sorbet/translate.rb', line 22 def strip_sorbet_sigs(ruby_contents, file:) StripSorbetSigs.new(ruby_contents, file: file).rewrite end |