lib/berkshelf/file_syncer.rb in berkshelf-5.5.0 vs lib/berkshelf/file_syncer.rb in berkshelf-5.6.0
- old
+ new
@@ -1,13 +1,13 @@
-require 'fileutils'
+require "fileutils"
module Berkshelf
module FileSyncer
extend self
# Files to be ignored during a directory globbing
- IGNORED_FILES = %w(. ..).freeze
+ IGNORED_FILES = %w{. ..}.freeze
#
# Glob across the given pattern, accounting for dotfiles, removing Ruby's
# dumb idea to include +'.'+ and +'..'+ as entries.
#
@@ -60,12 +60,12 @@
# let glob expand the source directory in case it is an abbreviated windows
# user directory: C:/Users/MATTWR~1/AppData/Local/Temp
# so that it matches the parent of source_files
source = glob(source).first
-
- source_files = glob(File.join(source, '**/*'))
+
+ source_files = glob(File.join(source, "**/*"))
source_files = source_files.reject do |source_file|
basename = relative_path_for(source_file, source)
excludes.any? { |exclude| File.fnmatch?(exclude, basename, File::FNM_DOTMATCH) }
end
@@ -92,11 +92,11 @@
end
when :file
FileUtils.cp(source_file, "#{destination}/#{relative_path}")
else
type = File.ftype(source_file)
- raise RuntimeError, "Unknown file type: `#{type}' at " \
+ raise "Unknown file type: `#{type}' at " \
"`#{source_file}'. Failed to sync `#{source_file}' to " \
"`#{destination}/#{relative_path}'!"
end
end
@@ -123,20 +123,21 @@
true
end
private
+
#
# The relative path of the given +path+ to the +parent+.
#
# @param [String] path
# the path to get relative with
# @param [String] parent
# the parent where the path is contained (hopefully)
#
# @return [String]
#
- def relative_path_for(path, parent)
- Pathname.new(path).relative_path_from(Pathname.new(parent)).to_s
- end
+ def relative_path_for(path, parent)
+ Pathname.new(path).relative_path_from(Pathname.new(parent)).to_s
+ end
end
end