Class: Wukong::Deploy::Templater

Inherits:
Object
  • Object
show all
Includes:
FileUtils, ConflictResolution, Messaging
Defined in:
lib/wukong-deploy/templater.rb

Overview

Templates out a deploy pack repo in a given directory.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ConflictResolution

#always_replace!, #always_replace?, #handle_conflict, #never_replace!, #never_replace?

Methods included from Messaging

#message, #message_conflict, #message_create, #message_replace, #message_same, #message_skip

Constructor Details

#initialize(root, options = {}) ⇒ Templater

Initialize a new Templater creating a deploy pack repository at the given root using the given options.

Parameters:

  • root (String)
  • options (Hash) (defaults to: {})


30
31
32
33
# File 'lib/wukong-deploy/templater.rb', line 30

def initialize root, options={}
  self.repo    = Repo.new(root)
  self.options = options
end

Instance Attribute Details

#optionsObject

The Configliere::Param settings.



19
20
21
# File 'lib/wukong-deploy/templater.rb', line 19

def options
  @options
end

#repoObject

The Wukong::Deploy::Repo being templated.



16
17
18
# File 'lib/wukong-deploy/templater.rb', line 16

def repo
  @repo
end

Instance Method Details

#dry_run?true?

Is this a dry run in which no files are actually created or modified on disk?

Returns:

  • (true, nil)


39
40
41
# File 'lib/wukong-deploy/templater.rb', line 39

def dry_run?
  options[:dry_run]
end

#run!Object

Run this templater.



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/wukong-deploy/templater.rb', line 44

def run!
  if dry_run?
    puts "Would perform the following actions in #{repo.root}"
  else
    puts "Within #{repo.root}:"
  end
  create_dirs
  create_templates
  create_gitkeeps
  create_gitignore
end

#templates_dirPathname

The directory containing templates used to generate the corresponding files in the new deploy pack repository.

Returns:

  • (Pathname)


60
61
62
# File 'lib/wukong-deploy/templater.rb', line 60

def templates_dir
  @templates_dir ||= Pathname.new(File.expand_path('../../../templates', __FILE__))
end