judge_system 1.7.2 → 1.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +28 -0
- data/README.md +1 -1
- data/Rakefile +3 -3
- data/bin/console +3 -3
- data/judge_system.gemspec +18 -16
- data/lib/compile_systems/c_system.rb +13 -13
- data/lib/compile_systems/cpp_system.rb +13 -13
- data/lib/compile_systems/go_system.rb +12 -12
- data/lib/compile_systems/hs_system.rb +12 -12
- data/lib/compile_systems/py_system.rb +12 -12
- data/lib/compile_systems/rb_system.rb +12 -12
- data/lib/compile_systems/swift_system.rb +13 -13
- data/lib/judge_system.rb +49 -66
- data/lib/judge_system/version.rb +1 -1
- data/lib/zlib_input.rb +9 -9
- data/wercker.yml +6 -0
- metadata +17 -3
- data/.ruby-version +0 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 66a5e610c3f04a03a3c5995f8f7f340c80d6aa6c
         | 
| 4 | 
            +
              data.tar.gz: 8725d6e567c79b14271dddaf3d71ea08ee1961f6
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: f75e46f42cf3cb8d26fd82095c88b7f9acbd8aba2e437e78b33ce7c22749b8a45f6349b29d60312f40a556096e88579e50bced2acec1ef5d619fe80978b0a9d8
         | 
| 7 | 
            +
              data.tar.gz: 29258383872cd55bc5a4f5c1b8cfc40e3df33781e407a3676d82bb32e8e67a15bda25610afb8045e962f0d08f7a804c0fe5474d2be147a044c3e11615143746a
         | 
    
        data/.rubocop.yml
    ADDED
    
    | @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            AllCops:
         | 
| 2 | 
            +
              Exclude:
         | 
| 3 | 
            +
                - 'spec/*.rb'
         | 
| 4 | 
            +
            AsciiComments:
         | 
| 5 | 
            +
              Enabled: false
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Style/ClassAndModuleChildren:
         | 
| 8 | 
            +
              Enabled: false
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            Style/Documentation:
         | 
| 11 | 
            +
              Enabled: false
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            Style/FrozenStringLiteralComment:
         | 
| 14 | 
            +
              Enabled: false
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            Metrics/BlockLength:
         | 
| 17 | 
            +
              Exclude:
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            MethodLength:
         | 
| 20 | 
            +
              Max: 20
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            Metrics/LineLength:
         | 
| 23 | 
            +
              Max: 120
         | 
| 24 | 
            +
              Exclude:
         | 
| 25 | 
            +
                - 'lib/compile_systems/*.rb'
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            Metrics/AbcSize:
         | 
| 28 | 
            +
              Max: 20
         | 
    
        data/README.md
    CHANGED
    
    | @@ -58,7 +58,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To | |
| 58 58 |  | 
| 59 59 | 
             
            ## Contributing
         | 
| 60 60 |  | 
| 61 | 
            -
            Bug reports and pull requests are welcome on GitHub at https://github.com/ | 
| 61 | 
            +
            Bug reports and pull requests are welcome on GitHub at https://github.com/getty104/judge_system. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
         | 
| 62 62 |  | 
| 63 63 |  | 
| 64 64 | 
             
            ## License
         | 
    
        data/Rakefile
    CHANGED
    
    
    
        data/bin/console
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            #!/usr/bin/env ruby
         | 
| 2 2 |  | 
| 3 | 
            -
            require  | 
| 4 | 
            -
            require  | 
| 3 | 
            +
            require 'bundler/setup'
         | 
| 4 | 
            +
            require 'judge_system'
         | 
| 5 5 |  | 
| 6 6 | 
             
            # You can add fixtures and/or initialization code here to make experimenting
         | 
| 7 7 | 
             
            # with your gem easier. You can also use a different console, if you like.
         | 
| @@ -10,5 +10,5 @@ require "judge_system" | |
| 10 10 | 
             
            # require "pry"
         | 
| 11 11 | 
             
            # Pry.start
         | 
| 12 12 |  | 
| 13 | 
            -
            require  | 
| 13 | 
            +
            require 'irb'
         | 
