Separate the action handling of ln_s into a new method to lower complexity
This commit is contained in:
@@ -9,8 +9,5 @@ Eval:
|
|||||||
ClassLength:
|
ClassLength:
|
||||||
Enabled: false
|
Enabled: false
|
||||||
|
|
||||||
CyclomaticComplexity:
|
|
||||||
Max: 7
|
|
||||||
|
|
||||||
MethodLength:
|
MethodLength:
|
||||||
Max: 36
|
Max: 36
|
||||||
|
|||||||
@@ -156,17 +156,31 @@ class Homesick
|
|||||||
destination = Pathname.new(destination)
|
destination = Pathname.new(destination)
|
||||||
FileUtils.mkdir_p destination.dirname
|
FileUtils.mkdir_p destination.dirname
|
||||||
|
|
||||||
if destination.symlink? && destination.readlink == source
|
action = if destination.symlink? && destination.readlink == source
|
||||||
say_status :identical, destination.expand_path, :blue unless options[:quiet]
|
:identical
|
||||||
elsif destination.symlink?
|
elsif destination.symlink?
|
||||||
|
:symlink_conflict
|
||||||
|
elsif destination.exist?
|
||||||
|
:conflict
|
||||||
|
else
|
||||||
|
:success
|
||||||
|
end
|
||||||
|
|
||||||
|
handle_symlink_action action, source, destination
|
||||||
|
end
|
||||||
|
|
||||||
|
def handle_symlink_action(action, source, destination)
|
||||||
|
case action
|
||||||
|
when :identical
|
||||||
|
say_status :identical, destination.expand_path, :blue unless options[:quiet]
|
||||||
|
when :symlink_conflict
|
||||||
say_status :conflict,
|
say_status :conflict,
|
||||||
"#{destination} exists and points to " \
|
"#{destination} exists and points to " \
|
||||||
"#{destination.readlink}",
|
"#{destination.readlink}",
|
||||||
:red unless options[:quiet]
|
:red unless options[:quiet]
|
||||||
|
|
||||||
smart_system "ln -nsf '#{source}' '#{destination}'" \
|
system "ln -nsf '#{source}' '#{destination}'" if collision_accepted?
|
||||||
if collision_accepted?
|
when :conflict
|
||||||
elsif destination.exist?
|
|
||||||
say_status :conflict, "#{destination} exists", :red unless options[:quiet]
|
say_status :conflict, "#{destination} exists", :red unless options[:quiet]
|
||||||
|
|
||||||
if collision_accepted?
|
if collision_accepted?
|
||||||
|
|||||||
Reference in New Issue
Block a user