class Worktree::Feature::CopyFiles
Public Class Methods
new(project_dir:, branch:)
click to toggle source
# File lib/worktree/feature/copy_files.rb, line 9 def initialize(project_dir:, branch:) @project_dir = project_dir @branch = branch end
Public Instance Methods
run!()
click to toggle source
# File lib/worktree/feature/copy_files.rb, line 14 def run! files_to_copy.each { |path| copy_file(path) } end
Private Instance Methods
copy_file(file)
click to toggle source
# File lib/worktree/feature/copy_files.rb, line 24 def copy_file(file) master_path = "#{@project_dir}/master/#{file}" if File.exist?(master_path) FileUtils.cp_r master_path, "#{@project_dir}/#{@branch}/#{file}" else print "The path #{master_path} was not found!" end end
files_to_copy()
click to toggle source
# File lib/worktree/feature/copy_files.rb, line 20 def files_to_copy Worktree::Project.resolve(@branch, project_dir: @project_dir).copy_files end