coursemology-polyglot 0.2.2 → 0.2.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.
- checksums.yaml +4 -4
- data/.gitignore +17 -17
- data/.hound.yml +8 -8
- data/.idea/Coursemology Polyglot.iml +8 -8
- data/.rspec +2 -2
- data/.rubocop.unhound.yml +109 -109
- data/.rubocop.yml +46 -46
- data/.travis.yml +15 -15
- data/Gemfile +4 -4
- data/README.md +32 -32
- data/Rakefile +6 -6
- data/app/assets/javascripts/coursemology/polyglot/ace-modes.js.erb +5 -5
- data/coursemology-polyglot.gemspec +36 -36
- data/lib/coursemology/polyglot.rb +18 -18
- data/lib/coursemology/polyglot/concrete_language.rb +10 -10
- data/lib/coursemology/polyglot/concrete_language/class_methods.rb +30 -30
- data/lib/coursemology/polyglot/engine.rb +24 -24
- data/lib/coursemology/polyglot/language.rb +109 -109
- data/lib/coursemology/polyglot/language/java_script.rb +4 -4
- data/lib/coursemology/polyglot/language/python.rb +12 -12
- data/lib/coursemology/polyglot/version.rb +5 -5
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6e207a9e893f8bf92b666be1b4d6cd3417cb329e
|
|
4
|
+
data.tar.gz: ccb93478f60bbfe16fea0b6f0152a680ee011b57
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ddc6057c0d2df965a5ccb5f09ca76ece3c0f8a0f4c9b742e46eeaa217e8d662473c98cc39659aaaa522d72abd03294a16a9c96bc2e64af10617473459562e1d6
|
|
7
|
+
data.tar.gz: a2443ad850d1c4d2cdb4c041b5cb1404efe6a1187ec84b361097361af83c6a66140e8ebaf412bf3dcd76971f7848538593aabf78aaa70b27f17a47263d617978
|
data/.gitignore
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
|
2
|
-
#
|
|
3
|
-
# If you find yourself ignoring temporary files generated by your text editor
|
|
4
|
-
# or operating system, you probably want to add a global ignore instead:
|
|
5
|
-
# git config --global core.excludesfile '~/.gitignore_global'
|
|
6
|
-
|
|
7
|
-
# Ignore bundler config and gems.
|
|
8
|
-
/.bundle
|
|
9
|
-
/vendor/bundle
|
|
10
|
-
/Gemfile.lock
|
|
11
|
-
|
|
12
|
-
# Ignore generated code coverage information
|
|
13
|
-
/spec/coverage/*
|
|
14
|
-
/coverage/*
|
|
15
|
-
|
|
16
|
-
# Ignore RSpec state
|
|
17
|
-
/spec/examples.txt
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
|
2
|
+
#
|
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
|
5
|
+
# git config --global core.excludesfile '~/.gitignore_global'
|
|
6
|
+
|
|
7
|
+
# Ignore bundler config and gems.
|
|
8
|
+
/.bundle
|
|
9
|
+
/vendor/bundle
|
|
10
|
+
/Gemfile.lock
|
|
11
|
+
|
|
12
|
+
# Ignore generated code coverage information
|
|
13
|
+
/spec/coverage/*
|
|
14
|
+
/coverage/*
|
|
15
|
+
|
|
16
|
+
# Ignore RSpec state
|
|
17
|
+
/spec/examples.txt
|
data/.hound.yml
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
ruby:
|
|
2
|
-
config_file: .rubocop.yml
|
|
3
|
-
|
|
4
|
-
java_script:
|
|
5
|
-
config_file: .jshintrc
|
|
6
|
-
|
|
7
|
-
scss:
|
|
8
|
-
config_file: .scss-lint.yml
|
|
1
|
+
ruby:
|
|
2
|
+
config_file: .rubocop.yml
|
|
3
|
+
|
|
4
|
+
java_script:
|
|
5
|
+
config_file: .jshintrc
|
|
6
|
+
|
|
7
|
+
scss:
|
|
8
|
+
config_file: .scss-lint.yml
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<module type="RUBY_MODULE" version="4">
|
|
3
|
-
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
-
<exclude-output />
|
|
5
|
-
<content url="file://$MODULE_DIR$" />
|
|
6
|
-
<orderEntry type="inheritedJdk" />
|
|
7
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
|
8
|
-
</component>
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
4
|
+
<exclude-output />
|
|
5
|
+
<content url="file://$MODULE_DIR$" />
|
|
6
|
+
<orderEntry type="inheritedJdk" />
|
|
7
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
8
|
+
</component>
|
|
9
9
|
</module>
|
data/.rspec
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
--color
|
|
2
|
-
--require spec_helper
|
|
1
|
+
--color
|
|
2
|
+
--require spec_helper
|
data/.rubocop.unhound.yml
CHANGED
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
Style/CollectionMethods:
|
|
2
|
-
Enabled: true
|
|
3
|
-
PreferredMethods:
|
|
4
|
-
reduce:
|
|
5
|
-
inject: 'reduce'
|
|
6
|
-
find:
|
|
7
|
-
detect: 'find'
|
|
8
|
-
|
|
9
|
-
Style/FileName:
|
|
10
|
-
Enabled: true
|
|
11
|
-
|
|
12
|
-
Style/GuardClause:
|
|
13
|
-
Enabled: true
|
|
14
|
-
|
|
15
|
-
Style/IfUnlessModifier:
|
|
16
|
-
Enabled: true
|
|
17
|
-
|
|
18
|
-
Style/PercentLiteralDelimiters:
|
|
19
|
-
Enabled: true
|
|
20
|
-
|
|
21
|
-
Style/SignalException:
|
|
22
|
-
Enabled: true
|
|
23
|
-
|
|
24
|
-
Style/SingleLineBlockParams:
|
|
25
|
-
Enabled: true
|
|
26
|
-
|
|
27
|
-
Style/SingleLineMethods:
|
|
28
|
-
Enabled: true
|
|
29
|
-
|
|
30
|
-
Style/TrailingCommaInArguments:
|
|
31
|
-
Enabled: true
|
|
32
|
-
|
|
33
|
-
Style/TrailingCommaInLiteral:
|
|
34
|
-
Enabled: true
|
|
35
|
-
|
|
36
|
-
Metrics/AbcSize:
|
|
37
|
-
Enabled: true
|
|
38
|
-
|
|
39
|
-
Metrics/ClassLength:
|
|
40
|
-
Enabled: true
|
|
41
|
-
|
|
42
|
-
Metrics/ModuleLength:
|
|
43
|
-
Enabled: true
|
|
44
|
-
|
|
45
|
-
Metrics/CyclomaticComplexity:
|
|
46
|
-
Enabled: true
|
|
47
|
-
|
|
48
|
-
Metrics/MethodLength:
|
|
49
|
-
Enabled: true
|
|
50
|
-
|
|
51
|
-
Metrics/ParameterLists:
|
|
52
|
-
Enabled: true
|
|
53
|
-
|
|
54
|
-
Metrics/PerceivedComplexity:
|
|
55
|
-
Enabled: true
|
|
56
|
-
|
|
57
|
-
Lint/AssignmentInCondition:
|
|
58
|
-
Enabled: true
|
|
59
|
-
|
|
60
|
-
Style/AccessorMethodName:
|
|
61
|
-
Enabled: true
|
|
62
|
-
|
|
63
|
-
Style/Alias:
|
|
64
|
-
Enabled: true
|
|
65
|
-
EnforcedStyle: prefer_alias_method
|
|
66
|
-
|
|
67
|
-
Style/Documentation:
|
|
68
|
-
Enabled: true
|
|
69
|
-
|
|
70
|
-
Style/DoubleNegation:
|
|
71
|
-
Enabled: true
|
|
72
|
-
|
|
73
|
-
Style/EachWithObject:
|
|
74
|
-
Enabled: true
|
|
75
|
-
|
|
76
|
-
Style/EmptyLiteral:
|
|
77
|
-
Enabled: true
|
|
78
|
-
|
|
79
|
-
Style/ModuleFunction:
|
|
80
|
-
Enabled: true
|
|
81
|
-
|
|
82
|
-
Style/OneLineConditional:
|
|
83
|
-
Enabled: true
|
|
84
|
-
|
|
85
|
-
Style/PerlBackrefs:
|
|
86
|
-
Enabled: true
|
|
87
|
-
|
|
88
|
-
Style/SpecialGlobalVars:
|
|
89
|
-
Enabled: true
|
|
90
|
-
|
|
91
|
-
Style/VariableInterpolation:
|
|
92
|
-
Enabled: true
|
|
93
|
-
|
|
94
|
-
Style/WhenThen:
|
|
95
|
-
Enabled: true
|
|
96
|
-
|
|
97
|
-
Lint/EachWithObjectArgument:
|
|
98
|
-
Enabled: true
|
|
99
|
-
|
|
100
|
-
Lint/HandleExceptions:
|
|
101
|
-
Enabled: true
|
|
102
|
-
|
|
103
|
-
Lint/LiteralInCondition:
|
|
104
|
-
Description: Checks of literals used in conditions.
|
|
105
|
-
Enabled: true
|
|
106
|
-
|
|
107
|
-
Lint/LiteralInInterpolation:
|
|
108
|
-
Description: Checks for literals used in interpolation.
|
|
109
|
-
Enabled: true
|
|
1
|
+
Style/CollectionMethods:
|
|
2
|
+
Enabled: true
|
|
3
|
+
PreferredMethods:
|
|
4
|
+
reduce:
|
|
5
|
+
inject: 'reduce'
|
|
6
|
+
find:
|
|
7
|
+
detect: 'find'
|
|
8
|
+
|
|
9
|
+
Style/FileName:
|
|
10
|
+
Enabled: true
|
|
11
|
+
|
|
12
|
+
Style/GuardClause:
|
|
13
|
+
Enabled: true
|
|
14
|
+
|
|
15
|
+
Style/IfUnlessModifier:
|
|
16
|
+
Enabled: true
|
|
17
|
+
|
|
18
|
+
Style/PercentLiteralDelimiters:
|
|
19
|
+
Enabled: true
|
|
20
|
+
|
|
21
|
+
Style/SignalException:
|
|
22
|
+
Enabled: true
|
|
23
|
+
|
|
24
|
+
Style/SingleLineBlockParams:
|
|
25
|
+
Enabled: true
|
|
26
|
+
|
|
27
|
+
Style/SingleLineMethods:
|
|
28
|
+
Enabled: true
|
|
29
|
+
|
|
30
|
+
Style/TrailingCommaInArguments:
|
|
31
|
+
Enabled: true
|
|
32
|
+
|
|
33
|
+
Style/TrailingCommaInLiteral:
|
|
34
|
+
Enabled: true
|
|
35
|
+
|
|
36
|
+
Metrics/AbcSize:
|
|
37
|
+
Enabled: true
|
|
38
|
+
|
|
39
|
+
Metrics/ClassLength:
|
|
40
|
+
Enabled: true
|
|
41
|
+
|
|
42
|
+
Metrics/ModuleLength:
|
|
43
|
+
Enabled: true
|
|
44
|
+
|
|
45
|
+
Metrics/CyclomaticComplexity:
|
|
46
|
+
Enabled: true
|
|
47
|
+
|
|
48
|
+
Metrics/MethodLength:
|
|
49
|
+
Enabled: true
|
|
50
|
+
|
|
51
|
+
Metrics/ParameterLists:
|
|
52
|
+
Enabled: true
|
|
53
|
+
|
|
54
|
+
Metrics/PerceivedComplexity:
|
|
55
|
+
Enabled: true
|
|
56
|
+
|
|
57
|
+
Lint/AssignmentInCondition:
|
|
58
|
+
Enabled: true
|
|
59
|
+
|
|
60
|
+
Style/AccessorMethodName:
|
|
61
|
+
Enabled: true
|
|
62
|
+
|
|
63
|
+
Style/Alias:
|
|
64
|
+
Enabled: true
|
|
65
|
+
EnforcedStyle: prefer_alias_method
|
|
66
|
+
|
|
67
|
+
Style/Documentation:
|
|
68
|
+
Enabled: true
|
|
69
|
+
|
|
70
|
+
Style/DoubleNegation:
|
|
71
|
+
Enabled: true
|
|
72
|
+
|
|
73
|
+
Style/EachWithObject:
|
|
74
|
+
Enabled: true
|
|
75
|
+
|
|
76
|
+
Style/EmptyLiteral:
|
|
77
|
+
Enabled: true
|
|
78
|
+
|
|
79
|
+
Style/ModuleFunction:
|
|
80
|
+
Enabled: true
|
|
81
|
+
|
|
82
|
+
Style/OneLineConditional:
|
|
83
|
+
Enabled: true
|
|
84
|
+
|
|
85
|
+
Style/PerlBackrefs:
|
|
86
|
+
Enabled: true
|
|
87
|
+
|
|
88
|
+
Style/SpecialGlobalVars:
|
|
89
|
+
Enabled: true
|
|
90
|
+
|
|
91
|
+
Style/VariableInterpolation:
|
|
92
|
+
Enabled: true
|
|
93
|
+
|
|
94
|
+
Style/WhenThen:
|
|
95
|
+
Enabled: true
|
|
96
|
+
|
|
97
|
+
Lint/EachWithObjectArgument:
|
|
98
|
+
Enabled: true
|
|
99
|
+
|
|
100
|
+
Lint/HandleExceptions:
|
|
101
|
+
Enabled: true
|
|
102
|
+
|
|
103
|
+
Lint/LiteralInCondition:
|
|
104
|
+
Description: Checks of literals used in conditions.
|
|
105
|
+
Enabled: true
|
|
106
|
+
|
|
107
|
+
Lint/LiteralInInterpolation:
|
|
108
|
+
Description: Checks for literals used in interpolation.
|
|
109
|
+
Enabled: true
|
data/.rubocop.yml
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
inherit_from:
|
|
2
|
-
- .rubocop.unhound.yml
|
|
3
|
-
|
|
4
|
-
AllCops:
|
|
5
|
-
Include:
|
|
6
|
-
- '**/Gemfile'
|
|
7
|
-
- '**/Rakefile'
|
|
8
|
-
Exclude:
|
|
9
|
-
- 'vendor/bundle/**/*'
|
|
10
|
-
TargetRubyVersion: 2.1
|
|
11
|
-
|
|
12
|
-
Metrics/LineLength:
|
|
13
|
-
Max: 100
|
|
14
|
-
|
|
15
|
-
Style/ClassAndModuleChildren:
|
|
16
|
-
EnforcedStyle: compact
|
|
17
|
-
|
|
18
|
-
Style/DotPosition:
|
|
19
|
-
EnforcedStyle: trailing
|
|
20
|
-
|
|
21
|
-
Style/Documentation:
|
|
22
|
-
Enabled: false
|
|
23
|
-
|
|
24
|
-
Style/IndentHash:
|
|
25
|
-
EnforcedStyle: consistent
|
|
26
|
-
|
|
27
|
-
Style/IfUnlessModifier:
|
|
28
|
-
MaxLineLength: 100
|
|
29
|
-
|
|
30
|
-
Style/ParallelAssignment:
|
|
31
|
-
Enabled: false
|
|
32
|
-
|
|
33
|
-
Style/StringLiterals:
|
|
34
|
-
EnforcedStyle: single_quotes
|
|
35
|
-
|
|
36
|
-
Style/WhileUntilModifier:
|
|
37
|
-
MaxLineLength: 100
|
|
38
|
-
|
|
39
|
-
Style/WordArray:
|
|
40
|
-
Enabled: false
|
|
41
|
-
|
|
42
|
-
Style/RegexpLiteral:
|
|
43
|
-
AllowInnerSlashes: true
|
|
44
|
-
|
|
45
|
-
Style/ClassAndModuleChildren:
|
|
46
|
-
EnforcedStyle: compact
|
|
1
|
+
inherit_from:
|
|
2
|
+
- .rubocop.unhound.yml
|
|
3
|
+
|
|
4
|
+
AllCops:
|
|
5
|
+
Include:
|
|
6
|
+
- '**/Gemfile'
|
|
7
|
+
- '**/Rakefile'
|
|
8
|
+
Exclude:
|
|
9
|
+
- 'vendor/bundle/**/*'
|
|
10
|
+
TargetRubyVersion: 2.1
|
|
11
|
+
|
|
12
|
+
Metrics/LineLength:
|
|
13
|
+
Max: 100
|
|
14
|
+
|
|
15
|
+
Style/ClassAndModuleChildren:
|
|
16
|
+
EnforcedStyle: compact
|
|
17
|
+
|
|
18
|
+
Style/DotPosition:
|
|
19
|
+
EnforcedStyle: trailing
|
|
20
|
+
|
|
21
|
+
Style/Documentation:
|
|
22
|
+
Enabled: false
|
|
23
|
+
|
|
24
|
+
Style/IndentHash:
|
|
25
|
+
EnforcedStyle: consistent
|
|
26
|
+
|
|
27
|
+
Style/IfUnlessModifier:
|
|
28
|
+
MaxLineLength: 100
|
|
29
|
+
|
|
30
|
+
Style/ParallelAssignment:
|
|
31
|
+
Enabled: false
|
|
32
|
+
|
|
33
|
+
Style/StringLiterals:
|
|
34
|
+
EnforcedStyle: single_quotes
|
|
35
|
+
|
|
36
|
+
Style/WhileUntilModifier:
|
|
37
|
+
MaxLineLength: 100
|
|
38
|
+
|
|
39
|
+
Style/WordArray:
|
|
40
|
+
Enabled: false
|
|
41
|
+
|
|
42
|
+
Style/RegexpLiteral:
|
|
43
|
+
AllowInnerSlashes: true
|
|
44
|
+
|
|
45
|
+
Style/ClassAndModuleChildren:
|
|
46
|
+
EnforcedStyle: compact
|
data/.travis.yml
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
sudo: false
|
|
2
|
-
language: ruby
|
|
3
|
-
rvm:
|
|
4
|
-
- 2.1.8
|
|
5
|
-
- 2.2.4
|
|
6
|
-
- 2.3.0
|
|
7
|
-
- ruby-head
|
|
8
|
-
matrix:
|
|
9
|
-
allow_failures:
|
|
10
|
-
- rvm: ruby-head
|
|
11
|
-
bundler_args: "--jobs=3 --retry=3"
|
|
12
|
-
cache: bundler
|
|
13
|
-
|
|
14
|
-
before_install:
|
|
15
|
-
- gem update bundler
|
|
1
|
+
sudo: false
|
|
2
|
+
language: ruby
|
|
3
|
+
rvm:
|
|
4
|
+
- 2.1.8
|
|
5
|
+
- 2.2.4
|
|
6
|
+
- 2.3.0
|
|
7
|
+
- ruby-head
|
|
8
|
+
matrix:
|
|
9
|
+
allow_failures:
|
|
10
|
+
- rvm: ruby-head
|
|
11
|
+
bundler_args: "--jobs=3 --retry=3"
|
|
12
|
+
cache: bundler
|
|
13
|
+
|
|
14
|
+
before_install:
|
|
15
|
+
- gem update bundler
|
data/Gemfile
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
|
|
3
|
-
# Specify your gem's dependencies in coursemology-polyglot.gemspec
|
|
4
|
-
gemspec
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
# Specify your gem's dependencies in coursemology-polyglot.gemspec
|
|
4
|
+
gemspec
|
data/README.md
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
# Coursemology Polyglot [](https://travis-ci.org/Coursemology/polyglot)
|
|
2
|
-
[](https://codeclimate.com/github/Coursemology/polyglot) [](https://coveralls.io/github/Coursemology/polyglot?branch=master) [](https://hakiri.io/github/Coursemology/polyglot/master) [](http://inch-ci.org/github/coursemology/polyglot) [](https://badge.fury.io/rb/coursemology-polyglot)
|
|
3
|
-
|
|
4
|
-
This is the library common between the web application and the evaluator for determining the
|
|
5
|
-
programming languages supported in Coursemology.
|
|
6
|
-
|
|
7
|
-
## Usage
|
|
8
|
-
### With Rails
|
|
9
|
-
The library works with Railties, so there is no special configuration.
|
|
10
|
-
|
|
11
|
-
The gem provides a JavaScript asset which can be used to require all Ace modes that are needed by
|
|
12
|
-
all concrete languages. In your application manifest, include this:
|
|
13
|
-
|
|
14
|
-
```javascript
|
|
15
|
-
//= require coursemology/polyglot/ace-modes
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
Ensure that Ace is found within the `ace` directory (i.e. `ace/mode-python.js` etc.)
|
|
19
|
-
|
|
20
|
-
### Without Rails
|
|
21
|
-
In your `Gemfile`:
|
|
22
|
-
```ruby
|
|
23
|
-
gem 'coursemology-polyglot'
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
Then, in your application:
|
|
27
|
-
```ruby
|
|
28
|
-
Coursemology::Polyglot.eager_load!
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
The Polyglot library needs to be eager loaded so that it knows which languages are defined.
|
|
32
|
-
Otherwise, the list of `concrete_languages` will be empty.
|
|
1
|
+
# Coursemology Polyglot [](https://travis-ci.org/Coursemology/polyglot)
|
|
2
|
+
[](https://codeclimate.com/github/Coursemology/polyglot) [](https://coveralls.io/github/Coursemology/polyglot?branch=master) [](https://hakiri.io/github/Coursemology/polyglot/master) [](http://inch-ci.org/github/coursemology/polyglot) [](https://badge.fury.io/rb/coursemology-polyglot)
|
|
3
|
+
|
|
4
|
+
This is the library common between the web application and the evaluator for determining the
|
|
5
|
+
programming languages supported in Coursemology.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
### With Rails
|
|
9
|
+
The library works with Railties, so there is no special configuration.
|
|
10
|
+
|
|
11
|
+
The gem provides a JavaScript asset which can be used to require all Ace modes that are needed by
|
|
12
|
+
all concrete languages. In your application manifest, include this:
|
|
13
|
+
|
|
14
|
+
```javascript
|
|
15
|
+
//= require coursemology/polyglot/ace-modes
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Ensure that Ace is found within the `ace` directory (i.e. `ace/mode-python.js` etc.)
|
|
19
|
+
|
|
20
|
+
### Without Rails
|
|
21
|
+
In your `Gemfile`:
|
|
22
|
+
```ruby
|
|
23
|
+
gem 'coursemology-polyglot'
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Then, in your application:
|
|
27
|
+
```ruby
|
|
28
|
+
Coursemology::Polyglot.eager_load!
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The Polyglot library needs to be eager loaded so that it knows which languages are defined.
|
|
32
|
+
Otherwise, the list of `concrete_languages` will be empty.
|
data/Rakefile
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
require 'bundler/gem_tasks'
|
|
2
|
-
require 'rspec/core/rake_task'
|
|
3
|
-
|
|
4
|
-
RSpec::Core::RakeTask.new(:spec)
|
|
5
|
-
|
|
6
|
-
task default: :spec
|
|
1
|
+
require 'bundler/gem_tasks'
|
|
2
|
+
require 'rspec/core/rake_task'
|
|
3
|
+
|
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
5
|
+
|
|
6
|
+
task default: :spec
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<%
|
|
2
|
-
Coursemology::Polyglot::Language.concrete_languages.map(&:ace_mode).uniq.each do |ace_mode|
|
|
3
|
-
require_asset "ace/mode-#{ace_mode}"
|
|
4
|
-
end
|
|
5
|
-
%>
|
|
1
|
+
<%
|
|
2
|
+
Coursemology::Polyglot::Language.concrete_languages.map(&:ace_mode).uniq.each do |ace_mode|
|
|
3
|
+
require_asset "ace/mode-#{ace_mode}"
|
|
4
|
+
end
|
|
5
|
+
%>
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
# coding: utf-8
|
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
-
require 'coursemology/polyglot/version'
|
|
5
|
-
|
|
6
|
-
Gem::Specification.new do |spec|
|
|
7
|
-
spec.name = 'coursemology-polyglot'
|
|
8
|
-
spec.version = Coursemology::Polyglot::VERSION
|
|
9
|
-
spec.authors = ['Joel Low']
|
|
10
|
-
spec.email = ['joel@joelsplace.sg']
|
|
11
|
-
spec.license = 'MIT'
|
|
12
|
-
|
|
13
|
-
spec.summary = 'Coursemology polyglot definitions'
|
|
14
|
-
spec.description = <<-DESC
|
|
15
|
-
Common definitions shared between the web application and the evaluator for determining the
|
|
16
|
-
programming languages supported in Coursemology.
|
|
17
|
-
DESC
|
|
18
|
-
spec.homepage = 'https://github.com/Coursemology/polyglot'
|
|
19
|
-
spec.files = `git ls-files -z`.split("\x0").
|
|
20
|
-
reject { |f| f.match(/^(test|spec|features)\//) }
|
|
21
|
-
spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
|
|
22
|
-
spec.require_paths = ['lib']
|
|
23
|
-
|
|
24
|
-
spec.add_development_dependency 'bundler'
|
|
25
|
-
spec.add_development_dependency 'rake'
|
|
26
|
-
spec.add_development_dependency 'rspec'
|
|
27
|
-
spec.add_development_dependency 'simplecov'
|
|
28
|
-
spec.add_development_dependency 'coveralls'
|
|
29
|
-
spec.add_development_dependency 'codeclimate-test-reporter'
|
|
30
|
-
|
|
31
|
-
spec.add_dependency 'activesupport', '~> 4.2.0', '>= 4.2.2'
|
|
32
|
-
|
|
33
|
-
# For autoloading in Rails applications, as well as the Ace modes inclusion. Keep this as the
|
|
34
|
-
# same as ActiveSupport version.
|
|
35
|
-
spec.add_development_dependency 'railties', '~> 4.2.0', '>= 4.2.2'
|
|
36
|
-
end
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'coursemology/polyglot/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = 'coursemology-polyglot'
|
|
8
|
+
spec.version = Coursemology::Polyglot::VERSION
|
|
9
|
+
spec.authors = ['Joel Low']
|
|
10
|
+
spec.email = ['joel@joelsplace.sg']
|
|
11
|
+
spec.license = 'MIT'
|
|
12
|
+
|
|
13
|
+
spec.summary = 'Coursemology polyglot definitions'
|
|
14
|
+
spec.description = <<-DESC
|
|
15
|
+
Common definitions shared between the web application and the evaluator for determining the
|
|
16
|
+
programming languages supported in Coursemology.
|
|
17
|
+
DESC
|
|
18
|
+
spec.homepage = 'https://github.com/Coursemology/polyglot'
|
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").
|
|
20
|
+
reject { |f| f.match(/^(test|spec|features)\//) }
|
|
21
|
+
spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
|
|
22
|
+
spec.require_paths = ['lib']
|
|
23
|
+
|
|
24
|
+
spec.add_development_dependency 'bundler'
|
|
25
|
+
spec.add_development_dependency 'rake'
|
|
26
|
+
spec.add_development_dependency 'rspec'
|
|
27
|
+
spec.add_development_dependency 'simplecov'
|
|
28
|
+
spec.add_development_dependency 'coveralls'
|
|
29
|
+
spec.add_development_dependency 'codeclimate-test-reporter'
|
|
30
|
+
|
|
31
|
+
spec.add_dependency 'activesupport', '~> 4.2.0', '>= 4.2.2'
|
|
32
|
+
|
|
33
|
+
# For autoloading in Rails applications, as well as the Ace modes inclusion. Keep this as the
|
|
34
|
+
# same as ActiveSupport version.
|
|
35
|
+
spec.add_development_dependency 'railties', '~> 4.2.0', '>= 4.2.2'
|
|
36
|
+
end
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
require 'active_support/all'
|
|
3
|
-
require 'coursemology/polyglot/version'
|
|
4
|
-
require 'coursemology/polyglot/engine' if defined?(Rails)
|
|
5
|
-
|
|
6
|
-
module Coursemology::Polyglot
|
|
7
|
-
extend ActiveSupport::Autoload
|
|
8
|
-
|
|
9
|
-
eager_autoload do
|
|
10
|
-
autoload :Language
|
|
11
|
-
autoload :ConcreteLanguage
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def self.eager_load!
|
|
15
|
-
super
|
|
16
|
-
Coursemology::Polyglot::Language.eager_load!
|
|
17
|
-
end
|
|
18
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'active_support/all'
|
|
3
|
+
require 'coursemology/polyglot/version'
|
|
4
|
+
require 'coursemology/polyglot/engine' if defined?(Rails)
|
|
5
|
+
|
|
6
|
+
module Coursemology::Polyglot
|
|
7
|
+
extend ActiveSupport::Autoload
|
|
8
|
+
|
|
9
|
+
eager_autoload do
|
|
10
|
+
autoload :Language
|
|
11
|
+
autoload :ConcreteLanguage
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.eager_load!
|
|
15
|
+
super
|
|
16
|
+
Coursemology::Polyglot::Language.eager_load!
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
# This module is included when a Language can be directly used by the user.
|
|
3
|
-
#
|
|
4
|
-
# This is deliberately defined so that consumers of this library can inject methods into all
|
|
5
|
-
# concrete languages.
|
|
6
|
-
module Coursemology::Polyglot::ConcreteLanguage
|
|
7
|
-
extend ActiveSupport::Autoload
|
|
8
|
-
|
|
9
|
-
autoload :ClassMethods
|
|
10
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# This module is included when a Language can be directly used by the user.
|
|
3
|
+
#
|
|
4
|
+
# This is deliberately defined so that consumers of this library can inject methods into all
|
|
5
|
+
# concrete languages.
|
|
6
|
+
module Coursemology::Polyglot::ConcreteLanguage
|
|
7
|
+
extend ActiveSupport::Autoload
|
|
8
|
+
|
|
9
|
+
autoload :ClassMethods
|
|
10
|
+
end
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
# This module is extended by the language's singleton class when the Language can be directly used
|
|
3
|
-
# by the user.
|
|
4
|
-
#
|
|
5
|
-
# This is deliberately defined so that consumers of this library can inject methods into all
|
|
6
|
-
# concrete languages' classes.
|
|
7
|
-
module Coursemology::Polyglot::ConcreteLanguage::ClassMethods
|
|
8
|
-
# The default algorithm for translating a language to a corresponding Docker image name.
|
|
9
|
-
#
|
|
10
|
-
# This will:
|
|
11
|
-
# 1. Strip the +Coursemology::Polyglot::Language+ prefix.
|
|
12
|
-
# 2. Underscore the name.
|
|
13
|
-
# 3. Replace *n*Point*n* strings with dots (e.g. Python2Point7 to Python2.7).
|
|
14
|
-
# 4. Replace slashes with dashes.
|
|
15
|
-
def docker_image
|
|
16
|
-
# Remove the Coursemology::Polyglot::Language prefix
|
|
17
|
-
class_name = name
|
|
18
|
-
class_name = class_name.sub(/^Coursemology::Polyglot::Language::/, '')
|
|
19
|
-
|
|
20
|
-
# Use the underscored name
|
|
21
|
-
class_name = class_name.underscore
|
|
22
|
-
|
|
23
|
-
# Replace the "_point" string with a decimal
|
|
24
|
-
class_name.gsub!(/(?<=[\d])_point(?=[\d])/, '.')
|
|
25
|
-
|
|
26
|
-
# Replace slashes with dashes
|
|
27
|
-
class_name.tr!('/', '-')
|
|
28
|
-
class_name
|
|
29
|
-
end
|
|
30
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# This module is extended by the language's singleton class when the Language can be directly used
|
|
3
|
+
# by the user.
|
|
4
|
+
#
|
|
5
|
+
# This is deliberately defined so that consumers of this library can inject methods into all
|
|
6
|
+
# concrete languages' classes.
|
|
7
|
+
module Coursemology::Polyglot::ConcreteLanguage::ClassMethods
|
|
8
|
+
# The default algorithm for translating a language to a corresponding Docker image name.
|
|
9
|
+
#
|
|
10
|
+
# This will:
|
|
11
|
+
# 1. Strip the +Coursemology::Polyglot::Language+ prefix.
|
|
12
|
+
# 2. Underscore the name.
|
|
13
|
+
# 3. Replace *n*Point*n* strings with dots (e.g. Python2Point7 to Python2.7).
|
|
14
|
+
# 4. Replace slashes with dashes.
|
|
15
|
+
def docker_image
|
|
16
|
+
# Remove the Coursemology::Polyglot::Language prefix
|
|
17
|
+
class_name = name
|
|
18
|
+
class_name = class_name.sub(/^Coursemology::Polyglot::Language::/, '')
|
|
19
|
+
|
|
20
|
+
# Use the underscored name
|
|
21
|
+
class_name = class_name.underscore
|
|
22
|
+
|
|
23
|
+
# Replace the "_point" string with a decimal
|
|
24
|
+
class_name.gsub!(/(?<=[\d])_point(?=[\d])/, '.')
|
|
25
|
+
|
|
26
|
+
# Replace slashes with dashes
|
|
27
|
+
class_name.tr!('/', '-')
|
|
28
|
+
class_name
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
class Coursemology::Polyglot::Engine < Rails::Engine
|
|
3
|
-
def self.eager_load!
|
|
4
|
-
super
|
|
5
|
-
Coursemology::Polyglot.eager_load!
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
# :nocov:
|
|
9
|
-
# These are Railties callbacks, which we can't trigger in specs specifically.
|
|
10
|
-
def self.initialize_engine(_)
|
|
11
|
-
Coursemology::Polyglot::Language.eager_load!
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def self.after_initialize(_)
|
|
15
|
-
return if !Coursemology::Polyglot::Language.connected? ||
|
|
16
|
-
!Coursemology::Polyglot::Language.table_exists?
|
|
17
|
-
|
|
18
|
-
Coursemology::Polyglot::Language.load_languages
|
|
19
|
-
end
|
|
20
|
-
# :nocov:
|
|
21
|
-
|
|
22
|
-
initializer('coursemology.polyglot', &method(:initialize_engine))
|
|
23
|
-
config.after_initialize(&method(:after_initialize))
|
|
24
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
class Coursemology::Polyglot::Engine < Rails::Engine
|
|
3
|
+
def self.eager_load!
|
|
4
|
+
super
|
|
5
|
+
Coursemology::Polyglot.eager_load!
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# :nocov:
|
|
9
|
+
# These are Railties callbacks, which we can't trigger in specs specifically.
|
|
10
|
+
def self.initialize_engine(_)
|
|
11
|
+
Coursemology::Polyglot::Language.eager_load!
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.after_initialize(_)
|
|
15
|
+
return if !Coursemology::Polyglot::Language.connected? ||
|
|
16
|
+
!Coursemology::Polyglot::Language.table_exists?
|
|
17
|
+
|
|
18
|
+
Coursemology::Polyglot::Language.load_languages
|
|
19
|
+
end
|
|
20
|
+
# :nocov:
|
|
21
|
+
|
|
22
|
+
initializer('coursemology.polyglot', &method(:initialize_engine))
|
|
23
|
+
config.after_initialize(&method(:after_initialize))
|
|
24
|
+
end
|
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
if defined?(ActiveRecord)
|
|
3
|
-
# :nocov:
|
|
4
|
-
# TODO: This is for compatibility with the Web application. A future refactoring might be able
|
|
5
|
-
# to remove this dependency.
|
|
6
|
-
class Coursemology::Polyglot::Language < ActiveRecord::Base; end
|
|
7
|
-
# :nocov:
|
|
8
|
-
else
|
|
9
|
-
class Coursemology::Polyglot::Language; end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
# An abstract language. This is a class which can represent a family of languages. Languages become
|
|
13
|
-
# concrete and can be used when that language includes +Coursemology::Polyglot::ConcreteLanguage+.
|
|
14
|
-
#
|
|
15
|
-
# Languages define their own scripts and stylesheets needed to syntax highlight code.
|
|
16
|
-
#
|
|
17
|
-
# Each subclass represents a language ancestry, such as differing language versions (see the Python
|
|
18
|
-
# language definition.) Derived languages can be defined at runtime to utilise the syntax
|
|
19
|
-
# highlighting capabilities of the root language, while requiring a separate runtime environment to
|
|
20
|
-
# run programs written in the derived language.
|
|
21
|
-
#
|
|
22
|
-
# Do *NOT* remove languages after they have been defined because the types specified in this
|
|
23
|
-
# library can have references stored in code (e.g. in a database)
|
|
24
|
-
class Coursemology::Polyglot::Language
|
|
25
|
-
extend ActiveSupport::Autoload
|
|
26
|
-
|
|
27
|
-
eager_autoload do
|
|
28
|
-
autoload :Python
|
|
29
|
-
autoload :JavaScript
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
# Marks the current class as a concrete language.
|
|
33
|
-
#
|
|
34
|
-
# Concrete languages can be instantiated and used.
|
|
35
|
-
#
|
|
36
|
-
# @param [String] display_name The display name for the language
|
|
37
|
-
# @param [String] docker_image The Docker image to use for the given language. This defaults to
|
|
38
|
-
# the string generated by +Coursemology::Polyglot::ConcreteLanguage.docker_image+.
|
|
39
|
-
def self.concrete_language(display_name, docker_image: nil)
|
|
40
|
-
include Coursemology::Polyglot::ConcreteLanguage
|
|
41
|
-
extend Coursemology::Polyglot::ConcreteLanguage::ClassMethods
|
|
42
|
-
|
|
43
|
-
concrete_class_methods = Module.new do
|
|
44
|
-
define_method(:display_name) { display_name }
|
|
45
|
-
define_method(:docker_image) { docker_image } if docker_image
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
extend concrete_class_methods
|
|
49
|
-
end
|
|
50
|
-
private_class_method :concrete_language
|
|
51
|
-
|
|
52
|
-
# Determines the concrete language subclasses of this language.
|
|
53
|
-
#
|
|
54
|
-
# @return [Array<Class>]
|
|
55
|
-
def self.concrete_languages
|
|
56
|
-
descendants.select do |klass|
|
|
57
|
-
klass.ancestors.include?(Coursemology::Polyglot::ConcreteLanguage)
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
# The name of the lexer or mode to use with a given library. This is inherited by classes.
|
|
62
|
-
#
|
|
63
|
-
# @param [String|nil] default The default lexer/mode to use for each library.
|
|
64
|
-
# @param [String] rouge The overridden lexer to use for Rouge. This is optional and will
|
|
65
|
-
# default to +default+
|
|
66
|
-
# @param [String] ace The overridden mode to use for Ace. This is optional and will
|
|
67
|
-
# default to +default+
|
|
68
|
-
# @raise [ArgumentError] When no default is specified and the Rouge lexer or Ace mode is not
|
|
69
|
-
# specified.
|
|
70
|
-
def self.syntax_highlighter(default = nil, rouge: default, ace: default)
|
|
71
|
-
fail ArgumentError unless rouge && ace
|
|
72
|
-
|
|
73
|
-
syntax_highlighter_class_methods = Module.new do
|
|
74
|
-
define_method(:rouge_lexer) { rouge }
|
|
75
|
-
define_method(:ace_mode) { ace }
|
|
76
|
-
end
|
|
77
|
-
extend syntax_highlighter_class_methods
|
|
78
|
-
|
|
79
|
-
syntax_highlighter_instance_methods = Module.new do
|
|
80
|
-
delegate :rouge_lexer, :ace_mode, to: :class
|
|
81
|
-
end
|
|
82
|
-
include syntax_highlighter_instance_methods
|
|
83
|
-
end
|
|
84
|
-
private_class_method :syntax_highlighter
|
|
85
|
-
|
|
86
|
-
# Gets the display name of the language.
|
|
87
|
-
#
|
|
88
|
-
# @abstract
|
|
89
|
-
# @return [String]
|
|
90
|
-
def self.display_name
|
|
91
|
-
fail NotImplementedError
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
# The Rouge lexer to use with this language.
|
|
95
|
-
#
|
|
96
|
-
# @abstract
|
|
97
|
-
# @return [String]
|
|
98
|
-
def self.rouge_lexer
|
|
99
|
-
fail NotImplementedError
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
# The Ace mode to use with this language.
|
|
103
|
-
#
|
|
104
|
-
# @abstract
|
|
105
|
-
# @return [String]
|
|
106
|
-
def self.ace_mode
|
|
107
|
-
fail NotImplementedError
|
|
108
|
-
end
|
|
109
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
if defined?(ActiveRecord)
|
|
3
|
+
# :nocov:
|
|
4
|
+
# TODO: This is for compatibility with the Web application. A future refactoring might be able
|
|
5
|
+
# to remove this dependency.
|
|
6
|
+
class Coursemology::Polyglot::Language < ActiveRecord::Base; end
|
|
7
|
+
# :nocov:
|
|
8
|
+
else
|
|
9
|
+
class Coursemology::Polyglot::Language; end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# An abstract language. This is a class which can represent a family of languages. Languages become
|
|
13
|
+
# concrete and can be used when that language includes +Coursemology::Polyglot::ConcreteLanguage+.
|
|
14
|
+
#
|
|
15
|
+
# Languages define their own scripts and stylesheets needed to syntax highlight code.
|
|
16
|
+
#
|
|
17
|
+
# Each subclass represents a language ancestry, such as differing language versions (see the Python
|
|
18
|
+
# language definition.) Derived languages can be defined at runtime to utilise the syntax
|
|
19
|
+
# highlighting capabilities of the root language, while requiring a separate runtime environment to
|
|
20
|
+
# run programs written in the derived language.
|
|
21
|
+
#
|
|
22
|
+
# Do *NOT* remove languages after they have been defined because the types specified in this
|
|
23
|
+
# library can have references stored in code (e.g. in a database)
|
|
24
|
+
class Coursemology::Polyglot::Language
|
|
25
|
+
extend ActiveSupport::Autoload
|
|
26
|
+
|
|
27
|
+
eager_autoload do
|
|
28
|
+
autoload :Python
|
|
29
|
+
autoload :JavaScript
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# Marks the current class as a concrete language.
|
|
33
|
+
#
|
|
34
|
+
# Concrete languages can be instantiated and used.
|
|
35
|
+
#
|
|
36
|
+
# @param [String] display_name The display name for the language
|
|
37
|
+
# @param [String] docker_image The Docker image to use for the given language. This defaults to
|
|
38
|
+
# the string generated by +Coursemology::Polyglot::ConcreteLanguage.docker_image+.
|
|
39
|
+
def self.concrete_language(display_name, docker_image: nil)
|
|
40
|
+
include Coursemology::Polyglot::ConcreteLanguage
|
|
41
|
+
extend Coursemology::Polyglot::ConcreteLanguage::ClassMethods
|
|
42
|
+
|
|
43
|
+
concrete_class_methods = Module.new do
|
|
44
|
+
define_method(:display_name) { display_name }
|
|
45
|
+
define_method(:docker_image) { docker_image } if docker_image
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
extend concrete_class_methods
|
|
49
|
+
end
|
|
50
|
+
private_class_method :concrete_language
|
|
51
|
+
|
|
52
|
+
# Determines the concrete language subclasses of this language.
|
|
53
|
+
#
|
|
54
|
+
# @return [Array<Class>]
|
|
55
|
+
def self.concrete_languages
|
|
56
|
+
descendants.select do |klass|
|
|
57
|
+
klass.ancestors.include?(Coursemology::Polyglot::ConcreteLanguage)
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# The name of the lexer or mode to use with a given library. This is inherited by classes.
|
|
62
|
+
#
|
|
63
|
+
# @param [String|nil] default The default lexer/mode to use for each library.
|
|
64
|
+
# @param [String] rouge The overridden lexer to use for Rouge. This is optional and will
|
|
65
|
+
# default to +default+
|
|
66
|
+
# @param [String] ace The overridden mode to use for Ace. This is optional and will
|
|
67
|
+
# default to +default+
|
|
68
|
+
# @raise [ArgumentError] When no default is specified and the Rouge lexer or Ace mode is not
|
|
69
|
+
# specified.
|
|
70
|
+
def self.syntax_highlighter(default = nil, rouge: default, ace: default)
|
|
71
|
+
fail ArgumentError unless rouge && ace
|
|
72
|
+
|
|
73
|
+
syntax_highlighter_class_methods = Module.new do
|
|
74
|
+
define_method(:rouge_lexer) { rouge }
|
|
75
|
+
define_method(:ace_mode) { ace }
|
|
76
|
+
end
|
|
77
|
+
extend syntax_highlighter_class_methods
|
|
78
|
+
|
|
79
|
+
syntax_highlighter_instance_methods = Module.new do
|
|
80
|
+
delegate :rouge_lexer, :ace_mode, to: :class
|
|
81
|
+
end
|
|
82
|
+
include syntax_highlighter_instance_methods
|
|
83
|
+
end
|
|
84
|
+
private_class_method :syntax_highlighter
|
|
85
|
+
|
|
86
|
+
# Gets the display name of the language.
|
|
87
|
+
#
|
|
88
|
+
# @abstract
|
|
89
|
+
# @return [String]
|
|
90
|
+
def self.display_name
|
|
91
|
+
fail NotImplementedError
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# The Rouge lexer to use with this language.
|
|
95
|
+
#
|
|
96
|
+
# @abstract
|
|
97
|
+
# @return [String]
|
|
98
|
+
def self.rouge_lexer
|
|
99
|
+
fail NotImplementedError
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# The Ace mode to use with this language.
|
|
103
|
+
#
|
|
104
|
+
# @abstract
|
|
105
|
+
# @return [String]
|
|
106
|
+
def self.ace_mode
|
|
107
|
+
fail NotImplementedError
|
|
108
|
+
end
|
|
109
|
+
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class Coursemology::Polyglot::Language::JavaScript < Coursemology::Polyglot::Language
|
|
2
|
-
syntax_highlighter 'javascript'
|
|
3
|
-
concrete_language '
|
|
4
|
-
end
|
|
1
|
+
class Coursemology::Polyglot::Language::JavaScript < Coursemology::Polyglot::Language
|
|
2
|
+
syntax_highlighter 'javascript'
|
|
3
|
+
concrete_language 'JavaScript', docker_image: 'javascript'
|
|
4
|
+
end
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
class Coursemology::Polyglot::Language::Python < Coursemology::Polyglot::Language
|
|
3
|
-
syntax_highlighter 'python'
|
|
4
|
-
|
|
5
|
-
class Python2Point7 < Coursemology::Polyglot::Language::Python
|
|
6
|
-
concrete_language 'Python 2.7', docker_image: 'python:2.7'
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
class Python3Point4 < Coursemology::Polyglot::Language::Python
|
|
10
|
-
concrete_language 'Python 3.4', docker_image: 'python:3.4'
|
|
11
|
-
end
|
|
12
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
class Coursemology::Polyglot::Language::Python < Coursemology::Polyglot::Language
|
|
3
|
+
syntax_highlighter 'python'
|
|
4
|
+
|
|
5
|
+
class Python2Point7 < Coursemology::Polyglot::Language::Python
|
|
6
|
+
concrete_language 'Python 2.7', docker_image: 'python:2.7'
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
class Python3Point4 < Coursemology::Polyglot::Language::Python
|
|
10
|
+
concrete_language 'Python 3.4', docker_image: 'python:3.4'
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
module Coursemology; end
|
|
3
|
-
module Coursemology::Polyglot
|
|
4
|
-
VERSION = '0.2.
|
|
5
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
module Coursemology; end
|
|
3
|
+
module Coursemology::Polyglot
|
|
4
|
+
VERSION = '0.2.3'.freeze
|
|
5
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: coursemology-polyglot
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Joel Low
|
|
@@ -188,3 +188,4 @@ signing_key:
|
|
|
188
188
|
specification_version: 4
|
|
189
189
|
summary: Coursemology polyglot definitions
|
|
190
190
|
test_files: []
|
|
191
|
+
has_rdoc:
|