mumuki-wollok-runner 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ODlmNTQ0ZDA3OTVhY2ZmNWE1NWYxNWZhMzFmN2UwZjg1ODg0MDI5NQ==
5
+ data.tar.gz: !binary |-
6
+ ZDFkMDk2NDAxY2U4MWYxNWIzZDkxMzkzZWU3Y2QxMmYzMGZjZGI0NQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MWE3NTMzNTA5OWM5YTVmMDFmZWUxN2JjYzViMmMyMWFhZTE5YjdmMGI3ZTRh
10
+ N2ZkN2E4NzI2YWZmMDY1OTg5ODZlMjAyZjZhNzQ1NmNhNzcyYTMyZDY0MjVh
11
+ MzlkNGY1ZjIyYmNjNTRhYTgxZmFkNTZiMTM4NTZhYWZjNWQ3NGI=
12
+ data.tar.gz: !binary |-
13
+ ZWQ0MjI0ZmM0OGFmNGRjNTNhY2JiMWRiZDA0MzJmMzlkYzFkM2VjZGNiODc3
14
+ OGFkMjQ1YmY5NjczMzYzOTQ0OWU3YmJiZGRlZmRlNTU5NDcyMGU3Mzk4YTg1
15
+ NzAyNmQ5ZDkwYmNmMWVhMDQ1NGJmMjIzNzM5Y2FmYjIzMTMzMjk=
@@ -0,0 +1,15 @@
1
+ class WollokMetadataHook < Mumukit::Hook
2
+ def metadata
3
+ {language: {
4
+ name: 'wollok',
5
+ icon: {type: 'devicon', name: 'code'},
6
+ version: '1.5',
7
+ extension: 'wlk',
8
+ ace_mode: 'wollok'
9
+ },
10
+ test_framework: {
11
+ name: 'builtin',
12
+ test_extension: 'wtest'
13
+ }}
14
+ end
15
+ end
@@ -0,0 +1,65 @@
1
+ require 'rest-client'
2
+
3
+ class WollokQueryHook < WollokHook
4
+ def transform_response(response)
5
+ if errored? response
6
+ [extract_compilation_errors(response), :errored]
7
+ elsif response['consoleOutput'].present?
8
+ [response['consoleOutput'], :passed]
9
+ elsif response['runtimeError'].present?
10
+ [response['runtimeError']['message'], :failed]
11
+ else
12
+ [response.to_s, :errored]
13
+ end
14
+ end
15
+
16
+ def program_type
17
+ 'wpgm'
18
+ end
19
+
20
+ def compile_program(r)
21
+ <<WLK
22
+ #{r.extra}
23
+ #{r.content}
24
+ object mumukiPrettyPrinter {
25
+ method prettyPrint(anObject) {
26
+ if (anObject != null && anObject != void)
27
+ console.println('=> ' + anObject.toString())
28
+ else
29
+ console.println('=>')
30
+ }
31
+ }
32
+
33
+ object mumukiConsole {
34
+ var inCookie = false
35
+
36
+ method enterCookie() { inCookie = true }
37
+ method exitCookie() { inCookie = false }
38
+
39
+ method println(anObject) {
40
+ if (!inCookie) {
41
+ console.println(anObject)
42
+ }
43
+ }
44
+ }
45
+
46
+ program mumuki {
47
+ mumukiConsole.enterCookie()
48
+ #{build_state(r.cookie)}
49
+ mumukiConsole.exitCookie()
50
+
51
+ #{
52
+ if %w(var const).any? { |it| r.query.strip.start_with? it }
53
+ "#{r.query}\nmumukiPrettyPrinter.prettyPrint(void)"
54
+ else
55
+ "mumukiPrettyPrinter.prettyPrint(#{r.query})"
56
+ end
57
+ }
58
+ }
59
+ WLK
60
+ end
61
+
62
+ def build_state(cookie)
63
+ (cookie||[]).map { |statement| "try { #{statement} } catch e : Exception { }" }.join("\n")
64
+ end
65
+ end
@@ -0,0 +1,39 @@
1
+ class WollokTestHook < WollokHook
2
+
3
+ def transform_response(result)
4
+ if errored? result
5
+ [extract_compilation_errors(result), :errored]
6
+ elsif result['tests'].present?
7
+ [result['tests'].map { |it| transform_test_result(it) }]
8
+ elsif result['runtimeErrors'].present?
9
+ [result['runtimeErrors'].to_s, :failed]
10
+ elsif result['consoleOutput'].present?
11
+ [result['consoleOutput'] || '', :failed]
12
+ else
13
+ [result.to_s, :errored]
14
+ end
15
+ end
16
+
17
+ def transform_test_result(result)
18
+ [result['name'], result['state'] == 'passed' ? :passed : :failed, result['error'].try{|i|i['stackTrace']}]
19
+ end
20
+
21
+ def program_type
22
+ 'wtest'
23
+ end
24
+
25
+ def compile_program(r)
26
+ <<WLK
27
+ object mumukiConsole {
28
+ method println(anObject) {
29
+ console.println(anObject)
30
+ }
31
+ }
32
+
33
+ #{r.extra}
34
+ #{r.content}
35
+ #{r.test}
36
+ WLK
37
+ end
38
+
39
+ end
@@ -0,0 +1,37 @@
1
+ class WollokHook < Mumukit::Hook
2
+
3
+ def run!(request)
4
+ transform_response JSON.pretty_parse(RestClient.post(server_path, request.to_json))
5
+ end
6
+
7
+ def compile(request)
8
+ {program: compile_program(request),
9
+ programType: program_type}
10
+ end
11
+
12
+ def server_path
13
+ 'http://server.wollok.org:8080/run'
14
+ end
15
+
16
+ def errored?(response)
17
+ response['compilation'] && response['compilation']['issues'].any? do |issue|
18
+ compilation_error? issue
19
+ end
20
+ end
21
+
22
+ def extract_compilation_errors(response)
23
+ response['compilation']['issues']
24
+ .select { |it| compilation_error? it }
25
+ .map { |it| transform_compilation_error(it) }
26
+ .join("\n")
27
+ end
28
+
29
+ def compilation_error?(issue)
30
+ %w(org.eclipse.xtext.diagnostics.Diagnostic.Syntax
31
+ org.eclipse.xtext.diagnostics.Diagnostic.Linking).include? issue['code']
32
+ end
33
+
34
+ def transform_compilation_error(issue)
35
+ "#{issue['severity']}: #{issue['message']}"
36
+ end
37
+ end
@@ -0,0 +1,11 @@
1
+ require 'mumukit'
2
+
3
+ Mumukit.runner_name = 'wollok'
4
+ Mumukit.configure do |config|
5
+ config.stateful = true
6
+ end
7
+
8
+ require_relative './wollok_hook'
9
+ require_relative './test_hook'
10
+ require_relative './query_hook'
11
+ require_relative './metadata_hook'
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mumuki-wollok-runner
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Franco Leonardo Bulgarelli
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mumukit
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '2.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '2.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '3.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '3.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: codeclimate-test-reporter
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: mumukit-bridge
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '1.3'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '1.3'
97
+ description:
98
+ email:
99
+ - franco@mumuki.org
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - lib/metadata_hook.rb
105
+ - lib/query_hook.rb
106
+ - lib/test_hook.rb
107
+ - lib/wollok_hook.rb
108
+ - lib/wollok_runner.rb
109
+ homepage: http://github.com/mumuki/mumuki-wollok-server
110
+ licenses:
111
+ - MIT
112
+ metadata: {}
113
+ post_install_message:
114
+ rdoc_options: []
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubyforge_project:
129
+ rubygems_version: 2.4.5
130
+ signing_key:
131
+ specification_version: 4
132
+ summary: Wollok Runner for Mumuki
133
+ test_files: []