mumuki-javascript-runner 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fc94e6c70639fa8dd93cc2d61a054600feb0fbce
4
+ data.tar.gz: c9b9c57b96e1010f10d94a63f8be4f8f64df9c49
5
+ SHA512:
6
+ metadata.gz: 86c11ebf2e5873bf7ef74e50ba2b2a1302ce28deb48d96b9a7bf23d03df6e4bfacb94af57b1d183b1a4e0997ea26d7ff88c37827b2084290a4bb8720a6870b97
7
+ data.tar.gz: 84228cd4585696df3f155815a617137b2565eeef7db92781f0bd14da3b76cf69d34a8a50262eb275deb8923df17bfd4571acdc3785454d0337b8d328bb0ee64a
@@ -0,0 +1,12 @@
1
+ require 'mumukit'
2
+
3
+ Mumukit.runner_name = 'javascript'
4
+ Mumukit.configure do |config|
5
+ config.docker_image = 'mumuki/mumuki-mocha-worker'
6
+ config.structured = true
7
+ config.stateful = true
8
+ end
9
+
10
+ require_relative './metadata_hook'
11
+ require_relative './test_hook'
12
+ require_relative './query_hook'
@@ -0,0 +1,16 @@
1
+ class JavascriptMetadataHook < Mumukit::Hook
2
+ def metadata
3
+ {language: {
4
+ name: 'javascript',
5
+ icon: {type: 'devicon', name: 'javascript'},
6
+ version: '4.2.4',
7
+ extension: 'js',
8
+ ace_mode: 'javascript_badge'
9
+ },
10
+ test_framework: {
11
+ name: 'mocha',
12
+ version: '2.4.5',
13
+ test_extension: '.js'
14
+ }}
15
+ end
16
+ end
@@ -0,0 +1,44 @@
1
+ class JavascriptQueryHook < Mumukit::Templates::FileHook
2
+ isolated true
3
+
4
+ def tempfile_extension
5
+ '.js'
6
+ end
7
+
8
+
9
+ def compile_file_content(r)
10
+ <<javascript
11
+ 'use strict';
12
+
13
+ function mumukiConsolePrettyPrint(e) {
14
+ if (e instanceof Function) return '<function>';
15
+ return JSON.stringify(e);
16
+ }
17
+
18
+ #{r.extra}
19
+
20
+ #{r.content}
21
+
22
+ #{compile_cookie(r.cookie)}
23
+
24
+ #{compile_query(r.query)}
25
+ javascript
26
+ end
27
+
28
+ def compile_query(query)
29
+ if query.start_with? 'var '
30
+ "#{query}\nconsole.log('=> undefined')"
31
+ else
32
+ "console.log('=> ' + mumukiConsolePrettyPrint(#{query}))"
33
+ end
34
+ end
35
+
36
+ def compile_cookie(cookie)
37
+ return if cookie.blank?
38
+ cookie.map { |query| "try { #{query} } catch (e) {}" }.join("\n")
39
+ end
40
+
41
+ def command_line(filename)
42
+ "node #{filename}"
43
+ end
44
+ end
@@ -0,0 +1,36 @@
1
+ class JavascriptTestHook < Mumukit::Templates::FileHook
2
+ isolated true
3
+ structured true
4
+
5
+ def compile_file_content(request)
6
+ <<javascript
7
+ 'use strict';
8
+
9
+ var assert = require('assert');
10
+
11
+ #{request.extra}
12
+ #{request.content}
13
+ #{request.test}
14
+ javascript
15
+ end
16
+
17
+ def tempfile_extension
18
+ '.js'
19
+ end
20
+
21
+ def command_line(filename)
22
+ "mocha #{filename} -R json"
23
+ end
24
+
25
+ def to_structured_result(result)
26
+ transform(super['tests'])
27
+ end
28
+
29
+ def transform(examples)
30
+ examples.map { |e| [e['fullTitle'], e['err'].present? ? :failed : :passed, parse_out(e['err'])] }
31
+ end
32
+
33
+ def parse_out(exception)
34
+ exception.present? ? exception['message'] : ''
35
+ end
36
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mumuki-javascript-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-27 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.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.5'
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/javascript_runner.rb
105
+ - lib/metadata_hook.rb
106
+ - lib/query_hook.rb
107
+ - lib/test_hook.rb
108
+ homepage: http://github.com/mumuki/mumuki-javascript-server
109
+ licenses:
110
+ - MIT
111
+ metadata: {}
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 2.4.8
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: Javascript Runner for Mumuki
132
+ test_files: []