Class: Avm::SourceGenerators::Base

Inherits:
Object
  • Object
show all
Includes:
With::ApplicationStereotype
Defined in:
lib/avm/source_generators/base.rb

Constant Summary collapse

OPTION_NAME =
'name'
JOBS =
[].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.option_listAvm::SourceGenerators::OptionList



13
14
15
# File 'lib/avm/source_generators/base.rb', line 13

def option_list
  Avm::SourceGenerators::OptionList.new
end

Instance Method Details

#apply_templateObject



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

def apply_template
  root_template.apply(self, target_path)
end

#assert_clear_directoryObject



41
42
43
44
# File 'lib/avm/source_generators/base.rb', line 41

def assert_clear_directory
  target_path.mkpath
  raise "\"#{target_path}\" is not empty" if target_path.children.any?
end

#nameString

Returns:

  • (String)


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

def name
  options[OPTION_NAME].if_present(target_path.basename.to_path)
end

#option_listAvm::SourceGenerators::OptionList



32
# File 'lib/avm/source_generators/base.rb', line 32

delegate :option_list, to: :class

#performObject



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

def perform
  start_banner
  assert_clear_directory
  apply_template
  perform_jobs
end

#perform_jobsObject



50
51
52
53
54
55
# File 'lib/avm/source_generators/base.rb', line 50

def perform_jobs
  setting_value(:jobs).each do |job|
    infom "Generating #{job.humanize}..."
    send("generate_#{job}")
  end
end

#root_templateEacTemlates::Modules::Base

Returns:

  • (EacTemlates::Modules::Base)


64
65
66
# File 'lib/avm/source_generators/base.rb', line 64

def root_template
  template
end

#start_bannervoid

This method returns an undefined value.



58
59
60
61
# File 'lib/avm/source_generators/base.rb', line 58

def start_banner
  infov 'Target path', target_path
  infov 'Application name', name
end