mumukit 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 96ca9d2847fa9cf5412c483dd9e7900b0c093549
4
+ data.tar.gz: 07439f192678d0ac52cf8009ed2249a6955bcc88
5
+ SHA512:
6
+ metadata.gz: 7fb5c9cde7fb1e16ff83232a7b43dd11511c6ab504b07a1a72984bf36055d872fc48b51435ec027ff81a0626b5324595620cb626e776f4c2c9f17ac29bf6993d
7
+ data.tar.gz: f5eb3c788559964d2ac32ed272631ee3305cf17b293435d25499be1259b64122cc67c5812e76f426f2f9712cb27b3b3aa1ad8f52856d2b874a3e2fb7d8645c51
@@ -0,0 +1,14 @@
1
+ module Mumukit
2
+ class FileTestCompiler < Mumukit::Stub
3
+ include Mumukit::WithTempfile
4
+
5
+ def compile(test, extra, content)
6
+ raise 'You need to implement this method'
7
+ end
8
+
9
+ def create_compilation!(test, extra, content)
10
+ write_tempfile! compile(test, extra, content)
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,20 @@
1
+ class FileTestRunner < Mumukit::Stub
2
+ include Mumukit::WithCommandLine
3
+ def run_compilation!(file)
4
+ post_process_file(file, *run_test_file!(file))
5
+ ensure
6
+ file.unlink
7
+ end
8
+
9
+ def post_process_file(file, result, status)
10
+ [result, status]
11
+ end
12
+
13
+ def run_test_file!(file)
14
+ run_command run_test_command(file)
15
+ end
16
+
17
+ def run_test_command(file)
18
+ raise 'You need to implement this method'
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ class Mumukit::Stub
2
+ def initialize(config=nil)
3
+ @config = config
4
+ end
5
+ end
@@ -0,0 +1,42 @@
1
+ require 'yaml'
2
+
3
+ class Mumukit::TestServer
4
+ attr_reader :config
5
+
6
+ def initialize(config)
7
+ @config = config
8
+ end
9
+
10
+ def run!(request)
11
+ content = request['content']
12
+
13
+ test_results = run_tests! config, request['test'], request['extra'], content
14
+ expectation_results = run_expectations! config, request['expectations'], content
15
+
16
+ response = {exit: test_results[1], out: test_results[0], expectationResults: expectation_results}
17
+ response[:feedback] = test_results[2] if test_results[2]
18
+
19
+ response
20
+ rescue Exception => e
21
+ {exit: :failed, out: "#{e.message}:\n#{e.backtrace.join("\n")}"}
22
+ end
23
+
24
+
25
+ def run_tests!(config, test, extra, content)
26
+ compiler = TestCompiler.new(config)
27
+ runner = TestRunner.new(config)
28
+
29
+ compilation = compiler.create_compilation!(test, extra, content)
30
+ runner.run_compilation!(compilation)
31
+ end
32
+
33
+ def run_expectations!(config, expectations, content)
34
+ expectations_runner = ExpectationsRunner.new(config)
35
+
36
+ if expectations
37
+ expectations_runner.run_expectations!(expectations, content)
38
+ else
39
+ []
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,28 @@
1
+ require 'sinatra/base'
2
+ require 'yaml'
3
+ require 'json'
4
+
5
+ class Mumukit::TestServerApp < Sinatra::Base
6
+ configure do
7
+ set :mumuki_url, 'http://mumuki.io'
8
+ end
9
+
10
+ configure :development do
11
+ set :config_filename, 'config/development.yml'
12
+ end
13
+
14
+ configure :production do
15
+ set :config_filename, 'config/production.yml'
16
+ end
17
+
18
+ config = YAML.load_file(settings.config_filename) rescue nil
19
+ server = Mumukit::TestServer.new(config)
20
+
21
+ post '/test' do
22
+ JSON.generate(server.run!(JSON.parse(request.body.read)))
23
+ end
24
+
25
+ get '/*' do
26
+ redirect settings.mumuki_url
27
+ end
28
+ end
@@ -0,0 +1,3 @@
1
+ module Mumukit
2
+ VERSION = '0.3.0'
3
+ end
@@ -0,0 +1,7 @@
1
+ module Mumukit
2
+ module WithCommandLine
3
+ def run_command(command)
4
+ [%x{#{command}}, $?.success? ? :passed : :failed]
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,16 @@
1
+ require 'tempfile'
2
+
3
+ module Mumukit
4
+ module WithTempfile
5
+ def create_tempfile
6
+ Tempfile.new('mumuki.compile')
7
+ end
8
+
9
+ def write_tempfile!(content)
10
+ file = create_tempfile
11
+ file.write(content)
12
+ file.close
13
+ file
14
+ end
15
+ end
16
+ end
data/lib/mumukit.rb ADDED
@@ -0,0 +1,14 @@
1
+ module Mumukit
2
+ end
3
+
4
+ require_relative 'mumukit/version'
5
+ require_relative 'mumukit/stub'
6
+ require_relative 'mumukit/with_tempfile'
7
+ require_relative 'mumukit/with_command_line'
8
+ require_relative 'mumukit/file_test_compiler'
9
+ require_relative 'mumukit/file_test_runner'
10
+
11
+ require_relative 'stubs/expectations_runner'
12
+
13
+ require_relative 'mumukit/test_server'
14
+ require_relative 'mumukit/test_server_app'
@@ -0,0 +1,5 @@
1
+ class ExpectationsRunner < Mumukit::Stub
2
+ def run_expectations!(expectations, content)
3
+ []
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ class TestRunner
2
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mumukit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - Franco Leonardo Bulgarelli
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sinatra
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.4'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.4'
69
+ description: Helpers for building a Mumuki Test Server
70
+ email:
71
+ - flbulgarelli@yahoo.com.ar
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - lib/stubs/test_runner.rb
77
+ - lib/stubs/expectations_runner.rb
78
+ - lib/mumukit.rb
79
+ - lib/mumukit/with_command_line.rb
80
+ - lib/mumukit/with_tempfile.rb
81
+ - lib/mumukit/stub.rb
82
+ - lib/mumukit/file_test_compiler.rb
83
+ - lib/mumukit/test_server.rb
84
+ - lib/mumukit/version.rb
85
+ - lib/mumukit/file_test_runner.rb
86
+ - lib/mumukit/test_server_app.rb
87
+ homepage: https://github.com/flbulgarelli/mumukit
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - '>='
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.0.14
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: Mumuki Test Server Development Kit
111
+ test_files: []