forked from strchives/vim-config
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtranslation.rb
More file actions
46 lines (35 loc) · 832 Bytes
/
Copy pathtranslation.rb
File metadata and controls
46 lines (35 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require 'rake/win32'
require 'fileutils'
require 'pathname'
require File.join(File.dirname(__FILE__), 'installer')
class Translation
attr_accessor :source, :target
def initialize(source_path, target_path)
@source = pathname(source_path)
@target = pathname(target_path)
end
def link
raise "This source file does not exist: #{source}" unless source_exists?
`ln -s \"#{source}\" \"#{target}\"`
end
def force_link
FileUtils.rm_rf(target) && link
end
def safe_to_link?
identical? || !target_exists?
end
def source_exists?
File.exists?(source)
end
def target_exists?
File.exists?(target)
end
def identical?
File.identical?(source, target)
end
private
def pathname(file)
path = Installer.translate_path(file)
Pathname.new(path).expand_path
end
end