Class: Gitenv::Symlink

Inherits:
Object
  • Object
show all
Defined in:
lib/gitenv/symlink.rb

Instance Method Summary collapse

Constructor Details

#initialize(config, file, options = {}) ⇒ Symlink

Returns a new instance of Symlink.



7
8
9
# File 'lib/gitenv/symlink.rb', line 7

def initialize config, file, options = {}
  @config, @file, @options = config, file, options
end

Instance Method Details

#descriptionObject



23
24
25
# File 'lib/gitenv/symlink.rb', line 23

def description
  "#{link} -> #{target}"
end

#to_sObject



17
18
19
20
21
# File 'lib/gitenv/symlink.rb', line 17

def to_s
  color, mark, msg = status
  justification = @options[:justify] ? ' ' * (@options[:justify] - description.length) : ''
  %/ #{Paint[mark, color]} #{Paint[link, :cyan]} -> #{target}#{justification}#{Paint[msg, color]}/
end

#update!Object



11
12
13
14
15
# File 'lib/gitenv/symlink.rb', line 11

def update!
  unless File.exists? link
    File.symlink target, link
  end
end