| 14 14 | 
             
            IRB.start
         | 
    
        data/judge_system.gemspec
    CHANGED
    
    | @@ -1,35 +1,37 @@ | |
| 1 1 | 
             
            # coding: utf-8
         | 
| 2 | 
            +
             | 
| 2 3 | 
             
            lib = File.expand_path('../lib', __FILE__)
         | 
| 3 4 | 
             
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 5 | 
             
            require 'judge_system/version'
         | 
| 5 6 |  | 
| 6 7 | 
             
            Gem::Specification.new do |spec|
         | 
| 7 | 
            -
              spec.name          =  | 
| 8 | 
            +
              spec.name          = 'judge_system'
         | 
| 8 9 | 
             
              spec.version       = JudgeSystem::VERSION
         | 
| 9 | 
            -
              spec.authors       = [ | 
| 10 | 
            -
              spec.email         = [ | 
| 10 | 
            +
              spec.authors       = ['getty104']
         | 
| 11 | 
            +
              spec.email         = ['hayabusatoshihumi@gmail.com']
         | 
| 11 12 |  | 
| 12 | 
            -
              spec.summary       =  | 
| 13 | 
            +
              spec.summary       = 'This is a judge system for online judge '
         | 
| 13 14 | 
             
              spec.description   = "This is a judge system for online judge. \nThis gem work on the wandbox api."
         | 
| 14 | 
            -
              spec.homepage      =  | 
| 15 | 
            -
              spec.license       =  | 
| 15 | 
            +
              spec.homepage      = 'https://github.com/getty104/judge_system'
         | 
| 16 | 
            +
              spec.license       = 'MIT'
         | 
| 16 17 |  | 
| 17 18 | 
             
              # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
         | 
| 18 19 | 
             
              # to allow pushing to a single host or delete this section to allow pushing to any host.
         | 
| 19 | 
            -
             | 
| 20 | 
            +
              # if spec.respond_to?(:metadata)
         | 
| 20 21 | 
             
              #  spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
         | 
| 21 22 | 
             
              # raise "RubyGems 2.0 or newer is required to protect against " \
         | 
| 22 | 
            -
             | 
| 23 | 
            -
              #end
         | 
| 23 | 
            +
              # {}"public gem pushes."
         | 
| 24 | 
            +
              # end
         | 
| 24 25 | 
             
              spec.files         = `git ls-files -z`.split("\x0").reject do |f|
         | 
| 25 26 | 
             
                f.match(%r{^(test|spec|features)/})
         | 
| 26 27 | 
             
              end
         | 
| 27 | 
            -
              spec.bindir        =  | 
| 28 | 
            +
              spec.bindir        = 'exe'
         | 
| 28 29 | 
             
              spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
         | 
| 29 | 
            -
              spec.require_paths = [ | 
| 30 | 
            -
              spec.add_dependency  | 
| 31 | 
            -
              spec.add_dependency  | 
| 32 | 
            -
              spec.add_development_dependency  | 
| 33 | 
            -
              spec.add_development_dependency  | 
| 34 | 
            -
              spec.add_development_dependency  | 
| 30 | 
            +
              spec.require_paths = ['lib']
         | 
| 31 | 
            +
              spec.add_dependency 'rbzip2'
         | 
| 32 | 
            +
              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'
         | 
| 35 37 | 
             
            end
         | 
| @@ -1,26 +1,26 @@ | |
| 1 1 | 
             
            require 'base64'
         | 
| 2 2 |  | 
| 3 | 
            -
            File.open( | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 3 | 
            +
            File.open('stdin.txt.bz2', 'wb') do |file|
         | 
| 4 | 
            +
              file.write Base64.decode64 $stdin.read
         | 
| 5 | 
            +
              file.close
         | 
| 6 6 | 
             
            end
         | 
| 7 7 |  | 
| 8 | 
            -
            system( | 
| 8 | 
            +
            system('bunzip2 stdin.txt.bz2')
         | 
| 9 9 |  | 
| 10 | 
            -
            stdin = File.open( | 
| 10 | 
            +
            stdin = File.open('stdin.txt').read.split("\n<$><*><$>\n")
         | 
| 11 11 | 
             
            code = stdin[0]
         | 
| 12 12 | 
             
            input = stdin[1]
         | 
| 13 13 | 
             
            time = stdin[2]
         | 
| 14 14 |  | 
| 15 | 
            -
            File.open( | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 15 | 
            +
            File.open('./main.c', 'w') do |file|
         | 
| 16 | 
            +
              file.puts code
         | 
| 17 | 
            +
              file.close
         | 
| 18 18 | 
             
            end
         | 
| 19 19 |  | 
| 20 | 
            -
            File.open( | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 20 | 
            +
            File.open('./test.in', 'w') do |file|
         | 
| 21 | 
            +
              file.puts input
         | 
| 22 | 
            +
              file.close
         | 
| 23 23 | 
             
            end
         | 
| 24 24 |  | 
| 25 | 
            -
            system | 
| 26 | 
            -
            system | 
| 25 | 
            +
            system('/opt/wandbox/gcc-head/bin/gcc main.c -o main -O2')
         | 
| 26 | 
            +
            system('timeout -s 9 ' + time + ' ./main < test.in')
         | 
| @@ -1,26 +1,26 @@ | |
| 1 1 | 
             
            require 'base64'
         | 
| 2 2 |  | 
| 3 | 
            -
            File.open( | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 3 | 
            +
            File.open('stdin.txt.bz2', 'wb') do |file|
         | 
| 4 | 
            +
              file.write Base64.decode64 $stdin.read
         | 
| 5 | 
            +
              file.close
         | 
| 6 6 | 
             
            end
         | 
| 7 7 |  | 
| 8 | 
            -
            system( | 
| 8 | 
            +
            system('bunzip2 stdin.txt.bz2')
         | 
| 9 9 |  | 
| 10 | 
            -
            stdin = File.open( | 
| 10 | 
            +
            stdin = File.open('stdin.txt').read.split("\n<$><*><$>\n")
         | 
| 11 11 | 
             
            code = stdin[0]
         | 
| 12 12 | 
             
            input = stdin[1]
         | 
| 13 13 | 
             
            time = stdin[2]
         | 
| 14 14 |  | 
| 15 | 
            -
            File.open( | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 15 | 
            +
            File.open('./main.cpp', 'w') do |file|
         | 
| 16 | 
            +
              file.puts code
         | 
| 17 | 
            +
              file.close
         | 
| 18 18 | 
             
            end
         | 
| 19 19 |  | 
| 20 | 
            -
            File.open( | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 20 | 
            +
            File.open('./test.in', 'w') do |file|
         | 
| 21 | 
            +
              file.puts input
         | 
| 22 | 
            +
              file.close
         | 
| 23 23 | 
             
            end
         | 
| 24 24 |  | 
| 25 | 
            -
            system | 
| 26 | 
            -
            system | 
| 25 | 
            +
            system('/opt/wandbox/gcc-head/bin/g++ main.cpp -o main -O2')
         | 
| 26 | 
            +
            system('timeout -s 9 ' + time + ' ./main < test.in')
         | 
| @@ -1,25 +1,25 @@ | |
| 1 1 | 
             
            require 'base64'
         | 
| 2 2 |  | 
| 3 | 
            -
            File.open( | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 3 | 
            +
            File.open('stdin.txt.bz2', 'wb') do |file|
         | 
| 4 | 
            +
              file.write Base64.decode64 $stdin.read
         | 
| 5 | 
            +
              file.close
         | 
| 6 6 | 
             
            end
         | 
| 7 7 |  | 
| 8 | 
            -
            system( | 
| 8 | 
            +
            system('bunzip2 stdin.txt.bz2')
         | 
| 9 9 |  | 
| 10 | 
            -
            stdin = File.open( | 
| 10 | 
            +
            stdin = File.open('stdin.txt').read.split("\n<$><*><$>\n")
         | 
| 11 11 | 
             
            code = stdin[0]
         | 
| 12 12 | 
             
            input = stdin[1]
         | 
| 13 13 | 
             
            time = stdin[2]
         | 
| 14 14 |  | 
| 15 | 
            -
            File.open( | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 15 | 
            +
            File.open('./main.go', 'w') do |file|
         | 
| 16 | 
            +
              file.puts code
         | 
| 17 | 
            +
              file.close
         | 
| 18 18 | 
             
            end
         | 
| 19 19 |  | 
| 20 | 
            -
            File.open( | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 20 | 
            +
            File.open('./test.in', 'w') do |file|
         | 
| 21 | 
            +
              file.puts input
         | 
| 22 | 
            +
              file.close
         | 
| 23 23 | 
             
            end
         | 
| 24 24 |  | 
| 25 | 
            -
            system | 
| 25 | 
            +
            system('timeout -s 9 ' + time + ' /opt/wandbox/go-head/bin/go run main.go < test.in')
         | 
| @@ -1,25 +1,25 @@ | |
| 1 1 | 
             
            require 'base64'
         | 
| 2 2 |  | 
| 3 | 
            -
            File.open( | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 3 | 
            +
            File.open('stdin.txt.bz2', 'wb') do |file|
         | 
| 4 | 
            +
              file.write Base64.decode64 $stdin.read
         | 
| 5 | 
            +
              file.close
         | 
| 6 6 | 
             
            end
         | 
| 7 7 |  | 
| 8 | 
            -
            system( | 
| 8 | 
            +
            system('bunzip2 stdin.txt.bz2')
         | 
| 9 9 |  | 
| 10 | 
            -
            stdin = File.open( | 
| 10 | 
            +
            stdin = File.open('stdin.txt').read.split("\n<$><*><$>\n")
         | 
| 11 11 | 
             
            code = stdin[0]
         | 
| 12 12 | 
             
            input = stdin[1]
         | 
| 13 13 | 
             
            time = stdin[2]
         | 
| 14 14 |  | 
| 15 | 
            -
            File.open( | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 15 | 
            +
            File.open('./main.hs', 'w') do |file|
         | 
| 16 | 
            +
              file.puts code
         | 
| 17 | 
            +
              file.close
         | 
| 18 18 | 
             
            end
         | 
| 19 19 |  | 
| 20 | 
            -
            File.open( | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 20 | 
            +
            File.open('./test.in', 'w') do |file|
         | 
| 21 | 
            +
              file.puts input
         | 
| 22 | 
            +
              file.close
         | 
| 23 23 | 
             
            end
         | 
| 24 24 |  | 
| 25 | 
            -
            system | 
| 25 | 
            +
            system('timeout -s 9 ' + time + ' /opt/wandbox/ghc-head/bin/runghc main.hs < test.in')
         | 
| @@ -1,25 +1,25 @@ | |
| 1 1 | 
             
            require 'base64'
         | 
| 2 2 |  | 
| 3 | 
            -
            File.open( | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 3 | 
            +
            File.open('stdin.txt.bz2', 'wb') do |file|
         | 
| 4 | 
            +
              file.write Base64.decode64 $stdin.read
         | 
| 5 | 
            +
              file.close
         | 
| 6 6 | 
             
            end
         | 
| 7 7 |  | 
| 8 | 
            -
            system( | 
| 8 | 
            +
            system('bunzip2 stdin.txt.bz2')
         | 
| 9 9 |  | 
| 10 | 
            -
            stdin = File.open( | 
| 10 | 
            +
            stdin = File.open('stdin.txt').read.split("\n<$><*><$>\n")
         | 
| 11 11 | 
             
            code = stdin[0]
         | 
| 12 12 | 
             
            input = stdin[1]
         | 
| 13 13 | 
             
            time = stdin[2]
         | 
| 14 14 |  | 
| 15 | 
            -
            File.open( | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 15 | 
            +
            File.open('./main.py', 'w') do |file|
         | 
| 16 | 
            +
              file.puts code
         | 
| 17 | 
            +
              file.close
         | 
| 18 18 | 
             
            end
         | 
| 19 19 |  | 
| 20 | 
            -
            File.open( | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 20 | 
            +
            File.open('./test.in', 'w') do |file|
         | 
| 21 | 
            +
              file.puts input
         | 
| 22 | 
            +
              file.close
         | 
| 23 23 | 
             
            end
         | 
| 24 24 |  | 
| 25 | 
            -
            system | 
| 25 | 
            +
            system('timeout -s 9 ' + time + ' /opt/wandbox/cpython-head/bin/python3 main.py < test.in')
         | 
| @@ -1,25 +1,25 @@ | |
| 1 1 | 
             
            require 'base64'
         | 
| 2 2 |  | 
| 3 | 
            -
            File.open( | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 3 | 
            +
            File.open('stdin.txt.bz2', 'wb') do |file|
         | 
| 4 | 
            +
              file.write Base64.decode64 $stdin.read
         | 
| 5 | 
            +
              file.close
         | 
| 6 6 | 
             
            end
         | 
| 7 7 |  | 
| 8 | 
            -
            system( | 
| 8 | 
            +
            system('bunzip2 stdin.txt.bz2')
         | 
| 9 9 |  | 
| 10 | 
            -
            stdin = File.open( | 
| 10 | 
            +
            stdin = File.open('stdin.txt').read.split("\n<$><*><$>\n")
         | 
| 11 11 | 
             
            code = stdin[0]
         | 
| 12 12 | 
             
            input = stdin[1]
         | 
| 13 13 | 
             
            time = stdin[2]
         | 
| 14 14 |  | 
| 15 | 
            -
            File.open( | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 15 | 
            +
            File.open('./main.rb', 'w') do |file|
         | 
| 16 | 
            +
              file.puts code
         | 
| 17 | 
            +
              file.close
         | 
| 18 18 | 
             
            end
         | 
| 19 19 |  | 
| 20 | 
            -
            File.open( | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 20 | 
            +
            File.open('./test.in', 'w') do |file|
         | 
| 21 | 
            +
              file.puts input
         | 
| 22 | 
            +
              file.close
         | 
| 23 23 | 
             
            end
         | 
| 24 24 |  | 
| 25 | 
            -
            system | 
| 25 | 
            +
            system('timeout -s 9 ' + time + ' /opt/wandbox/ruby-head/bin/ruby main.rb < test.in')
         | 
| @@ -1,26 +1,26 @@ | |
| 1 1 | 
             
            require 'base64'
         | 
| 2 2 |  | 
| 3 | 
            -
            File.open( | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 3 | 
            +
            File.open('stdin.txt.bz2', 'wb') do |file|
         | 
| 4 | 
            +
              file.write Base64.decode64 $stdin.read
         | 
| 5 | 
            +
              file.close
         | 
| 6 6 | 
             
            end
         | 
| 7 7 |  | 
| 8 | 
            -
            system( | 
| 8 | 
            +
            system('bunzip2 stdin.txt.bz2')
         | 
| 9 9 |  | 
| 10 | 
            -
            stdin = File.open( | 
| 10 | 
            +
            stdin = File.open('stdin.txt').read.split("\n<$><*><$>\n")
         | 
| 11 11 | 
             
            code = stdin[0]
         | 
| 12 12 | 
             
            input = stdin[1]
         | 
| 13 13 | 
             
            time = stdin[2]
         | 
| 14 14 |  | 
| 15 | 
            -
            File.open( | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 15 | 
            +
            File.open('./main.swift', 'w') do |file|
         | 
| 16 | 
            +
              file.puts code
         | 
| 17 | 
            +
              file.close
         | 
| 18 18 | 
             
            end
         | 
| 19 19 |  | 
| 20 | 
            -
            File.open( | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 20 | 
            +
            File.open('./test.in', 'w') do |file|
         | 
| 21 | 
            +
              file.puts input
         | 
| 22 | 
            +
              file.close
         | 
| 23 23 | 
             
            end
         | 
| 24 24 |  | 
| 25 | 
            -
            system | 
| 26 | 
            -
            system | 
| 25 | 
            +
            system('/opt/wandbox/swift-head/usr/bin/swiftc main.swift -o main')
         | 
| 26 | 
            +
            system('timeout -s 9 ' + time + ' ./main < test.in')
         | 
    
        data/lib/judge_system.rb
    CHANGED
    
    | @@ -1,74 +1,57 @@ | |
| 1 | 
            -
            require  | 
| 1 | 
            +
            require 'judge_system/version'
         | 
| 2 2 | 
             
            require 'zlib_input'
         | 
| 3 | 
            -
            require  | 
| 4 | 
            -
            require  | 
| 5 | 
            -
            require  | 
| 6 | 
            -
            require 'timeout'
         | 
| 7 | 
            -
            require 'pathname'
         | 
| 3 | 
            +
            require 'net/http'
         | 
| 4 | 
            +
            require 'uri'
         | 
| 5 | 
            +
            require 'json'
         | 
| 8 6 |  | 
| 9 7 | 
             
            module JudgeSystem
         | 
| 10 | 
            -
             | 
| 8 | 
            +
              class WandBox
         | 
| 9 | 
            +
                def self.compile(compiler: '', code: '', stdin: '')
         | 
| 10 | 
            +
                  body = {
         | 
| 11 | 
            +
                    code: code,
         | 
| 12 | 
            +
                    compiler: compiler,
         | 
| 13 | 
            +
                    stdin: stdin
         | 
| 14 | 
            +
                  }.to_json
         | 
| 11 15 |  | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
            			request = Net::HTTP::Post.new(uri.request_uri, initheader = { "Content-type" => "application/json" },)
         | 
| 20 | 
            -
            			request.body = JSON.generate body
         | 
| 21 | 
            -
            			http = Net::HTTP.new(uri.host, uri.port)
         | 
| 22 | 
            -
            			http.start do |http|
         | 
| 23 | 
            -
            				response = http.request(request)
         | 
| 24 | 
            -
            				JSON.parse(response.body)
         | 
| 25 | 
            -
            			end
         | 
| 26 | 
            -
            		end
         | 
| 16 | 
            +
                  uri = URI.parse('http://melpon.org/wandbox/api/compile.json')
         | 
| 17 | 
            +
                  request = Net::HTTP::Post.new(uri.request_uri, 'Content-type' => 'application/json')
         | 
| 18 | 
            +
                  request.body = body
         | 
| 19 | 
            +
                  http = Net::HTTP.new(uri.host, uri.port)
         | 
| 20 | 
            +
                  response = http.request(request)
         | 
| 21 | 
            +
                  JSON.parse(response.body)
         | 
| 22 | 
            +
                end
         | 
| 27 23 |  | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
             | 
| 35 | 
            -
             | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
             | 
| 43 | 
            -
             | 
| 44 | 
            -
             | 
| 45 | 
            -
            			else
         | 
| 46 | 
            -
            				return result
         | 
| 47 | 
            -
            			end
         | 
| 48 | 
            -
            		end
         | 
| 49 | 
            -
            		private_class_method :compile, :run
         | 
| 50 | 
            -
            		
         | 
| 51 | 
            -
            		public
         | 
| 52 | 
            -
            		def self.judge lang, code , answer, stdin, time
         | 
| 53 | 
            -
            			output = run lang, code, stdin, time
         | 
| 54 | 
            -
            			if output == 'TLE'
         | 
| 55 | 
            -
            				return 'TLE'
         | 
| 56 | 
            -
            			elsif output == 'RE'
         | 
| 57 | 
            -
            				return 'RE'
         | 
| 58 | 
            -
            			else
         | 
| 59 | 
            -
            				result = output == answer
         | 
| 60 | 
            -
            				if result 
         | 
| 61 | 
            -
            					return 'AC'
         | 
| 62 | 
            -
            				else
         | 
| 63 | 
            -
            					return 'WA'
         | 
| 64 | 
            -
            				end
         | 
| 65 | 
            -
            			end
         | 
| 66 | 
            -
            		end
         | 
| 67 | 
            -
            	end
         | 
| 24 | 
            +
                def self.run(lang, code, input, time)
         | 
| 25 | 
            +
                  path = File.expand_path('../', __FILE__)
         | 
| 26 | 
            +
                  sys = File.open("#{path}/compile_systems/#{lang}_system.rb", 'r').read
         | 
| 27 | 
            +
                  data = nil
         | 
| 28 | 
            +
                  spliter = "\n<$><*><$>\n"
         | 
| 29 | 
            +
                  stdin = BZip2Input.compress(code + spliter + input + spliter + format('%f', time))
         | 
| 30 | 
            +
                  begin
         | 
| 31 | 
            +
                    data = compile(compiler: 'ruby-head', code: sys, stdin: stdin)
         | 
| 32 | 
            +
                  rescue
         | 
| 33 | 
            +
                    return 'RE'
         | 
| 34 | 
            +
                  end
         | 
| 35 | 
            +
                  error = data['program_error']
         | 
| 36 | 
            +
                  result = data['program_output']
         | 
| 37 | 
            +
                  return 'TLE' if error == "Killed\n"
         | 
| 38 | 
            +
                  return 'RE'  if result.nil? && error
         | 
| 39 | 
            +
                  result
         | 
| 40 | 
            +
                end
         | 
| 68 41 |  | 
| 69 | 
            -
             | 
| 70 | 
            -
            		WandBox.judge lang, code, answer, stdin, time
         | 
| 71 | 
            -
            	end
         | 
| 42 | 
            +
                private_class_method :compile, :run
         | 
| 72 43 |  | 
| 73 | 
            -
             | 
| 44 | 
            +
                def self.judge(lang, code, answer, stdin, time)
         | 
| 45 | 
            +
                  output = run(lang, code, stdin, time)
         | 
| 46 | 
            +
                  return 'TLE' if output == 'TLE'
         | 
| 47 | 
            +
                  return 'RE'  if output == 'RE'
         | 
| 48 | 
            +
                  output == answer ? 'AC' : 'WA'
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
              end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
              def judge_result(lang: '', code: '', answer: '', stdin: '', time: 20)
         | 
| 53 | 
            +
                WandBox.judge(lang, code, answer, stdin, time)
         | 
| 54 | 
            +
              end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
              module_function :judge_result
         | 
| 74 57 | 
             
            end
         | 
    
        data/lib/judge_system/version.rb
    CHANGED
    
    
    
        data/lib/zlib_input.rb
    CHANGED
    
    | @@ -1,12 +1,12 @@ | |
| 1 1 | 
             
            require 'rbzip2'
         | 
| 2 2 | 
             
            require 'base64'
         | 
| 3 3 | 
             
            module BZip2Input
         | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
            end
         | 
| 4 | 
            +
              def compress(input)
         | 
| 5 | 
            +
                string = StringIO.new
         | 
| 6 | 
            +
                bz2 = RBzip2::FFI::Compressor.new string
         | 
| 7 | 
            +
                bz2.write input
         | 
| 8 | 
            +
                bz2.close
         | 
| 9 | 
            +
                Base64.encode64(string.string)
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
              module_function :compress
         | 
| 12 | 
            +
            end
         | 
    
        data/wercker.yml
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: judge_system
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.7. | 
| 4 | 
            +
              version: 1.7.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - getty104
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2017- | 
| 11 | 
            +
            date: 2017-06-18 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rbzip2
         | 
| @@ -80,6 +80,20 @@ dependencies: | |
| 80 80 | 
             
                - - "~>"
         | 
| 81 81 | 
             
                  - !ruby/object:Gem::Version
         | 
| 82 82 | 
             
                    version: '3.0'
         | 
| 83 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 84 | 
            +
              name: rubocop
         | 
| 85 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 86 | 
            +
                requirements:
         | 
| 87 | 
            +
                - - "~>"
         | 
| 88 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 89 | 
            +
                    version: 0.42.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.42.0
         | 
| 83 97 | 
             
            description: "This is a judge system for online judge. \nThis gem work on the wandbox
         | 
| 84 98 | 
             
              api."
         | 
| 85 99 | 
             
            email:
         | 
| @@ -90,7 +104,7 @@ extra_rdoc_files: [] | |
| 90 104 | 
             
            files:
         | 
| 91 105 | 
             
            - ".gitignore"
         | 
| 92 106 | 
             
            - ".rspec"
         | 
| 93 | 
            -
            - ". | 
| 107 | 
            +
            - ".rubocop.yml"
         | 
| 94 108 | 
             
            - ".travis.yml"
         | 
| 95 109 | 
             
            - CODE_OF_CONDUCT.md
         | 
| 96 110 | 
             
            - Gemfile
         | 
    
        data/.ruby-version
    DELETED
    
    | @@ -1 +0,0 @@ | |
| 1 | 
            -
            2.3.3
         |