Class: Foobara::Generators::Generate
- Defined in:
- foobara-files-generator-0.0.5/src/generate.rb
Direct Known Subclasses
AutocrudGenerator::GenerateAutocrud, CommandGenerator::GenerateCommand, DomainGenerator::GenerateDomain, DomainMapperGenerator::GenerateDomainMapper, EmptyRubyProjectGenerator::GenerateEmptyRubyProject, OrganizationGenerator::GenerateOrganization, RackConnectorGenerator::GenerateRackConnector, RemoteImportsGenerator::GenerateRemoteImports, ResqueConnectorGenerator::GenerateResqueConnector, TypeGenerator::GenerateType, RemoteGenerator::GenerateTypescript
Constant Summary
Constants included from TruncatedInspect
Instance Attribute Summary collapse
-
#element_to_generate ⇒ Object
Returns the value of attribute element_to_generate.
Attributes included from CommandPatternImplementation::Concerns::Subcommands
Attributes included from CommandPatternImplementation::Concerns::Runtime
Attributes included from CommandPatternImplementation::Concerns::Errors
Attributes included from CommandPatternImplementation::Concerns::Inputs
Instance Method Summary collapse
- #base_generator ⇒ Object
- #each_element_to_generate ⇒ Object
- #elements_to_generate ⇒ Object
- #generate_element ⇒ Object
- #generated ⇒ Object
- #generated_elements ⇒ Object
- #include_non_templated_files ⇒ Object
- #paths_to_source_code ⇒ Object
- #templates_dir ⇒ Object
Methods inherited from Command
Methods included from Concern
foobara_class_methods_module_for, foobara_concern?, included
Methods included from CommandPatternImplementation::Concerns::Reflection
Methods included from CommandPatternImplementation::Concerns::DomainMappers
#domain_map, #domain_map!, #run_mapped_subcommand!
Methods included from CommandPatternImplementation::Concerns::Subcommands
#run_subcommand!, #subcommand?
Methods included from CommandPatternImplementation::Concerns::Entities
Methods included from CommandPatternImplementation::Concerns::Transactions
#auto_detect_current_transactions, #commit_transaction, #open_transaction, #opened_transactions, #relevant_entity_classes, #rollback_transaction, #transactions
Methods included from CommandPatternImplementation::Concerns::StateMachine
Methods included from CommandPatternImplementation::Concerns::Runtime
#execute, #halt!, #run, #run!, #run_execute, #succeed, #success?, #validate, #validate_records
Methods included from CommandPatternImplementation::Concerns::Errors
Methods included from CommandPatternImplementation::Concerns::Inputs
#cast_and_validate_inputs, #initialize, #method_missing, #respond_to_missing?, #respond_to_missing_for_inputs?
Methods included from TruncatedInspect
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Foobara::CommandPatternImplementation::Concerns::Inputs
Instance Attribute Details
#element_to_generate ⇒ Object
Returns the value of attribute element_to_generate.
9 10 11 |
# File 'foobara-files-generator-0.0.5/src/generate.rb', line 9 def element_to_generate @element_to_generate end |
Instance Method Details
#base_generator ⇒ Object
11 12 13 14 15 |
# File 'foobara-files-generator-0.0.5/src/generate.rb', line 11 def base_generator # :nocov: raise "subclass responsibility" # :nocov: end |
#each_element_to_generate ⇒ Object
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 'foobara-files-generator-0.0.5/src/generate.rb', line 29 def each_element_to_generate until elements_to_generate.empty? element_to_generate = elements_to_generate.first elements_to_generate.delete(element_to_generate) generators = if element_to_generate.is_a?(FilesGenerator) if generated.include?(element_to_generate) [] else elements_to_generate << element_to_generate.relevant_manifest [element_to_generate] end else if generated_elements.include?(element_to_generate) next end generated_elements << element_to_generate base_generator.generators_for(element_to_generate).select do |generator| generator.applicable? && !generated.include?(generator) end end generators.each do |generator| # TODO: change this name self.element_to_generate = generator generated << generator yield end end end |
#elements_to_generate ⇒ Object
17 18 19 |
# File 'foobara-files-generator-0.0.5/src/generate.rb', line 17 def elements_to_generate @elements_to_generate ||= Set.new end |
#generate_element ⇒ Object
62 63 64 65 66 67 |
# File 'foobara-files-generator-0.0.5/src/generate.rb', line 62 def generate_element return unless element_to_generate.applicable? paths_to_source_code[Util.array(element_to_generate.target_path).join("/")] = element_to_generate.generate(elements_to_generate) end |
#generated ⇒ Object
21 22 23 |
# File 'foobara-files-generator-0.0.5/src/generate.rb', line 21 def generated @generated ||= Set.new end |
#generated_elements ⇒ Object
25 26 27 |
# File 'foobara-files-generator-0.0.5/src/generate.rb', line 25 def generated_elements @generated_elements ||= Set.new end |
#include_non_templated_files ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'foobara-files-generator-0.0.5/src/generate.rb', line 69 def include_non_templated_files templates_dir_pathname = Pathname.new(templates_dir) Find.find(templates_dir) do |file_path| next if File.directory?(file_path) next if file_path.end_with?(".erb") file_path = Pathname.new(file_path) relative_path = file_path.relative_path_from(templates_dir_pathname) paths_to_source_code[relative_path.to_s] = File.read(file_path) end end |
#paths_to_source_code ⇒ Object
88 89 90 |
# File 'foobara-files-generator-0.0.5/src/generate.rb', line 88 def paths_to_source_code @paths_to_source_code ||= {} end |
#templates_dir ⇒ Object
84 85 86 |
# File 'foobara-files-generator-0.0.5/src/generate.rb', line 84 def templates_dir base_generator.templates_dir end |