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



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

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

Instance Method Details

#apply_templateObject



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

def apply_template
  root_template.apply(self, target_path)
end

#assert_clear_directoryObject



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

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

#nameString

Returns:

  • (String)


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

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

#option_listAvm::SourceGenerators::OptionList



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

delegate :option_list, to: :class

#performObject



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

def perform
  start_banner
  assert_clear_directory
  apply_template
  perform_jobs
end

#perform_jobsObject



53
54
55
56
57
58
# File 'lib/avm/source_generators/base.rb', line 53

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)


67
68
69
# File 'lib/avm/source_generators/base.rb', line 67

def root_template
  template
end

#start_bannervoid

This method returns an undefined value.



61
62
63
64
# File 'lib/avm/source_generators/base.rb', line 61

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