code_eval 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/bin/code_eval +40 -0
  3. metadata +45 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 635aedc929f5b0f0ed0def00c869925007562557
4
+ data.tar.gz: 12be4a438017b95928dbb31b316caf444c3e7c02
5
+ SHA512:
6
+ metadata.gz: 184d65cf0cfb0a9c7405841d2a73d977ca3538227ee35d1b3f7daad438a7fed95879e8e2e440cf1709bb6bf5eb535321f23742e452f3ccff4b21799b647d3121
7
+ data.tar.gz: ddd54778b433a3ead8baeaa620db98936737c52aa1466c2ddc2b8e4d4775c1ec393c4dc3ec4b1501806d2f0f8854537ffe1933902d348343ffb942bc7479521f
data/bin/code_eval ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'openssl'
4
+ require 'base64'
5
+
6
+ EXECUTER = ARGV[0]
7
+ FILENAME = ARGV[1]
8
+ KEY = ARGV[2]
9
+ TEST_CASE_FILE = ARGV[3]
10
+
11
+ def encrypt(msg)
12
+ encrypter = OpenSSL::Cipher::AES.new(128, :CBC)
13
+ encrypter.encrypt
14
+ encrypter.pkcs5_keyivgen KEY, 'wingify1'
15
+ # cipher.iv = OpenSSL::PKey::RSA.new('wingify')
16
+ encrypted = encrypter.update msg
17
+ encrypted << encrypter.final
18
+ Base64.encode64(encrypted).encode('utf-8').chomp
19
+ end
20
+
21
+ def assert(expected_output, input)
22
+ puts "\nRunning Test Case #{input}"
23
+ start = Time.now.to_f
24
+ result = expected_output == encrypt(`#{EXECUTER} #{FILENAME} #{input}`) ? 'PASS' : 'FAIL'
25
+ time = Time.now.to_f - start
26
+ puts "Result: #{result}, Time: #{time.round(2)}"
27
+ return result == 'PASS' ? 1 : 0
28
+ end
29
+
30
+ total = 0
31
+
32
+ File.open(TEST_CASE_FILE, 'r') do |infile|
33
+ while (line = infile.gets)
34
+ input = line.split(' ')[0]
35
+ expected_output = line.split(' ')[1]
36
+ total += assert(expected_output, input)
37
+ end
38
+ end
39
+
40
+ puts "\n\nTotal score #{total}"
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: code_eval
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Sahil Batla
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-09-21 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Evaluate Code & Check Test Cases In a File
14
+ email: sahilbathla1@gmail.com
15
+ executables:
16
+ - code_eval
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/code_eval
21
+ homepage: http://rubygems.org/gems/code_eval
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.6.12
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Evaluate Code & Check Test Cases
45
+ test_files: []