ojsubmitter 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/ojsubmitter/cli.rb +2 -0
- data/lib/ojsubmitter/judge/spoj.rb +99 -0
- data/lib/ojsubmitter/judge.rb +1 -1
- data/lib/ojsubmitter/version.rb +1 -1
- data/lib/ojsubmitter.rb +1 -0
- data/ojsubmitter.gemspec +1 -0
- metadata +16 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5e09460f877c47644d23150a3c3479d03fea45b
|
4
|
+
data.tar.gz: 5e2424eb3262f1c2be86470dfc861ae115244665
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5de9ad732e98acb2310b945d0d4315ec6c995669bc752a0745560c56411aae8f0bc08846db46d294d5477f87d6b037c7253255c8455faae984272e7a05681619
|
7
|
+
data.tar.gz: 5ee1531964bbd18240024d6b2bfa0312d7294844afd7a2f09ae79af862b47ce10c759fd8ef030f595f4754d83d7068053c890908fe52871d620bd28db2bb1de2
|
data/README.md
CHANGED
@@ -11,6 +11,7 @@ Submit a source code to the online judge from CLI.
|
|
11
11
|
### Enabled Judges
|
12
12
|
- [AIZU ONLINE JUDGE](http://judge.u-aizu.ac.jp)
|
13
13
|
- [PKU JudgeOnline](http://poj.org)
|
14
|
+
- [Sphere online judge](http://www.spoj.com)
|
14
15
|
|
15
16
|
You can also get this list from `ojsubmitter list` command.
|
16
17
|
|
data/lib/ojsubmitter/cli.rb
CHANGED
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'ojsubmitter/judge'
|
2
|
+
|
3
|
+
module OJS
|
4
|
+
class SPOJ < Judge
|
5
|
+
class << self
|
6
|
+
LANGUAGE_ID = {
|
7
|
+
'ada' => '7',
|
8
|
+
'assembler' => '13', # nasm
|
9
|
+
# 'Assembler' => '45', # Assembler GC g++
|
10
|
+
'awk' => '104',
|
11
|
+
'bash' => '28',
|
12
|
+
'brainf**k' => '12',
|
13
|
+
'c' => '11',
|
14
|
+
'c#' => '27',
|
15
|
+
'c++' => '1',
|
16
|
+
# 'C++' => '41', # g++ 4.3.2
|
17
|
+
'c++14' => '44',
|
18
|
+
'c99' => '34',
|
19
|
+
'clips' => '14',
|
20
|
+
'clojure' => '111',
|
21
|
+
'cobol' => '118',
|
22
|
+
'commonlisp' => '32', # clisp
|
23
|
+
# 'CommonLisp' => '31', # sbcl
|
24
|
+
'd' => '20',
|
25
|
+
'erlang' => '36',
|
26
|
+
'f#' => '124',
|
27
|
+
'fortran' => '5',
|
28
|
+
'go' => '114',
|
29
|
+
'groovy' => '121',
|
30
|
+
'haskell' => '21',
|
31
|
+
'icon' => '16',
|
32
|
+
'intercal' => '9',
|
33
|
+
'jar' => '24',
|
34
|
+
'java' => '10',
|
35
|
+
'javascript' => '112',
|
36
|
+
'lua' => '26',
|
37
|
+
'nemerle' => '30',
|
38
|
+
'nice' => '25',
|
39
|
+
'ocaml' => '8',
|
40
|
+
'pascal' => '22',
|
41
|
+
'perl' => '3',
|
42
|
+
'php' => '29',
|
43
|
+
'pike' => '19',
|
44
|
+
'prolog' => '15',
|
45
|
+
'python' => '4',
|
46
|
+
# 'Python' => '99' # PyPy
|
47
|
+
'python3' => '98',
|
48
|
+
# 'Python3' => '116', # python 3.2.3
|
49
|
+
# 'Python3' => '126', # python 3.2.3 nbc
|
50
|
+
'ruby' => '17',
|
51
|
+
'scala' => '39',
|
52
|
+
'scheme' => '33', # guile
|
53
|
+
# 'Scheme' => '18', # stalin
|
54
|
+
'sed' => '46',
|
55
|
+
'smalltalk' => '23',
|
56
|
+
'tcl' => '38',
|
57
|
+
'tecs' => '42',
|
58
|
+
'text' => '62',
|
59
|
+
'vb.net' => '50',
|
60
|
+
'whitespace' => '6'
|
61
|
+
}
|
62
|
+
|
63
|
+
def login
|
64
|
+
res = hclient.post(
|
65
|
+
'http://www.spoj.com/login/',
|
66
|
+
{ :login_user => user,
|
67
|
+
:password => password }
|
68
|
+
)
|
69
|
+
raise Judge::LoginFailedError if res.body =~ /Authentication failed!/
|
70
|
+
Logger.info "Logged in successfully."
|
71
|
+
end
|
72
|
+
|
73
|
+
def post
|
74
|
+
res = hclient.post(
|
75
|
+
'http://www.spoj.com/submit/complete/',
|
76
|
+
{ :problemcode => problem_id,
|
77
|
+
:lang => language,
|
78
|
+
:file => code }
|
79
|
+
)
|
80
|
+
raise Judge::SubmissionError if res.body =~ /Error/
|
81
|
+
end
|
82
|
+
|
83
|
+
def status_url
|
84
|
+
"http://www.spoj.com/status/#{user}"
|
85
|
+
end
|
86
|
+
|
87
|
+
def language
|
88
|
+
LANGUAGE_ID[@config['language'].to_s.downcase]
|
89
|
+
end
|
90
|
+
|
91
|
+
def problem_id
|
92
|
+
unless @config['problem_id']
|
93
|
+
@config['problem_id'] = File.basename(file).split('.')[0]
|
94
|
+
end
|
95
|
+
@config['problem_id'].upcase
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
data/lib/ojsubmitter/judge.rb
CHANGED
data/lib/ojsubmitter/version.rb
CHANGED
data/lib/ojsubmitter.rb
CHANGED
data/ojsubmitter.gemspec
CHANGED
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "rspec", "~> 3.0"
|
24
24
|
spec.add_development_dependency "simplecov", "~> 0.11.0"
|
25
25
|
spec.add_development_dependency "coveralls", "~> 0.8.0"
|
26
|
+
spec.add_development_dependency "fakefs", "~> 0.8.0"
|
26
27
|
|
27
28
|
spec.add_dependency 'httpclient', '~> 2.7.0'
|
28
29
|
spec.add_dependency 'thor', '~> 0.19.0'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ojsubmitter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hadrori
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.8.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: fakefs
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.8.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.8.0
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: httpclient
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -133,6 +147,7 @@ files:
|
|
133
147
|
- lib/ojsubmitter/judge.rb
|
134
148
|
- lib/ojsubmitter/judge/aoj.rb
|
135
149
|
- lib/ojsubmitter/judge/poj.rb
|
150
|
+
- lib/ojsubmitter/judge/spoj.rb
|
136
151
|
- lib/ojsubmitter/logger.rb
|
137
152
|
- lib/ojsubmitter/util.rb
|
138
153
|
- lib/ojsubmitter/version.rb
|