Class: Begin::SymlinkTemplate

Inherits:
Template
  • Object
show all
Defined in:
lib/begin/template.rb

Overview

Encapsulates the logic for templates that are installed as symlinks on the user’s machine.

Constant Summary

Constants inherited from Template

Template::CONFIG_NAME

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Template

#config, #config_path, #ensure_name_not_empty, #ensure_no_back_references, #ensure_no_conflicts, #process_file, #process_files, #process_path_name, #process_path_names, #process_path_names_in_dir, #run

Constructor Details

#initialize(path) ⇒ SymlinkTemplate

Returns a new instance of SymlinkTemplate.



124
125
126
127
# File 'lib/begin/template.rb', line 124

def initialize(path)
  super path
  @path.ensure_symlink_exists
end

Class Method Details

.install(source_uri, path) ⇒ Object



129
130
131
132
133
134
135
136
137
138
139
# File 'lib/begin/template.rb', line 129

def self.install(source_uri, path)
  source_path = Path.new source_uri, '.', 'Source path'
  source_path.ensure_dir_exists
  begin
    File.symlink source_path, path
    Output.success "Created symbolic link to '#{source_path}'"
  rescue NotImplementedError
    raise NotImplementedError, 'TODO: Copy tree when symlinks not supported'
  end
  SymlinkTemplate.new path
end

Instance Method Details

#uninstallObject



145
146
147
# File 'lib/begin/template.rb', line 145

def uninstall
  File.unlink @path
end

#updateObject



141
142
143
# File 'lib/begin/template.rb', line 141

def update
  # Do nothing. Symlink templates are always up-to-date.
end