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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c15735be1e373f3a239bca938b6c01aa5e7fb023
4
- data.tar.gz: 3ee561981631575f8db2667388c76584ed5edef4
3
+ metadata.gz: a5e09460f877c47644d23150a3c3479d03fea45b
4
+ data.tar.gz: 5e2424eb3262f1c2be86470dfc861ae115244665
5
5
  SHA512:
6
- metadata.gz: 553aa70b1faf82eba5004510d5550d891d200f045b1a5877d778db45be791f0cb0c20372c809fec1c353fb97dfe07d61dff6fe204689bb48161d544af87a9145
7
- data.tar.gz: 6e8900f7ccc3ff3c33c0b45aaaa3241c32c099c46baef4ed64aa12a7439293a3ec14bb75e950c75652f7ff9dc97edd689a217e55513d969b18f673f86807f08f
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
 
@@ -42,6 +42,8 @@ module OJS
42
42
  OJS::AOJ.submit @config
43
43
  when 'poj'
44
44
  OJS::POJ.submit @config
45
+ when 'spoj'
46
+ OJS::SPOJ.submit @config
45
47
  else
46
48
  list
47
49
  end
@@ -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
@@ -8,7 +8,7 @@ module OJS
8
8
 
9
9
  class << self
10
10
  def valid_judges
11
- %w[AOJ POJ]
11
+ %w[AOJ POJ SPOJ]
12
12
  end
13
13
 
14
14
  def login
@@ -1,3 +1,3 @@
1
1
  module OJS
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/ojsubmitter.rb CHANGED
@@ -3,6 +3,7 @@ require "ojsubmitter/logger"
3
3
  require "ojsubmitter/util"
4
4
  require 'ojsubmitter/judge/aoj'
5
5
  require 'ojsubmitter/judge/poj'
6
+ require 'ojsubmitter/judge/spoj'
6
7
 
7
8
  module OJS
8
9
  ROOT_DIR = File.expand_path(File.join(__FILE__, '..', '..'))
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.2.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