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.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/tapioca/dsl/pipeline.rb', line 32 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.
12 13 14 |
# File 'lib/tapioca/dsl/pipeline.rb', line 12 def compilers @compilers end |
#error_handler ⇒ Object (readonly)
Returns the value of attribute error_handler.
18 19 20 |
# File 'lib/tapioca/dsl/pipeline.rb', line 18 def error_handler @error_handler end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
21 22 23 |
# File 'lib/tapioca/dsl/pipeline.rb', line 21 def errors @errors end |
#requested_constants ⇒ Object (readonly)
Returns the value of attribute requested_constants.
15 16 17 |
# File 'lib/tapioca/dsl/pipeline.rb', line 15 def requested_constants @requested_constants end |
Instance Method Details
#add_error(error) ⇒ Object
84 85 86 |
# File 'lib/tapioca/dsl/pipeline.rb', line 84 def add_error(error) @errors << error end |
#compiler_enabled?(compiler_name) ⇒ Boolean
89 90 91 92 93 94 95 |
# File 'lib/tapioca/dsl/pipeline.rb', line 89 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
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 80 81 |
# File 'lib/tapioca/dsl/pipeline.rb', line 54 def run(&blk) constants_to_process = gather_constants(requested_constants) .select { |c| Runtime::Reflection.name_of(c) && Module === c } # Filter anonymous or value constants .sort_by! { |c| T.must(Runtime::Reflection.name_of(c)) } if constants_to_process.empty? report_error(" No classes/modules can be matched for RBI generation.\n Please check that the requested classes/modules include processable DSL methods.\n ERROR\n end\n\n result = Executor.new(\n constants_to_process,\n number_of_workers: @number_of_workers\n ).run_in_parallel do |constant|\n rbi = rbi_for_constant(constant)\n next if rbi.nil?\n\n blk.call(constant, rbi)\n end\n\n errors.each do |msg|\n report_error(msg)\n end\n\n result.compact\nend\n") |