most 0.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.
Files changed (96) hide show
  1. data/Copying.txt +679 -0
  2. data/History.txt +15 -0
  3. data/Manifest.txt +95 -0
  4. data/PostInstall.txt +6 -0
  5. data/Rakefile +44 -0
  6. data/Readme.rdoc +146 -0
  7. data/bin/most +31 -0
  8. data/lib/most.rb +52 -0
  9. data/lib/most/context.rb +244 -0
  10. data/lib/most/core.rb +171 -0
  11. data/lib/most/di/container.rb +148 -0
  12. data/lib/most/di/proxy.rb +55 -0
  13. data/lib/most/di/service.rb +63 -0
  14. data/lib/most/di/service_factory.rb +40 -0
  15. data/lib/most/environment.rb +67 -0
  16. data/lib/most/executor.rb +80 -0
  17. data/lib/most/helpers/array.rb +31 -0
  18. data/lib/most/helpers/hash.rb +25 -0
  19. data/lib/most/helpers/kernel.rb +35 -0
  20. data/lib/most/helpers/memory_out.rb +93 -0
  21. data/lib/most/helpers/numeric.rb +59 -0
  22. data/lib/most/helpers/object.rb +65 -0
  23. data/lib/most/helpers/symbol.rb +31 -0
  24. data/lib/most/interfaces/meta_programmable.rb +59 -0
  25. data/lib/most/starter.rb +126 -0
  26. data/lib/most/structures/box.rb +199 -0
  27. data/lib/most/structures/submission.rb +117 -0
  28. data/lib/most/structures/test_case.rb +173 -0
  29. data/lib/most/structures/test_runner.rb +103 -0
  30. data/lib/most/structures/types/options.rb +67 -0
  31. data/lib/most/structures/types/path.rb +39 -0
  32. data/lib/most/structures/types/report.rb +84 -0
  33. data/lib/most/submissions/cpp_memory_out_sample.rb +34 -0
  34. data/lib/most/submissions/cpp_sample.rb +36 -0
  35. data/lib/most/submissions/cpp_timeout_sample.rb +34 -0
  36. data/lib/most/submissions/cs_sample.rb +36 -0
  37. data/lib/most/submissions/erlang_sample.rb +36 -0
  38. data/lib/most/submissions/haskell_sample.rb +36 -0
  39. data/lib/most/submissions/java_sample.rb +36 -0
  40. data/lib/most/submissions/lisp_sample.rb +32 -0
  41. data/lib/most/submissions/lua_sample.rb +36 -0
  42. data/lib/most/submissions/ocaml_sample.rb +36 -0
  43. data/lib/most/submissions/pascal_sample.rb +36 -0
  44. data/lib/most/submissions/perl_sample.rb +32 -0
  45. data/lib/most/submissions/php_sample.rb +32 -0
  46. data/lib/most/submissions/python_sample.rb +32 -0
  47. data/lib/most/submissions/ruby_sample.rb +32 -0
  48. data/lib/most/submissions/vb_sample.rb +36 -0
  49. data/lib/most/tasks/general/win/cs.rb +60 -0
  50. data/lib/most/tasks/general/win/erlang.rb +86 -0
  51. data/lib/most/tasks/general/win/gcc.rb +39 -0
  52. data/lib/most/tasks/general/win/haskell.rb +75 -0
  53. data/lib/most/tasks/general/win/java.rb +72 -0
  54. data/lib/most/tasks/general/win/lisp.rb +59 -0
  55. data/lib/most/tasks/general/win/lua.rb +75 -0
  56. data/lib/most/tasks/general/win/ocaml.rb +77 -0
  57. data/lib/most/tasks/general/win/pascal.rb +73 -0
  58. data/lib/most/tasks/general/win/perl.rb +61 -0
  59. data/lib/most/tasks/general/win/php.rb +59 -0
  60. data/lib/most/tasks/general/win/python.rb +59 -0
  61. data/lib/most/tasks/general/win/ruby.rb +61 -0
  62. data/lib/most/tasks/general/win/vb.rb +60 -0
  63. data/lib/most/tasks/general/win/vc.rb +79 -0
  64. data/lib/most/tasks/general/win/vs.rb +52 -0
  65. data/samples/problem/solutions/cpp/main.cpp +9 -0
  66. data/samples/problem/solutions/cpp/tests.yml +19 -0
  67. data/samples/problem/solutions/cs/main.cs +17 -0
  68. data/samples/problem/solutions/cs/tests.yml +19 -0
  69. data/samples/problem/solutions/erlang/main.erl +2 -0
  70. data/samples/problem/solutions/erlang/tests.yml +19 -0
  71. data/samples/problem/solutions/haskell/main.hs +5 -0
  72. data/samples/problem/solutions/haskell/tests.yml +19 -0
  73. data/samples/problem/solutions/java/Main.java +14 -0
  74. data/samples/problem/solutions/java/tests.yml +19 -0
  75. data/samples/problem/solutions/lisp/main.lisp +1 -0
  76. data/samples/problem/solutions/lisp/tests.yml +19 -0
  77. data/samples/problem/solutions/lua/main.lua +4 -0
  78. data/samples/problem/solutions/lua/tests.yml +19 -0
  79. data/samples/problem/solutions/ocaml/main.ml +3 -0
  80. data/samples/problem/solutions/ocaml/tests.yml +19 -0
  81. data/samples/problem/solutions/pascal/main.pas +5 -0
  82. data/samples/problem/solutions/pascal/tests.yml +19 -0
  83. data/samples/problem/solutions/perl/main.pl +2 -0
  84. data/samples/problem/solutions/perl/tests.yml +19 -0
  85. data/samples/problem/solutions/php/main.php +1 -0
  86. data/samples/problem/solutions/php/tests.yml +19 -0
  87. data/samples/problem/solutions/python/main.py +1 -0
  88. data/samples/problem/solutions/python/tests.yml +19 -0
  89. data/samples/problem/solutions/ruby/main.rb +1 -0
  90. data/samples/problem/solutions/ruby/tests.yml +19 -0
  91. data/samples/problem/solutions/vb/main.vb +14 -0
  92. data/samples/problem/solutions/vb/tests.yml +19 -0
  93. data/samples/time_memory/solutions/cpp/main.cpp +21 -0
  94. data/samples/time_memory/solutions/cpp/tests.yml +19 -0
  95. data/tasks/samples.rb +31 -0
  96. metadata +242 -0
