class Caco::FileLink
Public Instance Methods
create_link!(ctx, target:, link:, link_exist:, link_same_target:, **)
click to toggle source
# File lib/caco/file_link.rb, line 31 def create_link!(ctx, target:, link:, link_exist:, link_same_target:, **) ctx[:force] = (link_exist && !link_same_target) FileUtils.ln_s target, link, force: ctx[:force] ctx[:link_created] = true end
ensure_target!(ctx, target_exist:, ensure_target: false, **)
click to toggle source
# File lib/caco/file_link.rb, line 26 def ensure_target!(ctx, target_exist:, ensure_target: false, **) return false if !target_exist && ensure_target true end
link_exist?(ctx, link:, **)
click to toggle source
# File lib/caco/file_link.rb, line 10 def link_exist?(ctx, link:, **) ctx[:link_exist] = !!File.lstat(link) rescue false ctx[:link_realpath] = File.realdirpath(link) rescue false ctx[:link_exist] end
link_same_target?(ctx, target_realpath:, link_realpath:, **)
click to toggle source
# File lib/caco/file_link.rb, line 22 def link_same_target?(ctx, target_realpath:, link_realpath:, **) ctx[:link_same_target] = (target_realpath == link_realpath) end
target_exist?(ctx, target:, **)
click to toggle source
# File lib/caco/file_link.rb, line 16 def target_exist?(ctx, target:, **) ctx[:target_exist] = File.exist?(target) ctx[:target_realpath] = File.realdirpath(target) rescue nil ctx[:target_exist] end