mumuki-php-runner 1.0.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
+ SHA256:
3
+ metadata.gz: a8a44729b686db8ec1bee4e049aa6ed466e80a764c2d199c3cdc37c4c6c49fe0
4
+ data.tar.gz: 8ebe718ca780b84b09eccc38b5aba09ec751ac3462452c08a36b72e6309545c1
5
+ SHA512:
6
+ metadata.gz: b7cba2ac3824aacfd7bd82c346377f174ba6f77fab1415d05713ce3aaf9806d80d3696b39ab80b9b1f787d46613a750778f42ba614d075ff466d9bd871918a71
7
+ data.tar.gz: 0772718ef25c9fb8c98f2798127b6f2fe240083f71d7ca2c39e167d32cc7e5ca5e51730c7440dce303c51d24da64382db6bb643c3bd50479828ce4e5b4a25891
@@ -0,0 +1,23 @@
1
+ class PhpMetadataHook < Mumukit::Hook
2
+ def metadata
3
+ {
4
+ language: {
5
+ name: 'php',
6
+ icon: {type: 'devicon', name: 'php'},
7
+ version: 'v1.0.0',
8
+ extension: 'php',
9
+ ace_mode: 'php'
10
+ },
11
+ test_framework: {
12
+ name: 'phpunit',
13
+ version: '7',
14
+ test_extension: 'php',
15
+ template: <<php
16
+ public function testDescriptionExample(): void {
17
+ $this->assertTrue(true);
18
+ }
19
+ php
20
+ }
21
+ }
22
+ end
23
+ end
@@ -0,0 +1,7 @@
1
+ class PhpFileHook < Mumukit::Templates::FileHook
2
+ isolated true
3
+
4
+ def tempfile_extension
5
+ '.php'
6
+ end
7
+ end
data/lib/php_runner.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'mumukit'
2
+
3
+ Mumukit.runner_name = 'php'
4
+ Mumukit.configure do |config|
5
+ config.docker_image = 'mumuki/mumuki-php-worker:1.1'
6
+ end
7
+
8
+ require_relative './version'
9
+ require_relative './metadata_hook'
10
+ require_relative './php_file_hook'
11
+ require_relative './test_hook'
12
+ require_relative './query_hook'
data/lib/query_hook.rb ADDED
@@ -0,0 +1,15 @@
1
+ class PhpQueryHook < PhpFileHook
2
+ def command_line(filename)
3
+ "php #{filename}"
4
+ end
5
+
6
+ def compile_file_content(req)
7
+ <<EOF
8
+ <?php
9
+ #{req.extra}
10
+ #{req.content}
11
+
12
+ echo #{req.query};
13
+ EOF
14
+ end
15
+ end
data/lib/test_hook.rb ADDED
@@ -0,0 +1,53 @@
1
+ class PhpTestHook < PhpFileHook
2
+ structured true
3
+
4
+ TEST_NAME = 'AAAMumukiTestCaseAAA'
5
+ PASSED_REGEXP = /[✔☢] ([^\n]+)/
6
+ FAILED_REGEXP = /✘ ([^\n]+)\n *\│\n *│ ([^イ]+│ \n )/
7
+
8
+ def command_line(filename)
9
+ "phpunit --testdox #{filename}"
10
+ end
11
+
12
+ def post_process_file(file, result, status)
13
+ return [result.strip, :errored] unless result.include? TEST_NAME
14
+
15
+ super file, result, status
16
+ end
17
+
18
+ def to_structured_result(result)
19
+ passed_tests = result.scan(PASSED_REGEXP).map { |it| to_passed_result it }
20
+ failed_tests = result.scan(FAILED_REGEXP).map { |it| to_failed_result it }.uniq { |it| it.first }
21
+
22
+ passed_tests.concat(failed_tests)
23
+ end
24
+
25
+ def compile_file_content(req)
26
+ <<-EOF
27
+ <?php
28
+ declare(strict_types=1);
29
+
30
+ #{req.extra}
31
+ #{req.content}
32
+
33
+ use PHPUnit\\Framework\\TestCase;
34
+
35
+ final class #{TEST_NAME}Test extends TestCase {
36
+ #{req.test.lines.map {|it| ' ' + it}.join}
37
+ }
38
+ EOF
39
+ end
40
+
41
+ private
42
+
43
+ def to_passed_result(regexp_groups)
44
+ [regexp_groups.first, 'passed', '']
45
+ end
46
+
47
+ def to_failed_result(regexp_groups)
48
+ reason_lines = regexp_groups.last.split "\n"
49
+ reason = reason_lines.take(reason_lines.count - 2).join "\n"
50
+
51
+ [regexp_groups.first, 'failed', reason]
52
+ end
53
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module PhpVersionHook
2
+ VERSION = '1.0.0'
3
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mumuki-php-runner
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Rodrigo Alfonso
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-08-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.21'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.21'
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: '3.5'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.5'
97
+ description:
98
+ email:
99
+ - rodri042@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - lib/metadata_hook.rb
105
+ - lib/php_file_hook.rb
106
+ - lib/php_runner.rb
107
+ - lib/query_hook.rb
108
+ - lib/test_hook.rb
109
+ - lib/version.rb
110
+ homepage: http://github.com/mumuki/mumuki-php-runner
111
+ licenses:
112
+ - MIT
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 2.7.7
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: PHP Runner for Mumuki
134
+ test_files: []