Minor fixes suggested by rubocop.

This commit is contained in:
Jeremy Cook
2019-01-18 23:32:31 -05:00
parent dd7d52a25d
commit f09c62d922
2 changed files with 9 additions and 12 deletions

View File

@@ -1,4 +1,3 @@
# -*- encoding : utf-8 -*-
module Homesick module Homesick
module Actions module Actions
# File-related helper methods for Homesick # File-related helper methods for Homesick
@@ -6,13 +5,10 @@ module Homesick
def mv(source, destination) def mv(source, destination)
source = Pathname.new(source) source = Pathname.new(source)
destination = Pathname.new(destination + source.basename) destination = Pathname.new(destination + source.basename)
case if destination.exist? && (options[:force] || shell.file_collision(destination) { source })
when destination.exist? && (options[:force] || shell.file_collision(destination) { source })
say_status :conflict, "#{destination} exists", :red say_status :conflict, "#{destination} exists", :red
FileUtils.mv source, destination unless options[:pretend]
else
FileUtils.mv source, destination unless options[:pretend]
end end
FileUtils.mv source, destination unless options[:pretend]
end end
def rm_rf(dir) def rm_rf(dir)
@@ -24,7 +20,7 @@ module Homesick
target = Pathname.new(target) target = Pathname.new(target)
if target.symlink? if target.symlink?
say_status :unlink, "#{target.expand_path}", :green say_status :unlink, target.expand_path.to_s, :green
FileUtils.rm_rf target FileUtils.rm_rf target
else else
say_status :conflict, "#{target} is not a symlink", :red say_status :conflict, "#{target} is not a symlink", :red
@@ -68,8 +64,8 @@ module Homesick
say_status :conflict, "#{destination} exists", :red say_status :conflict, "#{destination} exists", :red
else else
say_status :conflict, say_status :conflict,
"#{destination} exists and points to #{destination.readlink}", "#{destination} exists and points to #{destination.readlink}",
:red :red
end end
if collision_accepted?(destination, source) if collision_accepted?(destination, source)
FileUtils.rm_r destination, force: true unless options[:pretend] FileUtils.rm_r destination, force: true unless options[:pretend]

View File

@@ -136,11 +136,12 @@ module Homesick
def link(name = DEFAULT_CASTLE_NAME) def link(name = DEFAULT_CASTLE_NAME)
check_castle_existance(name, 'symlink') check_castle_existance(name, 'symlink')
inside castle_dir(name) do castle_path = castle_dir(name)
inside castle_path do
subdirs = subdirs(name) subdirs = subdirs(name)
# link files # link files
symlink_each(name, castle_dir(name), subdirs) symlink_each(name, castle_path, subdirs)
# link files in subdirs # link files in subdirs
subdirs.each do |subdir| subdirs.each do |subdir|