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



22
23
24
25
26
# File 'lib/avm/source_generators/runner.rb', line 22

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

#generator_uncachedObject



34
35
36
37
38
# File 'lib/avm/source_generators/runner.rb', line 34

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

#optionsHash<String, String>

Returns:

  • (Hash<String, String>)


43
44
45
# File 'lib/avm/source_generators/runner.rb', line 43

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

#runObject



17
18
19
20
# File 'lib/avm/source_generators/runner.rb', line 17

def run
  start_banner
  generate
end

#start_bannerObject



28
29
30
31
32
# File 'lib/avm/source_generators/runner.rb', line 28

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

#target_pathObject



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

def target_path
  parsed.target_path.to_pathname
end