Sha256: 9ab1f416d33fe1c205004d616a61acc490ca0cd031b1b7097fea3b465357628d
Contents?: true
Size: 565 Bytes
Versions: 3
Compression:
Stored size: 565 Bytes
Contents
# frozen_string_literal: true require 'pathname' require 'fileutils' module Flexdot class Backup BASE_DIR = 'backup' class << self def clear_all base_dir.glob('*').each(&:rmtree) end def base_dir Pathname.pwd.join(BASE_DIR) end end def initialize backup_dir.mkpath unless backup_dir.exist? end def call(file) FileUtils.mv(file, backup_dir) end private def backup_dir @backup_dir ||= self.class.base_dir.join(Time.now.strftime('%Y%m%d%H%M%S')) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
flexdot-3.0.0 | lib/flexdot/backup.rb |
flexdot-2.0.0 | lib/flexdot/backup.rb |
flexdot-1.0.2 | lib/flexdot/backup.rb |