Class: RepoManager::Generate

Inherits:
Thor
  • Object
show all
Includes:
ThorHelper, ViewHelper, Thor::Actions
Defined in:
lib/repo_manager/tasks/generate/init.rb

Instance Method Summary collapse

Methods included from ViewHelper

#path_to

Methods included from ThorHelper

#configuration, #configuration=, #ruby_binary

Methods included from ActionHelper

#relative_path, #shell_quote, #windows?

Instance Method Details

#init(path) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/repo_manager/tasks/generate/init.rb', line 12

def init(path)
  logger.debug "init task initial configuration: #{configuration.inspect}"

  # create instance var so that it can be referenced in templates
  @path = path ? File.expand_path(path) : FileUtils.pwd

  source = path_to(:repo_manager, File.join('lib', 'repo_manager', 'tasks', 'generate', 'templates', 'config', 'repo.conf.tt'))
  destination = File.join(@path, 'repo.conf')

  say_status :init, "creating initial config file at '#{destination}'"
  template(source, destination)

  source = path_to(:repo_manager, File.join('lib', 'repo_manager', 'tasks', 'generate', 'templates', 'init', '.'))
  destination = @path

  say_status :init, "creating initial file structure in '#{destination}'"
  directory(source, destination)

  return 0
end