Class: Rucoa::Yard::DefinitionsLoader
- Inherits:
-
Object
- Object
- Rucoa::Yard::DefinitionsLoader
- Defined in:
- lib/rucoa/yard/definitions_loader.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Array<Rucoa::Definition::Base>
- #comment_for(node) ⇒ String
-
#initialize(associations:, root_node:) ⇒ DefinitionsLoader
constructor
A new instance of DefinitionsLoader.
Constructor Details
#initialize(associations:, root_node:) ⇒ DefinitionsLoader
Returns a new instance of DefinitionsLoader.
26 27 28 29 30 31 32 |
# File 'lib/rucoa/yard/definitions_loader.rb', line 26 def initialize( associations:, root_node: ) @associations = associations @root_node = root_node end |
Class Method Details
.call(associations:, root_node:) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/rucoa/yard/definitions_loader.rb', line 13 def call( associations:, root_node: ) new( associations: associations, root_node: root_node ).call end |
Instance Method Details
#call ⇒ Array<Rucoa::Definition::Base>
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/rucoa/yard/definitions_loader.rb', line 35 def call [ @root_node, *@root_node.descendant_nodes ].flat_map do |node| [ DefinitionGenerators::ClassDefinitionGenerator, DefinitionGenerators::ConstantAssignmentDefinitionGenerator, DefinitionGenerators::MethodDefinitionGenerator, DefinitionGenerators::ModuleDefinitionGenerator, DefinitionGenerators::AttributeReaderDefinitionGenerator, DefinitionGenerators::AttributeWriterDefinitionGenerator ].flat_map do |generator| generator.call( comment: comment_for(node), node: node ) end end end |
#comment_for(node) ⇒ String
57 58 59 60 61 |
# File 'lib/rucoa/yard/definitions_loader.rb', line 57 def comment_for(node) @associations[node.location].map do |parser_comment| parser_comment.text.gsub(/^#\s*/m, '') end.join("\n") end |