judge_system 1.7.3 → 1.7.4

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
- SHA1:
3
- metadata.gz: 66a5e610c3f04a03a3c5995f8f7f340c80d6aa6c
4
- data.tar.gz: 8725d6e567c79b14271dddaf3d71ea08ee1961f6
2
+ SHA256:
3
+ metadata.gz: deedcb6c209d6d4347977067d57a107056eb4cc5280cc14aec8cd18d265941af
4
+ data.tar.gz: f12a9381ca98d08279567bd8c62edea48f8c4dc9b1521bdd15a9d73d202d8a45
5
5
  SHA512:
6
- metadata.gz: f75e46f42cf3cb8d26fd82095c88b7f9acbd8aba2e437e78b33ce7c22749b8a45f6349b29d60312f40a556096e88579e50bced2acec1ef5d619fe80978b0a9d8
7
- data.tar.gz: 29258383872cd55bc5a4f5c1b8cfc40e3df33781e407a3676d82bb32e8e67a15bda25610afb8045e962f0d08f7a804c0fe5474d2be147a044c3e11615143746a
6
+ metadata.gz: a8ac21bfe06bea7d6c915396098c403fdbb30cb7805d15e5fdf5daa6a7f62f4ad0312f54d9d6574343ed1990b08d171d0b70fb1582a2edfd07050cd34b95fc37
7
+ data.tar.gz: bb85301eb0aacafb478b2423b56df0be6d38e72f749920ccf62611e17355810ade002ff4aa7b8fc9b269b6caaa6f94035358fa39accf28b009d7545787a39484
data/.gitignore CHANGED
@@ -7,4 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
- /lib/old_compile_systems/
10
+ /lib/old_compile_systems/
@@ -13,9 +13,6 @@ Style/Documentation:
13
13
  Style/FrozenStringLiteralComment:
14
14
  Enabled: false
15
15
 
16
- Metrics/BlockLength:
17
- Exclude:
18
-
19
16
  MethodLength:
20
17
  Max: 20
21
18
 
