From 7a29b1d1455146ff8d9dd5fdf600e48ccef399b2 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Mon, 21 Mar 2016 22:31:22 -0400 Subject: [PATCH] Basic maintenance --- kgrader.rb | 10 ---------- lib/kgrader/cli.rb | 16 ++++++++++++++-- rakefile | 12 ++++++++++++ 3 files changed, 26 insertions(+), 12 deletions(-) delete mode 100755 kgrader.rb create mode 100644 rakefile diff --git a/kgrader.rb b/kgrader.rb deleted file mode 100755 index 9ae2a51..0000000 --- a/kgrader.rb +++ /dev/null @@ -1,10 +0,0 @@ -#! /usr/bin/env ruby - -require_relative 'lib/kgrader' - -def main - cli = KGrader::CLI.new - cli.test -end - -main diff --git a/lib/kgrader/cli.rb b/lib/kgrader/cli.rb index 1d74564..0bfd6ea 100644 --- a/lib/kgrader/cli.rb +++ b/lib/kgrader/cli.rb @@ -1,8 +1,20 @@ module KGrader class CLI - def test - puts 'Hello, world!' + def initialize(dir) + @dir = dir + end + + def reset_jail + jail_dir = File.join(@dir, 'jail') + FileUtils.rm_rf jail_dir + FileUtils.mkdir jail_dir + FileUtils.touch File.join(jail_dir, '.gitkeep') + end + + def reset_desk + desk_dir = File.join(@dir, 'desk') + FileUtils.rm_rf Dir.glob(File.join(desk_dir, '*', '')) end end end diff --git a/rakefile b/rakefile new file mode 100644 index 0000000..ee5bdc9 --- /dev/null +++ b/rakefile @@ -0,0 +1,12 @@ +require_relative 'lib/kgrader' + +task :clean do + cli = KGrader::CLI.new Rake.application.original_dir + cli.reset_jail +end + +task :clobber do + cli = KGrader::CLI.new Rake.application.original_dir + cli.reset_jail + cli.reset_desk +end