Browse Source

Spec out SVN backend.

master
Ben Kurtovic 8 years ago
parent
commit
84ec0a1ddf
8 changed files with 59 additions and 9 deletions
  1. +1
    -0
      lib/kgrader.rb
  2. +4
    -0
      lib/kgrader/assignment.rb
  3. +1
    -0
      lib/kgrader/backend.rb
  4. +17
    -0
      lib/kgrader/backend/svn.rb
  5. +3
    -1
      lib/kgrader/course.rb
  6. +23
    -7
      lib/kgrader/task.rb
  7. +9
    -0
      lib/kgrader/util.rb
  8. +1
    -1
      spec/cs241h

+ 1
- 0
lib/kgrader.rb View File

@@ -1,4 +1,5 @@
require_relative 'kgrader/assignment'
require_relative 'kgrader/backend'
require_relative 'kgrader/cli'
require_relative 'kgrader/course'
require_relative 'kgrader/errors'


+ 4
- 0
lib/kgrader/assignment.rb View File

@@ -11,5 +11,9 @@ module KGrader
rescue FilesystemError
raise AssignmentError, "unknown assignment: #{name}"
end

def id
@config['id'] || @name
end
end
end

+ 1
- 0
lib/kgrader/backend.rb View File

@@ -0,0 +1 @@
require_relative 'backend/svn'

+ 17
- 0
lib/kgrader/backend/svn.rb View File

@@ -0,0 +1,17 @@
module KGrader::Backend
class SVN

def initialize(filesystem, config)
@fs = filesystem
@config = config
end

def fetch(semester, assignment, student)
url = @config['url'] % {
:semester => semester, :assignment => assignment, :student => student }

# TODO
puts "[fetching #{student}: #{url}]"
end
end
end

+ 3
- 1
lib/kgrader/course.rb View File

@@ -1,12 +1,14 @@
module KGrader
class Course
attr_reader :name
attr_reader :name, :backend

def initialize(filesystem, name)
@fs = filesystem
@name = name

@config = @fs.load @fs.course_config(@name)
type = @config['backend']
@backend = KGrader::backend(type).new self, @config[type]
@rosters = {}
@assignments = {}
rescue FilesystemError


+ 23
- 7
lib/kgrader/task.rb View File

@@ -19,11 +19,17 @@ module KGrader
regrade = options.fetch(:regrade, false)

# TODO
puts "Grading #{@course.name}:#{@semester} assignment #{@assignment.name}..."
puts "- students: #{students.inspect}"
puts "- due: #{due}"
puts "- fetch: #{fetch}"
puts "- regrade: #{regrade}"
puts "[grading]"
puts "course => #{@course.name}"
puts "semester => #{@semester}"
puts "assignment => #{@assignment.name}"
puts "students => #{students.join ', '}"
puts "due => #{due}"
puts "fetch => #{fetch}"
puts "regrade => #{regrade}"
puts

fetch_students students if fetch
end

def commit(options = {})
@@ -31,8 +37,18 @@ module KGrader
students &= options[:students] unless options[:students].nil?

# TODO
puts "Committing #{@course.name}:#{@semester} assignment #{@assignment.name}..."
puts "- students: #{students.inspect}"
puts "[committing]"
puts "course => #{@course.name}"
puts "semester => #{@semester}"
puts "assignment => #{@assignment.name}"
puts "students => #{students.join ', '}"
end

private
def fetch_students(students)
students.each do |student|
@course.backend.fetch @semester, @assignment.id, student
end
end
end
end

+ 9
- 0
lib/kgrader/util.rb View File

@@ -33,6 +33,15 @@ module KGrader
return args, options
end

def self.backend(type)
case type
when 'svn'
Backend::SVN
else
raise ConfigError, "unknown backend: #{type}"
end
end

def self.current_semester(format)
season = Time.now.strftime('%m').to_i <= 6 ? 'sp' : 'fa'
case format


+ 1
- 1
spec/cs241h

@@ -1 +1 @@
Subproject commit 3c6f5d050d8a66de6b3c36ce1985c225700a5c2f
Subproject commit 438e509e4c9097894f275dd66a5ae37bbcb62c24

Loading…
Cancel
Save