Class: Tapioca::Commands::Dsl
- Inherits:
-
CommandWithoutTracker
- Object
- Command
- CommandWithoutTracker
- Tapioca::Commands::Dsl
- Includes:
- RBIFilesHelper, SorbetHelper
- Defined in:
- lib/tapioca/commands/dsl.rb
Constant Summary
Constants included from SorbetHelper
SorbetHelper::FEATURE_REQUIREMENTS, SorbetHelper::SORBET_BIN, SorbetHelper::SORBET_EXE_PATH_ENV_VAR, SorbetHelper::SORBET_GEM_SPEC, SorbetHelper::SORBET_PAYLOAD_URL
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(requested_constants:, outpath:, only:, exclude:, file_header:, tapioca_path:, should_verify: false, quiet: false, verbose: false, number_of_workers: nil, auto_strictness: true, gem_dir: DEFAULT_GEM_DIR, rbi_formatter: DEFAULT_RBI_FORMATTER, app_root: ".") ⇒ Dsl
constructor
A new instance of Dsl.
- #list_compilers ⇒ Object
Methods included from RBIFilesHelper
#duplicated_nodes_from_index, #index_rbi, #index_rbis, #location_to_payload_url, #validate_rbi_files
Methods included from SorbetHelper
#sorbet, #sorbet_path, #sorbet_supports?
Methods included from Tapioca::CliHelper
#netrc_file, #rbi_formatter, #say_error
Constructor Details
#initialize(requested_constants:, outpath:, only:, exclude:, file_header:, tapioca_path:, should_verify: false, quiet: false, verbose: false, number_of_workers: nil, auto_strictness: true, gem_dir: DEFAULT_GEM_DIR, rbi_formatter: DEFAULT_RBI_FORMATTER, app_root: ".") ⇒ Dsl
Returns a new instance of Dsl.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/tapioca/commands/dsl.rb', line 28 def initialize( requested_constants:, outpath:, only:, exclude:, file_header:, tapioca_path:, should_verify: false, quiet: false, verbose: false, number_of_workers: nil, auto_strictness: true, gem_dir: DEFAULT_GEM_DIR, rbi_formatter: DEFAULT_RBI_FORMATTER, app_root: "." ) @requested_constants = requested_constants @outpath = outpath @only = only @exclude = exclude @file_header = file_header @tapioca_path = tapioca_path @should_verify = should_verify @quiet = quiet @verbose = verbose @number_of_workers = number_of_workers @auto_strictness = auto_strictness @gem_dir = gem_dir @rbi_formatter = rbi_formatter @app_root = app_root super() end |
Instance Method Details
#execute ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/tapioca/commands/dsl.rb', line 90 def execute Loaders::Dsl.load_application( tapioca_path: @tapioca_path, eager_load: @requested_constants.empty?, app_root: @app_root, ) if @should_verify say("Checking for out-of-date RBIs...") else say("Compiling DSL RBI files...") end say("") outpath = @should_verify ? Pathname.new(Dir.mktmpdir) : @outpath rbi_files_to_purge = existing_rbi_filenames(@requested_constants) pipeline = create_pipeline processed_files = pipeline.run do |constant, contents| constant_name = T.must(Tapioca::Runtime::Reflection.name_of(constant)) if @verbose && !@quiet say_status(:processing, constant_name, :yellow) end compile_dsl_rbi( constant_name, contents, outpath: outpath, quiet: @should_verify || (@quiet && !@verbose), ) end processed_files.each { |filename| rbi_files_to_purge.delete(T.must(filename)) } say("") if @should_verify perform_dsl_verification(outpath) else purge_stale_dsl_rbi_files(rbi_files_to_purge) say("Done", :green) if @auto_strictness say("") validate_rbi_files( command: default_command(:dsl, @requested_constants.join(" ")), gem_dir: @gem_dir, dsl_dir: @outpath.to_s, auto_strictness: @auto_strictness, compilers: pipeline.active_compilers, ) end say("All operations performed in working directory.", [:green, :bold]) say("Please review changes and commit them.", [:green, :bold]) end end |
#list_compilers ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/tapioca/commands/dsl.rb', line 63 def list_compilers Loaders::Dsl.load_application( tapioca_path: @tapioca_path, eager_load: @requested_constants.empty?, app_root: @app_root, ) pipeline = create_pipeline say("") say("Loaded DSL compiler classes:") say("") table = pipeline.compilers.map do |compiler| status = if pipeline.active_compilers.include?(compiler) set_color("enabled", :green) else set_color("disabled", :red) end [compiler.name, status] end print_table(table, { indent: 2 }) end |