Class: Stevenson::Template::Local

Inherits:
Base
  • Object
show all
Defined in:
lib/stevenson/templates/local.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#name

Instance Method Summary collapse

Methods inherited from Base

#close, #place_config, #place_files

Constructor Details

#initialize(template_path, options) ⇒ Local

Returns a new instance of Local.



6
7
8
# File 'lib/stevenson/templates/local.rb', line 6

def initialize(template_path, options)
  @template_path, @options = template_path, options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/stevenson/templates/local.rb', line 4

def options
  @options
end

#template_pathObject (readonly)

Returns the value of attribute template_path.



4
5
6
# File 'lib/stevenson/templates/local.rb', line 4

def template_path
  @template_path
end

Instance Method Details

#local_directoryObject



10
11
12
13
14
15
16
17
18
# File 'lib/stevenson/templates/local.rb', line 10

def local_directory
  raise InvalidTemplateException.new('The given path is not a directory') unless File.directory?(template_path)

  @_local_directory ||= Dir.mktmpdir.tap do |dir|
    directories = [template_path, options[:subdirectory], '.'].compact

    FileUtils.cp_r File.join(*directories), dir
  end
end