ccup 0.0.1

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.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm use 1.9.3@ccup
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ccup.gemspec
4
+ gemspec
@@ -0,0 +1,12 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', cli: "--color --format nested" do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^spec/ccup/.+_spec\.rb$})
7
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
8
+ watch('spec/spec_helper.rb') { "spec" }
9
+
10
+ watch(%r{^lib/ccup/(.+)\.rb$}) { |m| "spec/ccup/#{m[1]}_spec.rb" }
11
+ end
12
+
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Bryan Bibat
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,39 @@
1
+ # Ccup
2
+
3
+ Verification tool for DevCon Code Challenge Cup
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'ccup'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install ccup
18
+
19
+ ## Usage
20
+
21
+ $ ccup SUBMISSION_FILE INPUT_FOLDER OUTPUT_FILE ANSWER_KEY_FILE
22
+
23
+ Creates a temporary directory and copies SUBMISSION\_FILE, the files inside
24
+ INPUT\_FOLDER, and ANSWER\_KEY\_FILE into it before compiling (if needed) and
25
+ executing the SUBMISSION\_FILE.
26
+
27
+ Verification will be done by running "diff" on OUTPUT\_FILE and ANSWER\_KEY\_FILE
28
+ and putting the results into result.txt on the same folder. The running time
29
+ will also be added to result.txt.
30
+
31
+ The program ends with displaying the temporary folder.
32
+
33
+ ## Contributing
34
+
35
+ 1. Fork it
36
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
37
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
38
+ 4. Push to the branch (`git push origin my-new-feature`)
39
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
3
+ require 'ccup'
4
+
5
+ c = Ccup::Exec.new(ARGV)
6
+ c.process unless c.error
7
+ `nautilus #{c.temp_folder}` if c.temp_folder
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ccup/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "ccup"
8
+ gem.version = Ccup::VERSION
9
+ gem.authors = ["Bryan Bibat"]
10
+ gem.email = ["bry@bryanbibat.net"]
11
+ gem.description = %q{Verification tool for DevCon Code Challenge Cup}
12
+ gem.summary = %q{This automates stuff.}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_development_dependency "rspec"
21
+ gem.add_development_dependency "guard"
22
+ gem.add_development_dependency "guard-rspec"
23
+ gem.add_development_dependency "libnotify"
24
+ gem.add_development_dependency "rb-inotify"
25
+ gem.add_runtime_dependency "open4"
26
+
27
+ end
@@ -0,0 +1,6 @@
1
+ require "ccup/version"
2
+ require "ccup/exec"
3
+
4
+ module Ccup
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,181 @@
1
+ require 'open4'
2
+ require 'tmpdir'
3
+
4
+ module Ccup
5
+ class Exec
6
+
7
+ attr_reader :submission, :input_folder, :output_file, :answer_key, :error, :temp_folder
8
+ BANNER = <<-MSG
9
+
10
+ Usage
11
+ ccup SUBMISSION_FILE INPUT_FOLDER OUTPUT_FILE ANSWER_KEY_FILE
12
+
13
+ Description
14
+ Creates a temporary directory and copies SUBMISSION_FILE, the files inside
15
+ INPUT_FOLDER, and ANSWER_KEY_FILE into it before compiling (if needed) and
16
+ executing the SUBMISSION_FILE.
17
+
18
+ Verification will be done by running "diff" on OUTPUT_FILE and ANSWER_KEY_FILE
19
+ and putting the results into result.txt on the same folder. The running time
20
+ will also be added to result.txt.
21
+
22
+ The program ends with displaying the temporary folder.
23
+
24
+ MSG
25
+ def initialize(argv)
26
+ if argv.size != 4
27
+ $stderr.puts BANNER
28
+ @error = true
29
+ return
30
+ end
31
+ @submission = argv[0]
32
+ @input_folder = argv[1]
33
+ @output_file = argv[2]
34
+ @answer_key = argv[3]
35
+ unless @error
36
+ @submission_file = File.basename(@submission)
37
+ validate
38
+ @pl = determine_pl(File.extname(@submission))
39
+ end
40
+ end
41
+
42
+ def validate
43
+ unless File.exist? @submission
44
+ @error = true
45
+ $stderr.puts "Can't find #{@submission}"
46
+ end
47
+ unless Dir.exist? @input_folder
48
+ @error = true
49
+ $stderr.puts "Can't find #{@input_folder}"
50
+ end
51
+ unless File.exist? @answer_key
52
+ @error = true
53
+ $stderr.puts "Can't find #{@answer_key}"
54
+ end
55
+ end
56
+
57
+ def determine_pl(ext)
58
+ case ext
59
+ when ".c"
60
+ :c
61
+ when ".cpp"
62
+ :cpp
63
+ when ".cs"
64
+ :csharp
65
+ when ".java"
66
+ :java
67
+ when ".php"
68
+ :php
69
+ when ".vb"
70
+ :vbnet
71
+ when ".rb"
72
+ :ruby
73
+ when ".py"
74
+ :python
75
+ when ".js"
76
+ :js
77
+ else
78
+ @error = true
79
+ $stderr.puts "Invalid submission"
80
+ end
81
+ end
82
+
83
+ def process
84
+ return if @error
85
+ @temp_folder = prepare_temp_folder
86
+ Dir.chdir @temp_folder do
87
+ @results_file = File.open("results.txt", "w")
88
+ compile
89
+ unless @error
90
+ run
91
+ end
92
+ unless @error
93
+ compare
94
+ end
95
+ @results_file.puts "Done."
96
+ @results_file.close
97
+ end
98
+ return self
99
+ end
100
+
101
+ def prepare_temp_folder
102
+ temp_folder = Dir.mktmpdir
103
+ FileUtils.cp @submission, temp_folder
104
+ Dir.chdir @input_folder do
105
+ FileUtils.cp Dir.entries(".").reject { |x| File.directory? x }, temp_folder
106
+ end
107
+ FileUtils.cp @answer_key, temp_folder
108
+ `touch #{File.join temp_folder, @output_file}`
109
+ temp_folder
110
+ end
111
+
112
+ def compile
113
+ command = case @pl
114
+ when :c
115
+ "gcc -Wall #{@submission_file} -o #{root_name}"
116
+ when :cpp
117
+ "g++ -Wall #{@submission_file} -o #{root_name}"
118
+ when :csharp
119
+ "gmcs #{@submission_file}"
120
+ when :java
121
+ "javac #{@submission_file}"
122
+ when :vbnet
123
+ "vbnc #{@submission_file}"
124
+ end
125
+ if command
126
+ @results_file.puts "Compiling submission..."
127
+ pid, stdin, stdout, stderr = Open4::popen4 command
128
+ ignored, status = Process::waitpid2 pid
129
+ unless status.exitstatus == 0
130
+ @error = true
131
+ @results_file.puts "ERROR ENCOUNTERED:"
132
+ @results_file.puts stderr.read.strip
133
+ end
134
+ end
135
+ end
136
+
137
+ def run
138
+ command = case @pl
139
+ when :c, :cpp
140
+ "./#{root_name}"
141
+ when :csharp, :vbnet
142
+ "mono #{root_name}.exe"
143
+ when :java
144
+ "java #{root_name}"
145
+ when :ruby
146
+ "ruby #{@submission_file}"
147
+ when :python
148
+ "python #{@submission_file}"
149
+ when :php
150
+ "php #{@submission_file}"
151
+ when :js
152
+ "node #{@submission_file}"
153
+ end
154
+ @results_file.puts "Running submission..."
155
+ start_at = Time.now
156
+ pid, stdin, stdout, stderr = Open4::popen4 command
157
+ ignored, status = Process::waitpid2 pid
158
+
159
+ unless status.exitstatus == 0
160
+ @error = true
161
+ @results_file.puts "ERROR ENCOUNTERED:"
162
+ @results_file.puts stderr.read.strip
163
+ end
164
+ #TODO check status
165
+ @results_file.puts "Execution time: #{ Time.now - start_at } seconds"
166
+ end
167
+
168
+ def root_name
169
+ File.basename(@submission_file, File.extname(@submission_file))
170
+ end
171
+
172
+ def compare
173
+ @results_file.puts "Comparing output with answer key..."
174
+ pid, stdin, stdout, stderr = Open4::popen4 "diff #{@output_file} #{File.basename @answer_key}"
175
+ ignored, status = Process::waitpid2 pid
176
+
177
+ @results_file.puts stdout.read.strip
178
+ end
179
+
180
+ end
181
+ end
@@ -0,0 +1,3 @@
1
+ module Ccup
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,204 @@
1
+ require 'spec_helper'
2
+
3
+ valid_submission = "./spec/files/submission.rb"
4
+ valid_input_folder = "./spec/files/input"
5
+ valid_output = "output.txt"
6
+ valid_answer_key = "./spec/files/answer_key.txt"
7
+
8
+ incorrect_submission = "./spec/files/wrong_submission.rb"
9
+ error_submission = "./spec/files/error_submission.rb"
10
+ missing_submission = "./spec/files/missing.rb"
11
+ missing_input_folder = "./spec/files/inputx"
12
+ missing_answer_key = "./spec/files/answer_keyx.txt"
13
+ compile_error_submission = "./spec/files/SubmissionError.java"
14
+ valid_python = "./spec/files/submission.py"
15
+ valid_java = "./spec/files/Submission.java"
16
+
17
+ incorrect_c = "./spec/files/hello.c"
18
+ incorrect_cpp = "./spec/files/hello.cpp"
19
+ incorrect_cs = "./spec/files/hello.cs"
20
+ incorrect_vb = "./spec/files/hello.vb"
21
+ incorrect_php = "./spec/files/hello.php"
22
+ incorrect_js = "./spec/files/hello.js"
23
+
24
+ valid_values = [valid_submission, valid_input_folder, valid_output, valid_answer_key]
25
+
26
+ describe Ccup::Exec do
27
+
28
+ describe "input" do
29
+ it "should output error" do
30
+ error = capture(:stderr) do
31
+ Ccup::Exec.new([])
32
+ end
33
+ error.should == Ccup::Exec::BANNER
34
+ end
35
+
36
+ it "should have 4 arguments" do
37
+ capture(:stderr) do
38
+ Ccup::Exec.new([]).error.should be true
39
+ end
40
+ error = capture(:stderr) do
41
+ Ccup::Exec.new(valid_values[0,3]).error.should be true
42
+ end
43
+ error.should == Ccup::Exec::BANNER
44
+ end
45
+ end
46
+
47
+ describe "correct input" do
48
+ it "should not return with error" do
49
+ error = capture(:stderr) do
50
+ c = Ccup::Exec.new(valid_values)
51
+ c.error.should_not be true
52
+ c.process
53
+ 5.should == IO.readlines(File.join(c.temp_folder, "results.txt")).size
54
+ end
55
+ error.should_not == Ccup::Exec::BANNER
56
+ end
57
+
58
+ it "should not return with error" do
59
+ error = capture(:stderr) do
60
+ c = Ccup::Exec.new(valid_values)
61
+ c.error.should_not be true
62
+ c.process
63
+ 5.should == IO.readlines(File.join(c.temp_folder, "results.txt")).size
64
+ end
65
+ error.should_not == Ccup::Exec::BANNER
66
+ end
67
+ it "should produce a large result file" do
68
+ invalid_values = [incorrect_submission] + valid_values[1,3]
69
+ c = Ccup::Exec.new(invalid_values).process
70
+ 5.should < IO.readlines(File.join(c.temp_folder, "results.txt")).size
71
+ end
72
+
73
+ it "for python should not return with error" do
74
+ error = capture(:stderr) do
75
+ python_values = [valid_python] + valid_values[1,3]
76
+ c = Ccup::Exec.new(python_values)
77
+ c.error.should_not be true
78
+ c.process
79
+ 5.should == IO.readlines(File.join(c.temp_folder, "results.txt")).size
80
+ end
81
+ error.should_not == Ccup::Exec::BANNER
82
+ end
83
+
84
+ it "for java should not return with error" do
85
+ error = capture(:stderr) do
86
+ java_values = [valid_java] + valid_values[1,3]
87
+ c = Ccup::Exec.new(java_values)
88
+ c.error.should_not be true
89
+ c.process
90
+ 6.should == IO.readlines(File.join(c.temp_folder, "results.txt")).size
91
+ end
92
+ error.should_not == Ccup::Exec::BANNER
93
+ end
94
+ end
95
+
96
+ describe "initial load" do
97
+
98
+ subject { Ccup::Exec.new(valid_values) }
99
+
100
+ its(:submission) { should == valid_submission }
101
+ it "should produce a large result file" do
102
+ invalid_values = [incorrect_submission] + valid_values[1,3]
103
+ c = Ccup::Exec.new(invalid_values).process
104
+ 5.should < IO.readlines(File.join(c.temp_folder, "results.txt")).size
105
+ end
106
+ its(:input_folder) { should == valid_input_folder }
107
+ its(:output_file) { should == valid_output }
108
+ its(:answer_key) { should == valid_answer_key }
109
+
110
+ end
111
+
112
+ describe "incorrect input" do
113
+
114
+ it "should stop on missing submission files" do
115
+ error = capture(:stderr) do
116
+ invalid_values = [missing_submission] + valid_values[1,3]
117
+ c = Ccup::Exec.new(invalid_values)
118
+ c.error.should == true
119
+ end
120
+ error.strip.should == "Can't find #{missing_submission}"
121
+ end
122
+
123
+ it "should stop on missing input folder" do
124
+ error = capture(:stderr) do
125
+ invalid_values = [valid_values[0], missing_input_folder] + valid_values[2,2]
126
+ c = Ccup::Exec.new(invalid_values)
127
+ c.error.should == true
128
+ end
129
+ error.strip.should == "Can't find #{missing_input_folder}"
130
+ end
131
+
132
+ it "should stop on missing answer key" do
133
+ error = capture(:stderr) do
134
+ invalid_values = valid_values[0,3] + [missing_answer_key]
135
+ c = Ccup::Exec.new(invalid_values)
136
+ c.error.should == true
137
+ end
138
+ error.strip.should == "Can't find #{missing_answer_key}"
139
+ end
140
+
141
+ it "should stop on non-programs" do
142
+ error = capture(:stderr) do
143
+ invalid_values = [valid_answer_key] + valid_values[1,3]
144
+ c = Ccup::Exec.new(invalid_values)
145
+ c.error.should == true
146
+ end
147
+ error.strip.should == "Invalid submission"
148
+ end
149
+
150
+ it "should produce a large result file" do
151
+ invalid_values = [incorrect_submission] + valid_values[1,3]
152
+ c = Ccup::Exec.new(invalid_values).process
153
+ 5.should < IO.readlines(File.join(c.temp_folder, "results.txt")).size
154
+ end
155
+
156
+ it "should stop on compiler error" do
157
+ invalid_values = [compile_error_submission] + valid_values[1,3]
158
+ c = Ccup::Exec.new(invalid_values).process
159
+ "ERROR ENCOUNTERED:".should == IO.readlines(File.join(c.temp_folder, "results.txt"))[1].strip
160
+ end
161
+
162
+ it "should stop on runtime error" do
163
+ invalid_values = [error_submission] + valid_values[1,3]
164
+ c = Ccup::Exec.new(invalid_values).process
165
+ "ERROR ENCOUNTERED:".should == IO.readlines(File.join(c.temp_folder, "results.txt"))[1].strip
166
+ end
167
+
168
+ it "should fail on incorrect C" do
169
+ invalid_values = [incorrect_c] + valid_values[1,3]
170
+ c = Ccup::Exec.new(invalid_values).process
171
+ 6.should < IO.readlines(File.join(c.temp_folder, "results.txt")).size
172
+ end
173
+
174
+ it "should fail on incorrect C++" do
175
+ invalid_values = [incorrect_cpp] + valid_values[1,3]
176
+ c = Ccup::Exec.new(invalid_values).process
177
+ 6.should < IO.readlines(File.join(c.temp_folder, "results.txt")).size
178
+ end
179
+
180
+ it "should fail on incorrect C#" do
181
+ invalid_values = [incorrect_cs] + valid_values[1,3]
182
+ c = Ccup::Exec.new(invalid_values).process
183
+ 6.should < IO.readlines(File.join(c.temp_folder, "results.txt")).size
184
+ end
185
+
186
+ it "should fail on incorrect VB.NET" do
187
+ invalid_values = [incorrect_vb] + valid_values[1,3]
188
+ c = Ccup::Exec.new(invalid_values).process
189
+ 6.should < IO.readlines(File.join(c.temp_folder, "results.txt")).size
190
+ end
191
+
192
+ it "should fail on incorrect PHP" do
193
+ invalid_values = [incorrect_php] + valid_values[1,3]
194
+ c = Ccup::Exec.new(invalid_values).process
195
+ 5.should < IO.readlines(File.join(c.temp_folder, "results.txt")).size
196
+ end
197
+
198
+ it "should fail on incorrect JS" do
199
+ invalid_values = [incorrect_js] + valid_values[1,3]
200
+ c = Ccup::Exec.new(invalid_values).process
201
+ 5.should < IO.readlines(File.join(c.temp_folder, "results.txt")).size
202
+ end
203
+ end
204
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ccup do
4
+ it "has the correct version" do
5
+ Ccup::VERSION.should == "0.0.1"
6
+ end
7
+ end
8
+
@@ -0,0 +1,25 @@
1
+ import java.io.BufferedWriter;
2
+ import java.io.File;
3
+ import java.io.FileWriter;
4
+ import java.io.IOException;
5
+ import java.io.PrintWriter;
6
+ import java.util.Scanner;
7
+
8
+ public class Submission {
9
+ public static void main(String... args) throws IOException {
10
+ Scanner sc = new Scanner(new File("input.txt"));
11
+ PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
12
+ "output.txt")));
13
+ while (sc.hasNextLine()) {
14
+ Scanner lsc = new Scanner(sc.nextLine());
15
+ long sum = 0;
16
+ while (lsc.hasNextInt()) {
17
+ sum += lsc.nextInt();
18
+ }
19
+ out.println(Long.toString(sum));
20
+ lsc.close();
21
+ }
22
+ out.close();
23
+ sc.close();
24
+ }
25
+ }
@@ -0,0 +1,26 @@
1
+ import java.io.BufferedWriter;
2
+ import java.io.File;
3
+ import java.io.FileWriter;
4
+ import java.io.IOException;
5
+ import java.io.PrintWriter;
6
+ import java.util.Scanner;
7
+
8
+ public class SubmissionJava {
9
+ public static void main(String... args) throws IOException {
10
+ Scanner sc = new Scaner(new File("input.txt"));
11
+ PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
12
+ "output.txt")));
13
+ while (sc.hasNextLine()) {
14
+ Scanner lsc = new Scanner(sc.nextLine());
15
+ long sum = 0;
16
+ while (lsc.hasNextInt()) {
17
+ sum += lsc.nextInt();
18
+ }
19
+ out.println(Long.toString(sum));
20
+ lsc.close();
21
+ }
22
+ out.close();
23
+ sc.close();
24
+ }
25
+ }
26
+
@@ -0,0 +1,2 @@
1
+ 6
2
+ 999
@@ -0,0 +1,4 @@
1
+ output = Fle.open("output.txt", "w")
2
+ IO.readlines("input.txt").each do |line|
3
+ output.puts( line.split.map { |x| x.to_i }.reduce(:+) )
4
+ end
@@ -0,0 +1,7 @@
1
+ # include <stdio.h>
2
+
3
+ int main(void)
4
+ {
5
+ printf("Hello World\n");
6
+ return 0;
7
+ }
@@ -0,0 +1,10 @@
1
+ // my first program in C++
2
+
3
+ #include <iostream>
4
+ using namespace std;
5
+
6
+ int main ()
7
+ {
8
+ cout << "Hello World!";
9
+ return 0;
10
+ }
@@ -0,0 +1,10 @@
1
+ using System;
2
+
3
+ public class HelloWorld
4
+ {
5
+ static public void Main ()
6
+ {
7
+ Console.WriteLine ("Hello Mono World");
8
+ }
9
+
10
+ }
@@ -0,0 +1 @@
1
+ console.log("Hello World!");
@@ -0,0 +1 @@
1
+ <?php echo("Hello");
@@ -0,0 +1,11 @@
1
+ ' Allow easy reference to the System namespace classes.
2
+ Imports System
3
+
4
+ ' This module houses the application's entry point.
5
+ Public Module modmain
6
+ ' Main is the application's entry point.
7
+ Sub Main()
8
+ ' Write text to the console.
9
+ Console.WriteLine ("Hello World using Visual Basic!")
10
+ End Sub
11
+ End Module
@@ -0,0 +1,2 @@
1
+ 1 2 3
2
+ 222 333 444
@@ -0,0 +1,5 @@
1
+ output = open("output.txt", "w")
2
+ for line in open("input.txt", "r"):
3
+ output.write(str(sum([int(x) for x in line.split()])))
4
+ output.write("\n")
5
+ output.close()
@@ -0,0 +1,4 @@
1
+ output = File.open("output.txt", "w")
2
+ IO.readlines("input.txt").each do |line|
3
+ output.puts( line.split.map { |x| x.to_i }.reduce(:+) )
4
+ end
@@ -0,0 +1 @@
1
+ puts "Hello World"
@@ -0,0 +1,15 @@
1
+ require_relative '../lib/ccup'
2
+
3
+ require 'stringio'
4
+
5
+ def capture(*streams)
6
+ streams.map! { |stream| stream.to_s }
7
+ begin
8
+ result = StringIO.new
9
+ streams.each { |stream| eval "$#{stream} = result" }
10
+ yield
11
+ ensure
12
+ streams.each { |stream| eval("$#{stream} = #{stream.upcase}") }
13
+ end
14
+ result.string
15
+ end
metadata ADDED
@@ -0,0 +1,188 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ccup
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Bryan Bibat
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: guard
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: guard-rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: libnotify
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rb-inotify
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: open4
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ description: Verification tool for DevCon Code Challenge Cup
111
+ email:
112
+ - bry@bryanbibat.net
113
+ executables:
114
+ - ccup
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - .rvmrc
120
+ - Gemfile
121
+ - Guardfile
122
+ - LICENSE.txt
123
+ - README.md
124
+ - Rakefile
125
+ - bin/ccup
126
+ - ccup.gemspec
127
+ - lib/ccup.rb
128
+ - lib/ccup/exec.rb
129
+ - lib/ccup/version.rb
130
+ - spec/ccup/exec_spec.rb
131
+ - spec/ccup_spec.rb
132
+ - spec/files/Submission.java
133
+ - spec/files/SubmissionError.java
134
+ - spec/files/answer_key.txt
135
+ - spec/files/error_submission.rb
136
+ - spec/files/hello.c
137
+ - spec/files/hello.cpp
138
+ - spec/files/hello.cs
139
+ - spec/files/hello.js
140
+ - spec/files/hello.php
141
+ - spec/files/hello.vb
142
+ - spec/files/input/input.txt
143
+ - spec/files/submission.py
144
+ - spec/files/submission.rb
145
+ - spec/files/wrong_submission.rb
146
+ - spec/spec_helper.rb
147
+ homepage: ''
148
+ licenses: []
149
+ post_install_message:
150
+ rdoc_options: []
151
+ require_paths:
152
+ - lib
153
+ required_ruby_version: !ruby/object:Gem::Requirement
154
+ none: false
155
+ requirements:
156
+ - - ! '>='
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
160
+ none: false
161
+ requirements:
162
+ - - ! '>='
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ requirements: []
166
+ rubyforge_project:
167
+ rubygems_version: 1.8.24
168
+ signing_key:
169
+ specification_version: 3
170
+ summary: This automates stuff.
171
+ test_files:
172
+ - spec/ccup/exec_spec.rb
173
+ - spec/ccup_spec.rb
174
+ - spec/files/Submission.java
175
+ - spec/files/SubmissionError.java
176
+ - spec/files/answer_key.txt
177
+ - spec/files/error_submission.rb
178
+ - spec/files/hello.c
179
+ - spec/files/hello.cpp
180
+ - spec/files/hello.cs
181
+ - spec/files/hello.js
182
+ - spec/files/hello.php
183
+ - spec/files/hello.vb
184
+ - spec/files/input/input.txt
185
+ - spec/files/submission.py
186
+ - spec/files/submission.rb
187
+ - spec/files/wrong_submission.rb
188
+ - spec/spec_helper.rb