data/README.md CHANGED
@@ -1,11 +1,11 @@
1
- [![wercker status](https://app.wercker.com/status/0964573b38729ce98909559e3779cca5/m/master "wercker status")](https://app.wercker.com/project/byKey/0964573b38729ce98909559e3779cca5)
1
+ [![wercker status](https://app.wercker.com/status/0964573b38729ce98909559e3779cca5/m/master "wercker status")](https://app.wercker.com/project/byKey/0964573b38729ce98909559e3779cca5)
2
2
  # JudgeSystem
3
3
 
4
- Judge_system is a compile and judge system for online judge.
5
- This system work on [melpon/wandbox](https://github.com/melpon/wandbox).
6
- That means you don't have to concern about dangerous codes if you use judge_system.
7
- Judge_system returns four results ('AC', 'WA', 'RE', 'TLE').
8
- Now, it can compile c, c++, ruby, go, python3, swift, haskell.
4
+ Judge_system is a compile and judge system for online judge.
5
+ This system work on [melpon/wandbox](https://github.com/melpon/wandbox).
6
+ That means you don't have to concern about dangerous codes if you use judge_system.
7
+ Judge_system returns four results ('AC', 'WA', 'RE', 'TLE').
8
+ Now, it can compile c, c++, ruby, go, python3, swift.
9
9
 
10
10
  ## Installation
11
11
 
@@ -35,7 +35,7 @@ JudgeSystem.judge_result lang: (string text), code: (string text), answer: (stri
35
35
 
36
36
  ```
37
37
 
38
- example
38
+ example
39
39
 
40
40
  ```ruby
41
41
  require 'judge_system'
@@ -1,6 +1,4 @@
1
- # coding: utf-8
2
-
3
- lib = File.expand_path('../lib', __FILE__)
1
+ lib = File.expand_path('lib', __dir__)
4
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
3
  require 'judge_system/version'
6
4
 
@@ -28,10 +26,10 @@ Gem::Specification.new do |spec|
28
26
  spec.bindir = 'exe'
29
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
28
  spec.require_paths = ['lib']
31
- spec.add_dependency 'rbzip2'
32
29
  spec.add_dependency 'ffi'
33
- spec.add_development_dependency 'bundler', '~> 1.13'
34
- spec.add_development_dependency 'rake', '~> 10.0'
35
- spec.add_development_dependency 'rspec', '~> 3.0'
36
- spec.add_development_dependency 'rubocop', '~> 0.42.0'
30
+ spec.add_dependency 'rbzip2'
31
+ spec.add_development_dependency 'bundler', '~> 1.17.1'
32
+ spec.add_development_dependency 'rake', '~> 12.0'
33
+ spec.add_development_dependency 'rspec', '~> 3.4'
34
+ spec.add_development_dependency 'rubocop', '~> 0.60.0'
37
35
  end
@@ -22,20 +22,25 @@ module JudgeSystem
22
22
  end
23
23
 
24
24
  def self.run(lang, code, input, time)
25
- path = File.expand_path('../', __FILE__)
25
+ path = File.expand_path(__dir__)
26
26
  sys = File.open("#{path}/compile_systems/#{lang}_system.rb", 'r').read
27
- data = nil
28
27
  spliter = "\n<$><*><$>\n"
29
- stdin = BZip2Input.compress(code + spliter + input + spliter + format('%f', time))
28
+ stdin = BZip2Input.compress(code + spliter + input + spliter + format('%<time>f', time: time))
29
+
30
30
  begin
31
31
  data = compile(compiler: 'ruby-head', code: sys, stdin: stdin)
32
- rescue
32
+ rescue StandardError
33
33
  return 'RE'
34
34
  end
35
+
35
36
  error = data['program_error']
36
37
  result = data['program_output']
37
- return 'TLE' if error == "Killed\n"
38
- return 'RE' if result.nil? && error
38
+
39
+ if error == "Killed\n"
40
+ result = 'TLE'
41
+ elsif result.nil? && error
42
+ result = 'RE'
43
+ end
39
44
  result
40
45
  end
41
46
 
@@ -43,15 +48,17 @@ module JudgeSystem
43
48
 
44
49
  def self.judge(lang, code, answer, stdin, time)
45
50
  output = run(lang, code, stdin, time)
46
- return 'TLE' if output == 'TLE'
47
- return 'RE' if output == 'RE'
48
- output == answer ? 'AC' : 'WA'
51
+ if %w[TLE RE].include?(output)
52
+ output
53
+ else
54
+ output == answer ? 'AC' : 'WA'
55
+ end
49
56
  end
50
57
  end
51
58
 
59
+ module_function
60
+
52
61
  def judge_result(lang: '', code: '', answer: '', stdin: '', time: 20)
53
62
  WandBox.judge(lang, code, answer, stdin, time)
54
63
  end
55
-
56
- module_function :judge_result
57
64
  end
@@ -1,3 +1,3 @@
1
1
  module JudgeSystem
2
- VERSION = '1.7.3'.freeze
2
+ VERSION = '1.7.4'.freeze
3
3
  end
@@ -1,6 +1,8 @@
1
1
  require 'rbzip2'
2
2
  require 'base64'
3
3
  module BZip2Input
4
+ module_function
5
+
4
6
  def compress(input)
5
7
  string = StringIO.new
6
8
  bz2 = RBzip2::FFI::Compressor.new string
@@ -8,5 +10,4 @@ module BZip2Input
8
10
  bz2.close
9
11
  Base64.encode64(string.string)
10
12
  end
11
- module_function :compress
12
13
  end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: judge_system
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.3
4
+ version: 1.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - getty104
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-18 00:00:00.000000000 Z
11
+ date: 2018-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rbzip2
14
+ name: ffi
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: ffi
28
+ name: rbzip2
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -44,56 +44,56 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '1.13'
47
+ version: 1.17.1
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '1.13'
54
+ version: 1.17.1
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '10.0'
61
+ version: '12.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '10.0'
68
+ version: '12.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '3.0'
75
+ version: '3.4'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '3.0'
82
+ version: '3.4'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rubocop
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.42.0
89
+ version: 0.60.0
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.42.0
96
+ version: 0.60.0
97
97
  description: "This is a judge system for online judge. \nThis gem work on the wandbox
98
98
  api."
99
99
  email:
@@ -117,7 +117,6 @@ files:
117
117
  - lib/compile_systems/c_system.rb
118
118
  - lib/compile_systems/cpp_system.rb
119
119
  - lib/compile_systems/go_system.rb
120
- - lib/compile_systems/hs_system.rb
121
120
  - lib/compile_systems/py_system.rb
122
121
  - lib/compile_systems/rb_system.rb
123
122
  - lib/compile_systems/swift_system.rb
@@ -145,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
144
  version: '0'
146
145
  requirements: []
147
146
  rubyforge_project:
148
- rubygems_version: 2.6.11
147
+ rubygems_version: 2.7.6
149
148
  signing_key:
150
149
  specification_version: 4
151
150
  summary: This is a judge system for online judge
@@ -1,25 +0,0 @@
1
- require 'base64'
2
-
3
- File.open('stdin.txt.bz2', 'wb') do |file|
4
- file.write Base64.decode64 $stdin.read
5
- file.close
6
- end
7
-
8
- system('bunzip2 stdin.txt.bz2')
9
-
10
- stdin = File.open('stdin.txt').read.split("\n<$><*><$>\n")
11
- code = stdin[0]
12
- input = stdin[1]
13
- time = stdin[2]
14
-
15
- File.open('./main.hs', 'w') do |file|
16
- file.puts code
17
- file.close
18
- end
19
-
20
- File.open('./test.in', 'w') do |file|
21
- file.puts input
22
- file.close
23
- end
24
-
25
- system('timeout -s 9 ' + time + ' /opt/wandbox/ghc-head/bin/runghc main.hs < test.in')