@@ -0,0 +1,32 @@
1
+ submission do
2
+ name 'Simple Python Submission'
3
+
4
+ entities :executable => path('main.py')
5
+
6
+ options :tests => {:report => {:differences => true, :time => true, :specs => true},
7
+ :steps => {:break => {:unsuccessful => true}}}
8
+
9
+ YAML.load_file('tests.yml').each_with_index do |specs, i|
10
+
11
+ add_test TestCase do
12
+ name "Test #{i + 1}"
13
+
14
+ input specs[:input]
15
+ output specs[:output]
16
+
17
+ runner TestRunner do
18
+ name 'Python Runner'
19
+
20
+ add_step Proc do
21
+ timeout specs[:time] do
22
+ total_memory_out specs[:memory] do
23
+ rake_clean 'win:python:run', entities[:executable], input
24
+ end
25
+ end
26
+ end
27
+
28
+ end
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,32 @@
1
+ submission do
2
+ name 'Simple Ruby Submission'
3
+
4
+ entities :executable => path('main.rb')
5
+
6
+ options :tests => {:report => {:differences => true, :time => true, :specs => true},
7
+ :steps => {:break => {:unsuccessful => true}}}
8
+
9
+ YAML.load_file('tests.yml').each_with_index do |specs, i|
10
+
11
+ add_test TestCase do
12
+ name "Test #{i + 1}"
13
+
14
+ input specs[:input]
15
+ output specs[:output]
16
+
17
+ runner TestRunner do
18
+ name 'Ruby Runner'
19
+
20
+ add_step Proc do
21
+ timeout specs[:time] do
22
+ total_memory_out specs[:memory] do
23
+ rake_clean 'win:ruby:run', entities[:executable], input
24
+ end
25
+ end
26
+ end
27
+
28
+ end
29
+ end
30
+
31
+ end
32
+ end
@@ -0,0 +1,36 @@
1
+ submission do
2
+ name 'Simple Visual Basic Submission'
3
+
4
+ entities :source_file => path('main.vb'), :executable => path('main.exe')
5
+
6
+ options :tests => {:report => {:differences => true, :time => true, :specs => true},
7
+ :steps => {:break => {:unsuccessful => true}}}
8
+
9
+ YAML.load_file('tests.yml').each_with_index do |specs, i|
10
+
11
+ add_test TestCase do
12
+ name "Test #{i + 1}"
13
+
14
+ input specs[:input]
15
+ output specs[:output]
16
+
17
+ runner TestRunner do
18
+ name 'Visual Basic Runner'
19
+
20
+ add_step Proc do
21
+ rake_clean 'win:vb:compile', entities[:source_file]
22
+ end
23
+
24
+ add_step Proc do
25
+ timeout specs[:time] do
26
+ total_memory_out specs[:memory] do
27
+ rake_clean 'win:vb:run', entities[:executable], input
28
+ end
29
+ end
30
+ end
31
+
32
+ end
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,60 @@
1
+ # Most - Modular Open Software Tester.
2
+ # Copyright (C) 2009 Dmitrii Toksaitov
3
+ #
4
+ # This file is part of Most.
5
+ #
6
+ # Most is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # Most is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with Most. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ require 'rake/clean'
20
+
21
+ namespace :win do
22
+ namespace :cs do
23
+
24
+ task :compile, :source, :needs => ['win:vs:find_vsvars'] do |task, args|
25
+ path = ENV['VSVARS']
26
+
27
+ preparation_command = path.nil? ? '' : "call \"#{path}\" &&"
28
+ compilation_command = %{#{preparation_command} csc /optimize+ #{args.source}}
29
+
30
+ service = Most::SERVICES[:open4]
31
+ service.popen4(compilation_command) do |stdin, stdout, stderr, pid|
32
+ $stdout.puts(stdout.read())
33
+ $stderr.puts(stderr.read())
34
+ end
35
+ end
36
+
37
+ task :run, :executable, :input do |task, args|
38
+ args.with_defaults(:input => '')
39
+
40
+ service = Most::SERVICES[:open4]
41
+ service.popen4(args.executable) do |stdin, stdout, stderr, pid|
42
+ Most::GLOBALS[:pid] = pid
43
+
44
+ unless args.input.is_a?(Most::Path)
45
+ stdin.write(args.input)
46
+ stdin.close()
47
+ end
48
+
49
+ process_stdout = stdout.read()
50
+ process_stderr = stderr.read()
51
+
52
+ Most::GLOBALS[:output] = process_stdout
53
+
54
+ $stdout.puts(process_stdout)
55
+ $stderr.puts(process_stderr)
56
+ end
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,86 @@
1
+ # Most - Modular Open Software Tester.
2
+ # Copyright (C) 2009 Dmitrii Toksaitov
3
+ #
4
+ # This file is part of Most.
5
+ #
6
+ # Most is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # Most is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with Most. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ require 'rake/clean'
20
+
21
+ CLEAN.include('*.dump')
22
+
23
+ namespace :win do
24
+ namespace :erlang do
25
+
26
+ task :prepare do
27
+ erlang_home = nil
28
+ Most::DIRECTORIES[:vendors].each do |directory|
29
+ possible_path = File.join(directory, 'erlang')
30
+ erlang_home = possible_path if File.directory?(possible_path)
31
+ end
32
+
33
+ unless erlang_home.nil?
34
+ bin_path = File.join(erlang_home, 'bin')
35
+ erts_bin_path = File.join(erlang_home, 'erts', 'bin')
36
+
37
+ ini_files = [File.join(bin_path, 'erl.ini').gsub(/[\/|\\]/, '\\\\\\\\'),
38
+ File.join(erts_bin_path, 'erl.ini').gsub(/[\/|\\]/, '\\\\\\\\')]
39
+
40
+ ENV['PATH'] ||= ''; ENV['PATH'] = "#{bin_path};#{ENV['PATH']}"
41
+
42
+ ini_files.each do |path|
43
+ File.open(path, 'w+') do |io|
44
+ io.write "[erlang]\n" +
45
+ "Bindir=#{erts_bin_path}\n" +
46
+ "Progname=erl\n" +
47
+ "Rootdir=#{erlang_home}\n"
48
+ end rescue nil
49
+ end
50
+ end
51
+ end
52
+
53
+ task :compile, :source, :needs => [:prepare] do |task, args|
54
+ compilation_command = %{erlc #{args.source}}
55
+
56
+ service = Most::SERVICES[:open4]
57
+ service.popen4(compilation_command) do |stdin, stdout, stderr, pid|
58
+ $stdout.puts(stdout.read())
59
+ $stderr.puts(stderr.read())
60
+ end
61
+ end
62
+
63
+ task :run, :entry_function, :input do |task, args|
64
+ args.with_defaults(:entry_function => '', :input => '')
65
+
66
+ service = Most::SERVICES[:open4]
67
+ service.popen4(%{erl -noshell -run #{args.entry_function} -s init stop}) do |stdin, stdout, stderr, pid|
68
+ Most::GLOBALS[:pid] = pid
69
+
70
+ unless args.input.is_a?(Most::Path)
71
+ stdin.write(args.input)
72
+ stdin.close()
73
+ end
74
+
75
+ process_stdout = stdout.read()
76
+ process_stderr = stderr.read()
77
+
78
+ Most::GLOBALS[:output] = process_stdout
79
+
80
+ $stdout.puts(process_stdout)
81
+ $stderr.puts(process_stderr)
82
+ end
83
+ end
84
+
85
+ end
86
+ end
@@ -0,0 +1,39 @@
1
+ # Most - Modular Open Software Tester.
2
+ # Copyright (C) 2009 Dmitrii Toksaitov
3
+ #
4
+ # This file is part of Most.
5
+ #
6
+ # Most is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # Most is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with Most. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ require 'rake/clean'
20
+
21
+ namespace :win do
22
+ namespace :gcc do
23
+
24
+ task :prepare do
25
+ gcc_home = nil
26
+ Most::DIRECTORIES[:vendors].each do |directory|
27
+ possible_path = File.join(directory, 'gcc')
28
+ gcc_home = possible_path if File.directory?(possible_path)
29
+ end
30
+
31
+ unless gcc_home.nil?
32
+ bin_path = File.join(gcc_home, 'bin')
33
+
34
+ ENV['PATH'] ||= ''; ENV['PATH'] = "#{bin_path};#{ENV['PATH']}"
35
+ end
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,75 @@
1
+ # Most - Modular Open Software Tester.
2
+ # Copyright (C) 2009 Dmitrii Toksaitov
3
+ #
4
+ # This file is part of Most.
5
+ #
6
+ # Most is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # Most is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with Most. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ require 'rake/clean'
20
+
21
+ CLEAN.include('*.hi')
22
+ CLEAN.include('*.o')
23
+
24
+ namespace :win do
25
+ namespace :haskell do
26
+
27
+ task :prepare do
28
+ haskell_home = nil
29
+ Most::DIRECTORIES[:vendors].each do |directory|
30
+ possible_path = File.join(directory, 'haskell')
31
+ haskell_home = possible_path if File.directory?(possible_path)
32
+ end
33
+
34
+ unless haskell_home.nil?
35
+ bin_path = File.join(haskell_home, 'bin')
36
+ extralibs_bin_path = File.join(haskell_home, 'extralibs', 'bin')
37
+
38
+ ENV['PATH'] ||= ''; ENV['PATH'] = "#{bin_path};#{extralibs_bin_path};#{ENV['PATH']}"
39
+ end
40
+ end
41
+
42
+ task :compile, :source, :needs => [:prepare] do |task, args|
43
+ compilation_command = %{ghc -O #{args.source}}
44
+
45
+ service = Most::SERVICES[:open4]
46
+ service.popen4(compilation_command) do |stdin, stdout, stderr, pid|
47
+ $stdout.puts(stdout.read())
48
+ $stderr.puts(stderr.read())
49
+ end
50
+ end
51
+
52
+ task :run, :executable, :input do |task, args|
53
+ args.with_defaults(:input => '')
54
+
55
+ service = Most::SERVICES[:open4]
56
+ service.popen4(args.executable) do |stdin, stdout, stderr, pid|
57
+ Most::GLOBALS[:pid] = pid
58
+
59
+ unless args.input.is_a?(Most::Path)
60
+ stdin.write(args.input)
61
+ stdin.close()
62
+ end
63
+
64
+ process_stdout = stdout.read()
65
+ process_stderr = stderr.read()
66
+
67
+ Most::GLOBALS[:output] = process_stdout
68
+
69
+ $stdout.puts(process_stdout)
70
+ $stderr.puts(process_stderr)
71
+ end
72
+ end
73
+
74
+ end
75
+ end
@@ -0,0 +1,72 @@
1
+ # Most - Modular Open Software Tester.
2
+ # Copyright (C) 2009 Dmitrii Toksaitov
3
+ #
4
+ # This file is part of Most.
5
+ #
6
+ # Most is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # Most is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with Most. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ require 'rake/clean'
20
+
21
+ namespace :win do
22
+ namespace :java do
23
+
24
+ task :prepare do
25
+ java_home = nil
26
+ Most::DIRECTORIES[:vendors].each do |directory|
27
+ possible_path = File.join(directory, 'java')
28
+ java_home = possible_path if File.directory?(possible_path)
29
+ end
30
+
31
+ unless java_home.nil?
32
+ bin_path = File.join(java_home, 'bin')
33
+
34
+ ENV['PATH'] ||= ''; ENV['PATH'] = "#{bin_path};#{ENV['PATH']}"
35
+ ENV['JAVA_HOME'] ||= ''; ENV['JAVA_HOME'] = java_home
36
+ end
37
+ end
38
+
39
+ task :compile, :source, :needs => [:prepare] do |task, args|
40
+ compilation_command = %{javac #{args.source}}
41
+
42
+ service = Most::SERVICES[:open4]
43
+ service.popen4(compilation_command) do |stdin, stdout, stderr, pid|
44
+ $stdout.puts(stdout.read())
45
+ $stderr.puts(stderr.read())
46
+ end
47
+ end
48
+
49
+ task :run, :executable, :input do |task, args|
50
+ args.with_defaults(:input => '')
51
+
52
+ service = Most::SERVICES[:open4]
53
+ service.popen4(%{java #{args.executable}}) do |stdin, stdout, stderr, pid|
54
+ Most::GLOBALS[:pid] = pid
55
+
56
+ unless args.input.is_a?(Most::Path)
57
+ stdin.write(args.input)
58
+ stdin.close()
59
+ end
60
+
61
+ process_stdout = stdout.read()
62
+ process_stderr = stderr.read()
63
+
64
+ Most::GLOBALS[:output] = process_stdout
65
+
66
+ $stdout.puts(process_stdout)
67
+ $stderr.puts(process_stderr)
68
+ end
69
+ end
70
+
71
+ end
72
+ end
@@ -0,0 +1,59 @@
1
+ # Most - Modular Open Software Tester.
2
+ # Copyright (C) 2009 Dmitrii Toksaitov
3
+ #
4
+ # This file is part of Most.
5
+ #
6
+ # Most is free software: you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # Most is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with Most. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ require 'rake/clean'
20
+
21
+ namespace :win do
22
+ namespace :lisp do
23
+
24
+ task :prepare do
25
+ lisp_home = nil
26
+ Most::DIRECTORIES[:vendors].each do |directory|
27
+ possible_path = File.join(directory, 'lisp')
28
+ lisp_home = possible_path if File.directory?(possible_path)
29
+ end
30
+
31
+ unless lisp_home.nil?
32
+ ENV['PATH'] ||= ''; ENV['PATH'] = "#{lisp_home};#{ENV['PATH']}"
33
+ end
34
+ end
35
+
36
+ task :run, :executable, :input, :needs => [:prepare] do |task, args|
37
+ args.with_defaults(:input => '')
38
+
39
+ service = Most::SERVICES[:open4]
40
+ service.popen4(%{clisp #{args.executable}}) do |stdin, stdout, stderr, pid|
41
+ Most::GLOBALS[:pid] = pid
42
+
43
+ unless args.input.is_a?(Most::Path)
44
+ stdin.write(args.input)
45
+ stdin.close()
46
+ end
47
+
48
+ process_stdout = stdout.read()
49
+ process_stderr = stderr.read()
50
+
51
+ Most::GLOBALS[:output] = process_stdout
52
+
53
+ $stdout.puts(process_stdout)
54
+ $stderr.puts(process_stderr)
55
+ end
56
+ end
57
+
58
+ end
59
+ end