Class: Avm::SourceGenerators::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/avm/source_generators/runner.rb

Constant Summary collapse

OPTION_NAME_VALUE_SEPARATOR =
':'

Instance Method Summary collapse

Instance Method Details

#generateObject



19
20
21
22
23
# File 'lib/avm/source_generators/runner.rb', line 19

def generate
  infom 'Generating...'
  generator.perform
  success "Source generated in \"#{generator.target_path}\""
end

#generator_uncachedObject



37
38
39
40
41
# File 'lib/avm/source_generators/runner.rb', line 37

def generator_uncached
  ::Avm::Registry.source_generators
    .detect_optional(stereotype_name, target_path, options) ||
    fatal_error("No generator found for stereotype \"#{stereotype_name}\"")
end

#help_extra_textString

Returns:

  • (String)


26
27
28
29
# File 'lib/avm/source_generators/runner.rb', line 26

def help_extra_text
  help_list_section('Stereotypes', ::Avm::Registry.source_generators.available
    .map(&:application_stereotype_name))
end

#optionsHash<String, String>

Returns:

  • (Hash<String, String>)


46
47
48
# File 'lib/avm/source_generators/runner.rb', line 46

def options
  parsed.option.to_h { |v| v.split(OPTION_NAME_VALUE_SEPARATOR) }
end

#runObject



14
15
16
17
# File 'lib/avm/source_generators/runner.rb', line 14

def run
  start_banner
  generate
end

#start_bannerObject



31
32
33
34
35
# File 'lib/avm/source_generators/runner.rb', line 31

def start_banner
  infov 'Stereotype', stereotype_name
  infov 'Target path', target_path
  infov 'Generator', generator.class
end

#target_pathObject



50
51
52
# File 'lib/avm/source_generators/runner.rb', line 50

def target_path
  parsed.target_path.to_pathname
end