Skip to content
This repository was archived by the owner on Jul 22, 2022. It is now read-only.

Commit 2105104

Browse files
committed
Add Ruby support
1 parent d7de089 commit 2105104

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
- [Python](https://www.python.org/)
3535
- [CPython](https://www.python.org/downloads/)
3636
- [PyPy](https://www.pypy.org/)
37-
37+
- [Ruby](https://www.ruby-lang.org/en/)
38+
- [`ruby`](https://www.ruby-lang.org/en/downloads/)
3839

3940
## Installation
4041
### From the [Python Package Index (PyPI)](https://pypi.org/)
@@ -296,6 +297,14 @@ sudo make install # python3 setup.py install
296297
],
297298
b'No syntax errors detected in index.php\n'
298299
]
300+
>>>
301+
>>> judge(Ruby(), b'print "Hello, world!";', [(b'', b'Hello, world!')]) # Ruby
302+
[
303+
[
304+
(<Status.AC: 'Accepted'>, (b'Hello, world!', b''), 0.05)
305+
],
306+
b'Syntax OK\n'
307+
]
299308
```
300309

301310

README.zh_Hans_CN.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
- [Python](https://www.python.org/)
3535
- [CPython](https://www.python.org/downloads/)
3636
- [PyPy](https://www.pypy.org/)
37+
- [Ruby](https://www.ruby-lang.org/zh_cn/)
38+
- [`ruby`](https://www.ruby-lang.org/zh_cn/downloads/)
3739

3840

3941
## 安装
@@ -296,6 +298,14 @@ sudo make install # python3 setup.py install
296298
],
297299
b'No syntax errors detected in index.php\n'
298300
]
301+
>>>
302+
>>> judge(Ruby(), b'print "Hello, world!";', [(b'', b'Hello, world!')]) # Ruby
303+
[
304+
[
305+
(<Status.AC: 'Accepted'>, (b'Hello, world!', b''), 0.05)
306+
],
307+
b'Syntax OK\n'
308+
]
299309
```
300310

301311

dockerjudge/processor.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,13 @@ def __init__(self, version=None):
182182
self.source = '__init__.py'
183183
self.compile = ['python', '-m', 'compileall', '.']
184184
self.judge = f'python {self.source}'
185+
186+
187+
class Ruby(Processor):
188+
'Ruby'
189+
190+
def __init__(self, version=None):
191+
self.image = self._get_image_with_tag('ruby', version)
192+
self.source = 'ruby.rb'
193+
self.compile = ['ruby', '-wc', self.source]
194+
self.judge = f'ruby {self.source}'

test_dockerjudge.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from dockerjudge import judge
88
from dockerjudge.processor import (Bash, Clang, GCC, Go, Node, OpenJDK,
9-
PHP, PyPy, Python)
9+
PHP, PyPy, Python, Ruby)
1010
from dockerjudge.status import Status
1111

1212

@@ -386,5 +386,16 @@ def test_php(self):
386386
self.assertEqual(result[0][0][0], Status.AC)
387387

388388

389+
class TestRuby(unittest.TestCase):
390+
391+
def test_ruby(self):
392+
result = judge(
393+
Ruby(),
394+
b'print "Hello, world!";',
395+
[(b'', b'Hello, world!')]
396+
)
397+
self.assertEqual(result[0][0][0], Status.AC)
398+
399+
389400
if __name__ == '__main__':
390401
unittest.main()

0 commit comments

Comments
 (0)