Skip to content
This repository was archived by the owner on Sep 25, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/coursemology/evaluator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module Coursemology::Evaluator
autoload :Logging
autoload :Models
autoload :Services
autoload :StringIO

# The logger to use for the client.
mattr_reader(:logger) { ActiveSupport::Logger.new(STDOUT) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def language=(language)
def package
@package ||= begin
body = plain_request('courses/assessment/programming_evaluations/:id/package', id: id)
Package.new(StringIO.new(body))
Package.new(Coursemology::Evaluator::StringIO.new(body))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering why you are using StringIO for the package ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I want a consistent API for Packages. Eventually I want to pass a stream in, see #10. Since I get an entire buffer at once now, the best is to use a StringIO.

Then there's the reason of why I need the custom StringIO -- that's because StringIO does not inherit from IO, rightly or wrongly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yah, I noticed that custom StringIO, but not sure RubyZip completely works with that. that' why I'm asking.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't, it's a hack...

And Rubyzip is so nasty I'm not sure I want to PR to fix it there... it's probably because it's a port from Java.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol, let's see how it goes.

end
end

Expand Down
13 changes: 13 additions & 0 deletions lib/coursemology/evaluator/string_io.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Adapter for StringIO for compatibility with RubyZip.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use snake_case for source file names.

#
# StringIO does not inherit from IO, so RubyZip does not accept StringIO in place of IO.
class Coursemology::Evaluator::StringIO < ::StringIO
def is_a?(klass)
klass == IO || super
end

# RubyZip assumes all IO objects respond to path.
def path
self
end
end
6 changes: 6 additions & 0 deletions spec/coursemology/evaluator/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
subject
end
end

it 'evaluates the package' do
VCR.use_cassette('client/pending_evaluation') do
subject
end
end
end
end

Expand Down
165 changes: 165 additions & 0 deletions spec/fixtures/vcr/cassettes/client/pending_evaluation.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.