Class: Tapioca::Dsl::Pipeline
- Inherits:
-
Object
- Object
- Tapioca::Dsl::Pipeline
- Extended by:
- T::Sig
- Defined in:
- lib/tapioca/dsl/pipeline.rb
Instance Attribute Summary collapse
-
#compilers ⇒ Object
readonly
Returns the value of attribute compilers.
-
#error_handler ⇒ Object
readonly
Returns the value of attribute error_handler.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#requested_constants ⇒ Object
readonly
Returns the value of attribute requested_constants.
Instance Method Summary collapse
- #add_error(error) ⇒ Object
- #compiler_enabled?(compiler_name) ⇒ Boolean
-
#initialize(requested_constants:, requested_compilers: [], excluded_compilers: [], error_handler: $stderr.method(:puts).to_proc, number_of_workers: nil) ⇒ Pipeline
constructor
A new instance of Pipeline.
- #run(&blk) ⇒ Object
Constructor Details
#initialize(requested_constants:, requested_compilers: [], excluded_compilers: [], error_handler: $stderr.method(:puts).to_proc, number_of_workers: nil) ⇒ Pipeline
Returns a new instance of Pipeline.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/tapioca/dsl/pipeline.rb', line 30 def initialize( requested_constants:, requested_compilers: [], excluded_compilers: [], error_handler: $stderr.method(:puts).to_proc, number_of_workers: nil ) @compilers = T.let( gather_compilers(requested_compilers, excluded_compilers), T::Enumerable[T.class_of(Compiler)] ) @requested_constants = requested_constants @error_handler = error_handler @number_of_workers = number_of_workers @errors = T.let([], T::Array[String]) end |
Instance Attribute Details
#compilers ⇒ Object (readonly)
Returns the value of attribute compilers.
10 11 12 |
# File 'lib/tapioca/dsl/pipeline.rb', line 10 def compilers @compilers end |
#error_handler ⇒ Object (readonly)
Returns the value of attribute error_handler.
16 17 18 |
# File 'lib/tapioca/dsl/pipeline.rb', line 16 def error_handler @error_handler end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
19 20 21 |
# File 'lib/tapioca/dsl/pipeline.rb', line 19 def errors @errors end |
#requested_constants ⇒ Object (readonly)
Returns the value of attribute requested_constants.
13 14 15 |
# File 'lib/tapioca/dsl/pipeline.rb', line 13 def requested_constants @requested_constants end |
Instance Method Details
#add_error(error) ⇒ Object
82 83 84 |
# File 'lib/tapioca/dsl/pipeline.rb', line 82 def add_error(error) @errors << error end |
#compiler_enabled?(compiler_name) ⇒ Boolean
87 88 89 90 91 92 93 |
# File 'lib/tapioca/dsl/pipeline.rb', line 87 def compiler_enabled?(compiler_name) potential_names = Compilers::NAMESPACES.map { |namespace| namespace + compiler_name } @compilers.any? do |compiler| potential_names.any?(compiler.name) end end |
#run(&blk) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/tapioca/dsl/pipeline.rb', line 52 def run(&blk) constants_to_process = gather_constants(requested_constants) .select { |c| Module === c } # Filter value constants out .sort_by! { |c| T.must(Runtime::Reflection.name_of(c)) } if constants_to_process.empty? report_error(<<~ERROR) No classes/modules can be matched for RBI generation. Please check that the requested classes/modules include processable DSL methods. ERROR end result = Executor.new( constants_to_process, number_of_workers: @number_of_workers ).run_in_parallel do |constant| rbi = rbi_for_constant(constant) next if rbi.nil? blk.call(constant, rbi) end errors.each do |msg| report_error(msg) end result.compact end |