Skip to content

ScrappyAcademy/log_rotate_starter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

log_rotate

This is the starter repo for the 'Log Rotator' project.

Please do not push to this repo.

Getting Started

  1. Fork the repo
  2. Have fun!

Background

Your client has an external backup process which creates a new archive file every day and saves it to a directory. To prevent the disk from filling, they have hired you to create a program to rotate the backups based on a specified retention policy.

Givens

  • All files of interest are in a single directory, 'files'
  • All files of interest contain the creation date in the name
  • The non-date portion of the file name is consistent between files
  • There is at most one file per date
  • There may be other files in the directory (no date in the name)
  • Some dates may not have a file

Requirements

  • Create a command line executable
  • When the executable is run, it should determine which files to keep based on the retention policy
  • All other files should be deleted
  • Get a basic implementation working before adding new features!

Retention Policy

  • 7 most recent daily files
  • 4 most recent Sunday files
  • 3 most recent first of the month files
  • If a file for a given date is missing, continue searching for the next file matching the criteria. For example, if run on 9/20 and 9/1 is missing, the files for 8/1, 7/1 and 6/1 should be retained.
  • Files with no date in the name should be kept

Beyond the Basics

Once you have a basic implementation, consider these questions:

  • The client wants to be able to run the command interactively, how would you present the interface? Prompts? Menus?
  • The client also wants to be able to run the command non-interactively. Again what interface would you use? Arguments? Config file? How would you know to be interactive or not?
  • What inputs do you require from the user? Are there reasonable defaults?
  • How easy would it be to update the retention policy to keep the last 12 Sundays? How about every second Tuesday of the month?

Extra Credit

  • Make sure your executable also works with the files from 'files2' and 'files3'
  • Automatically detect different date formats in the same directory
  • Handle multiple sets of files (different non-date portions of file name)
  • Did you use TDD?
  • Package the core code into a gem. Then use that gem in your program.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published