coursemology-evaluator 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,14 +1,14 @@
1
- # frozen_string_literal: true
2
- # Adapter for StringIO for compatibility with RubyZip.
3
- #
4
- # StringIO does not inherit from IO, so RubyZip does not accept StringIO in place of IO.
5
- class Coursemology::Evaluator::StringIO < ::StringIO
6
- def is_a?(klass)
7
- klass == IO || super
8
- end
9
-
10
- # RubyZip assumes all IO objects respond to path.
11
- def path
12
- self
13
- end
14
- end
1
+ # frozen_string_literal: true
2
+ # Adapter for StringIO for compatibility with RubyZip.
3
+ #
4
+ # StringIO does not inherit from IO, so RubyZip does not accept StringIO in place of IO.
5
+ class Coursemology::Evaluator::StringIO < ::StringIO
6
+ def is_a?(klass)
7
+ klass == IO || super
8
+ end
9
+
10
+ # RubyZip assumes all IO objects respond to path.
11
+ def path
12
+ self
13
+ end
14
+ end
@@ -1,42 +1,42 @@
1
- # frozen_string_literal: true
2
- module Coursemology::Evaluator::Utils
3
- # Represents one block of the Docker Attach protocol.
4
- DockerAttachBlock = Struct.new(:stream, :length, :bytes)
5
-
6
- # Parses a Docker +attach+ protocol stream into its constituent protocols.
7
- #
8
- # See https://docs.docker.com/engine/reference/api/docker_remote_api_v1.19/#attach-to-a-container.
9
- #
10
- # This drops all blocks belonging to streams other than STDIN, STDOUT, or STDERR.
11
- #
12
- # @param [String] string The input stream to parse.
13
- # @return [Array<(String, String, String)>] The stdin, stdout, and stderr output.
14
- def self.parse_docker_stream(string)
15
- result = [''.dup, ''.dup, ''.dup]
16
- stream = StringIO.new(string)
17
-
18
- while (block = parse_docker_stream_read_block(stream))
19
- next if block.stream >= result.length
20
- result[block.stream] << block.bytes
21
- end
22
-
23
- stream.close
24
- result
25
- end
26
-
27
- # Reads a block from the given stream, and parses it according to the Docker +attach+ protocol.
28
- #
29
- # @param [IO] stream The stream to read.
30
- # @raise [IOError] If the stream is corrupt.
31
- # @return [DockerAttachBlock] If there is data in the stream.
32
- # @return [nil] If there is no data left in the stream.
33
- def self.parse_docker_stream_read_block(stream)
34
- header = stream.read(8)
35
- return nil if header.blank?
36
- fail IOError unless header.length == 8
37
-
38
- console_stream, _, _, _, length = header.unpack('C4N')
39
- DockerAttachBlock.new(console_stream, length, stream.read(length))
40
- end
41
- private_class_method :parse_docker_stream_read_block
42
- end
1
+ # frozen_string_literal: true
2
+ module Coursemology::Evaluator::Utils
3
+ # Represents one block of the Docker Attach protocol.
4
+ DockerAttachBlock = Struct.new(:stream, :length, :bytes)
5
+
6
+ # Parses a Docker +attach+ protocol stream into its constituent protocols.
7
+ #
8
+ # See https://docs.docker.com/engine/reference/api/docker_remote_api_v1.19/#attach-to-a-container.
9
+ #
10
+ # This drops all blocks belonging to streams other than STDIN, STDOUT, or STDERR.
11
+ #
12
+ # @param [String] string The input stream to parse.
13
+ # @return [Array<(String, String, String)>] The stdin, stdout, and stderr output.
14
+ def self.parse_docker_stream(string)
15
+ result = [''.dup, ''.dup, ''.dup]
16
+ stream = StringIO.new(string)
17
+
18
+ while (block = parse_docker_stream_read_block(stream))
19
+ next if block.stream >= result.length
20
+ result[block.stream] << block.bytes
21
+ end
22
+
23
+ stream.close
24
+ result
25
+ end
26
+
27
+ # Reads a block from the given stream, and parses it according to the Docker +attach+ protocol.
28
+ #
29
+ # @param [IO] stream The stream to read.
30
+ # @raise [IOError] If the stream is corrupt.
31
+ # @return [DockerAttachBlock] If there is data in the stream.
32
+ # @return [nil] If there is no data left in the stream.
33
+ def self.parse_docker_stream_read_block(stream)
34
+ header = stream.read(8)
35
+ return nil if header.blank?
36
+ fail IOError unless header.length == 8
37
+
38
+ console_stream, _, _, _, length = header.unpack('C4N')
39
+ DockerAttachBlock.new(console_stream, length, stream.read(length))
40
+ end
41
+ private_class_method :parse_docker_stream_read_block
42
+ end
@@ -1,5 +1,5 @@
1
- # frozen_string_literal: true
2
- module Coursemology; end
3
- module Coursemology::Evaluator
4
- VERSION = '0.1.6'.freeze
5
- end
1
+ # frozen_string_literal: true
2
+ module Coursemology; end
3
+ module Coursemology::Evaluator
4
+ VERSION = '0.1.7'.freeze
5
+ end
@@ -1,3 +1,3 @@
1
- # frozen_string_literal: true
2
- # This augments the base polyglot library with methods needed for the evaluator.
3
- Dir[File.join(__dir__, '**/*.rb')].each { |f| require f }
1
+ # frozen_string_literal: true
2
+ # This augments the base polyglot library with methods needed for the evaluator.
3
+ Dir[File.join(__dir__, '**/*.rb')].each { |f| require f }
@@ -1,24 +1,24 @@
1
- # frozen_string_literal: true
2
- class Coursemology::Polyglot::Language
3
- # Finds the language class with the specified name.
4
- #
5
- # @param [String] type The name of the class.
6
- # @return [nil] If the type is not defined.
7
- # @return [Class] If the type was found.
8
- def self.find_by(type:)
9
- class_ = concrete_languages.find { |language| language.name == type }
10
- class_.new if class_
11
- end
12
-
13
- # Finds the language class with the specified name.
14
- #
15
- # @param [String] type The name of the class.
16
- # @return [Class] If the type was found.
17
- # @raise [ArgumentError] When the type was not found.
18
- def self.find_by!(type:)
19
- language = find_by(type: type)
20
- fail ArgumentError, "Cannot find the language #{type}" unless language
21
-
22
- language
23
- end
24
- end
1
+ # frozen_string_literal: true
2
+ class Coursemology::Polyglot::Language
3
+ # Finds the language class with the specified name.
4
+ #
5
+ # @param [String] type The name of the class.
6
+ # @return [nil] If the type is not defined.
7
+ # @return [Class] If the type was found.
8
+ def self.find_by(type:)
9
+ class_ = concrete_languages.find { |language| language.name == type }
10
+ class_.new if class_
11
+ end
12
+
13
+ # Finds the language class with the specified name.
14
+ #
15
+ # @param [String] type The name of the class.
16
+ # @return [Class] If the type was found.
17
+ # @raise [ArgumentError] When the type was not found.
18
+ def self.find_by!(type:)
19
+ language = find_by(type: type)
20
+ fail ArgumentError, "Cannot find the language #{type}" unless language
21
+
22
+ language
23
+ end
24
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coursemology-evaluator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Low
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-12 00:00:00.000000000 Z
11
+ date: 2016-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -292,7 +292,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
292
292
  version: '0'
293
293
  requirements: []
294
294
  rubyforge_project:
295
- rubygems_version: 2.6.6
295
+ rubygems_version: 2.5.1
296
296
  signing_key:
297
297
  specification_version: 4
298
298
  summary: Coursemology programming package evaluator