Class: Tapioca::Generator
- Inherits:
-
Thor::Shell::Color
- Object
- Thor::Shell::Color
- Tapioca::Generator
- Extended by:
- T::Sig
- Defined in:
- lib/tapioca/generator.rb
Constant Summary collapse
- DEFAULT_OUTDIR =
"sorbet/rbi/gems"
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#outdir ⇒ Object
readonly
Returns the value of attribute outdir.
-
#postrequire ⇒ Object
readonly
Returns the value of attribute postrequire.
-
#prerequire ⇒ Object
readonly
Returns the value of attribute prerequire.
-
#typed_overrides ⇒ Object
readonly
Returns the value of attribute typed_overrides.
Instance Method Summary collapse
- #build_gem_rbis(gem_names) ⇒ Object
-
#initialize(outdir: nil, prerequire: nil, postrequire: nil, command: nil, typed_overrides: nil) ⇒ Generator
constructor
A new instance of Generator.
- #sync_rbis_with_gemfile ⇒ Object
Constructor Details
#initialize(outdir: nil, prerequire: nil, postrequire: nil, command: nil, typed_overrides: nil) ⇒ Generator
Returns a new instance of Generator.
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/tapioca/generator.rb', line 33 def initialize(outdir: nil, prerequire: nil, postrequire: nil, command: nil, typed_overrides: nil) @outdir = T.let(Pathname.new(outdir || DEFAULT_OUTDIR), Pathname) @prerequire = T.let(prerequire, T.nilable(String)) @postrequire = T.let(postrequire, T.nilable(String)) @command = T.let(command || default_command, String) @typed_overrides = T.let(typed_overrides || {}, T::Hash[String, String]) @bundle = T.let(nil, T.nilable(Gemfile)) @compiler = T.let(nil, T.nilable(Compilers::SymbolTableCompiler)) @existing_rbis = T.let(nil, T.nilable(T::Hash[String, String])) @expected_rbis = T.let(nil, T.nilable(T::Hash[String, String])) super() end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
20 21 22 |
# File 'lib/tapioca/generator.rb', line 20 def command @command end |
#outdir ⇒ Object (readonly)
Returns the value of attribute outdir.
14 15 16 |
# File 'lib/tapioca/generator.rb', line 14 def outdir @outdir end |
#postrequire ⇒ Object (readonly)
Returns the value of attribute postrequire.
18 19 20 |
# File 'lib/tapioca/generator.rb', line 18 def postrequire @postrequire end |
#prerequire ⇒ Object (readonly)
Returns the value of attribute prerequire.
16 17 18 |
# File 'lib/tapioca/generator.rb', line 16 def prerequire @prerequire end |
#typed_overrides ⇒ Object (readonly)
Returns the value of attribute typed_overrides.
22 23 24 |
# File 'lib/tapioca/generator.rb', line 22 def typed_overrides @typed_overrides end |
Instance Method Details
#build_gem_rbis(gem_names) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/tapioca/generator.rb', line 47 def build_gem_rbis(gem_names) require_gem_file gems_to_generate(gem_names).map do |gem| say("Processing '#{gem.name}' gem:", :green) indent do compile_rbi(gem) puts end end say("All operations performed in working directory.", [:green, :bold]) say("Please review changes and commit them.", [:green, :bold]) end |
#sync_rbis_with_gemfile ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/tapioca/generator.rb', line 63 def sync_rbis_with_gemfile anything_done = [ perform_removals, perform_additions, ].any? if anything_done say("All operations performed in working directory.", [:green, :bold]) say("Please review changes and commit them.", [:green, :bold]) else say("No operations performed, all RBIs are up-to-date.", [:green, :bold]) end puts end |