Class: Avm::EacRubyBase1::SourceGenerators::Base

Inherits:
SourceGenerators::Base
  • Object
show all
Defined in:
lib/avm/eac_ruby_base1/source_generators/base.rb

Defined Under Namespace

Classes: VersionBuilder

Constant Summary collapse

IDENT =
'  '
JOBS =
%w[root_directory gemspec root_lib version_lib static gemfile_lock].freeze
TEMPLATE_VARIABLES =
%w[lib_path name root_module].freeze
OPTIONS =
{
  'eac-ruby-utils-version'.to_sym => 'Version for "eac_ruby_utils" gem.',
  'eac-ruby-gem-support-version'.to_sym => 'Version for "eac_ruby_gem_support" gem.'
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.option_listObject



24
25
26
# File 'lib/avm/eac_ruby_base1/source_generators/base.rb', line 24

def option_list
  OPTIONS.inject(super) { |a, e| a.option(*e) }
end

Instance Method Details

#eac_ruby_gem_support_versionObject



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

def eac_ruby_gem_support_version
  dependency_version('eac_ruby_gem_support')
end

#eac_ruby_utils_versionObject



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

def eac_ruby_utils_version
  dependency_version('eac_ruby_utils')
end

#lib_pathObject



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

def lib_path
  name.split('-').join('/')
end

#nameObject



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

def name
  root_directory.basename.to_s
end

#performObject



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

def perform
  infov 'Root directory', root_directory
  infov 'Gem name', name
  JOBS.each do |job|
    infom "Generating #{job.humanize}..."
    send("generate_#{job}")
  end
end

#root_directoryObject



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

def root_directory
  target_path
end

#root_moduleObject



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

def root_module
  lib_path.camelize
end

#root_module_closeObject



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

def root_module_close
  root_module_components.count.times.map do |index|
    (IDENT * index) + 'end'
  end.reverse.join("\n")
end

#root_module_componentsObject



78
79
80
# File 'lib/avm/eac_ruby_base1/source_generators/base.rb', line 78

def root_module_components
  root_module.split('::')
end

#root_module_inner_identationObject



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

def root_module_inner_identation
  IDENT * root_module_components.count
end

#root_module_openObject



72
73
74
75
76
# File 'lib/avm/eac_ruby_base1/source_generators/base.rb', line 72

def root_module_open
  root_module_components.each_with_index.map do |component, index|
    (IDENT * index) + 'module ' + component
  end.join("\n")
end