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

Methods included from With::ApplicationStereotype

#stereotype_namespace_module

Class Method Details

.option_listAvm::SourceGenerators::OptionList



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

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

Instance Method Details

#apply_templateObject



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

def apply_template
  root_template.apply(self, target_path)
end

#assert_clear_directoryObject



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

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

#nameString

Returns:

  • (String)


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

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

#option_listAvm::SourceGenerators::OptionList



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

def option_list
  self.class.option_list
end

#performObject



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

def perform
  start_banner
  assert_clear_directory
  apply_template
  perform_jobs
end

#perform_jobsObject



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

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)


70
71
72
# File 'lib/avm/source_generators/base.rb', line 70

def root_template
  template
end

#start_bannervoid

This method returns an undefined value.



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

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