Created
December 17, 2010 19:57
-
-
Save geoffreywiseman/745599 to your computer and use it in GitHub Desktop.
An example of what a prune DSL could look like.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
preprocess do |file| | |
file.modified_time = File.mtime( file.name ) | |
modified_date = Date.parse modified_time.to_s | |
file.days_since_modified = Date.today - modified_date | |
file.months_since_modified = ( Date.today.year - modified_date.year ) * 12 + (Date.today.month - modified_date.month) | |
end | |
category "Ignoring directories" do | |
match { |file| File.directory?(file.name) } | |
ignore | |
end | |
category "Retaining Files from the Last Two Weeks" do | |
match do |file| | |
file.days_since_modified <= 14 | |
end | |
retain | |
end | |
category "Retaining 'Friday' Files in Last Two Months" do | |
match { |file| file.modified_time.wday == 5 && file.months_since_modified < 2 && file.days_since_modified > 14 } | |
retain | |
end | |
category "Removing Non-Friday Files Older Than Two Weeks" do | |
match { |file| file.modified_time.wday != 5 && file.days_since_modified > 14 } | |
remove | |
end | |
category "Archiving Files Order than Last Two Months" do | |
match { |file| file.modified_time.wday == 5 && file.months_since_modified >= 2 } | |
archive | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment