coursemology-polyglot 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/Coursemology Polyglot.iml +11 -0
- data/.rubocop.unhound.yml +37 -172
- data/.rubocop.yml +20 -0
- data/.travis.yml +3 -2
- data/README.md +27 -0
- data/app/assets/javascripts/coursemology/polyglot/ace-modes.js.erb +5 -0
- data/coursemology-polyglot.gemspec +4 -0
- data/lib/coursemology/polyglot.rb +2 -0
- data/lib/coursemology/polyglot/concrete_language.rb +1 -0
- data/lib/coursemology/polyglot/concrete_language/class_methods.rb +1 -0
- data/lib/coursemology/polyglot/engine.rb +24 -0
- data/lib/coursemology/polyglot/language.rb +33 -10
- data/lib/coursemology/polyglot/language/python.rb +3 -0
- data/lib/coursemology/polyglot/version.rb +2 -1
- metadata +25 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5362954fc3f5ce4201052cca9dc8f60423d801e2
|
4
|
+
data.tar.gz: 28c1d21015e9025394f35eded6cdba6ea66bf43a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c34a0c52348298a4ad937ab75ab2316cea1a337ad038b8a69dd2f616da1c18022cbe798d4490d7e07a00d8c0f6b8367b2a43b93f7d3bcdfc7a26aa3479001fc
|
7
|
+
data.tar.gz: 03e2719ad1119acff8c6b2bbd8f5acb8f372d92b8d1558942cf122cdb0ec9a03094e370c433eb6878630f7b3c2dd02f58ef8564ad602e7c4d36aee45ac730194
|
@@ -1,9 +1,20 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="FacetManager">
|
4
|
+
<facet type="gem" name="Gem">
|
5
|
+
<configuration>
|
6
|
+
<option name="GEM_APP_ROOT_PATH" value="" />
|
7
|
+
<option name="GEM_APP_TEST_PATH" value="" />
|
8
|
+
<option name="GEM_APP_LIB_PATH" value="" />
|
9
|
+
</configuration>
|
10
|
+
</facet>
|
11
|
+
</component>
|
3
12
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
4
13
|
<exclude-output />
|
5
14
|
<content url="file://$MODULE_DIR$" />
|
6
15
|
<orderEntry type="inheritedJdk" />
|
7
16
|
<orderEntry type="sourceFolder" forTests="false" />
|
17
|
+
<orderEntry type="library" scope="PROVIDED" name="json (v1.8.3, ruby-2.3.0-p7) [gem]" level="application" />
|
18
|
+
<orderEntry type="library" scope="PROVIDED" name="rake (v10.5.0, ruby-2.3.0-p7) [gem]" level="application" />
|
8
19
|
</component>
|
9
20
|
</module>
|
data/.rubocop.unhound.yml
CHANGED
@@ -1,44 +1,4 @@
|
|
1
|
-
|
2
|
-
Enabled: true
|
3
|
-
|
4
|
-
ActionFilter:
|
5
|
-
Enabled: true
|
6
|
-
|
7
|
-
Alias:
|
8
|
-
Enabled: true
|
9
|
-
|
10
|
-
ArrayJoin:
|
11
|
-
Enabled: true
|
12
|
-
|
13
|
-
AsciiComments:
|
14
|
-
Enabled: true
|
15
|
-
|
16
|
-
AsciiIdentifiers:
|
17
|
-
Enabled: true
|
18
|
-
|
19
|
-
Attr:
|
20
|
-
Enabled: true
|
21
|
-
|
22
|
-
BlockNesting:
|
23
|
-
Enabled: true
|
24
|
-
|
25
|
-
CaseEquality:
|
26
|
-
Enabled: true
|
27
|
-
|
28
|
-
CharacterLiteral:
|
29
|
-
Enabled: true
|
30
|
-
|
31
|
-
ClassAndModuleChildren:
|
32
|
-
Enabled: true
|
33
|
-
EnforcedStyle: compact
|
34
|
-
|
35
|
-
ClassLength:
|
36
|
-
Enabled: true
|
37
|
-
|
38
|
-
ClassVars:
|
39
|
-
Enabled: true
|
40
|
-
|
41
|
-
CollectionMethods:
|
1
|
+
Style/CollectionMethods:
|
42
2
|
Enabled: true
|
43
3
|
PreferredMethods:
|
44
4
|
reduce:
|
@@ -46,199 +6,104 @@ CollectionMethods:
|
|
46
6
|
find:
|
47
7
|
detect: 'find'
|
48
8
|
|
49
|
-
|
50
|
-
Enabled: true
|
51
|
-
|
52
|
-
CommentAnnotation:
|
53
|
-
Enabled: true
|
54
|
-
|
55
|
-
CyclomaticComplexity:
|
56
|
-
Enabled: true
|
57
|
-
|
58
|
-
Delegate:
|
59
|
-
Enabled: true
|
60
|
-
|
61
|
-
DeprecatedHashMethods:
|
62
|
-
Enabled: true
|
63
|
-
|
64
|
-
DoubleNegation:
|
9
|
+
Style/FileName:
|
65
10
|
Enabled: true
|
66
11
|
|
67
|
-
|
12
|
+
Style/GuardClause:
|
68
13
|
Enabled: true
|
69
14
|
|
70
|
-
|
15
|
+
Style/IfUnlessModifier:
|
71
16
|
Enabled: true
|
72
17
|
|
73
|
-
|
74
|
-
Enabled: false
|
75
|
-
|
76
|
-
EvenOdd:
|
18
|
+
Style/PercentLiteralDelimiters:
|
77
19
|
Enabled: true
|
78
20
|
|
79
|
-
|
80
|
-
Enabled: false
|
81
|
-
|
82
|
-
FileName:
|
21
|
+
Style/SignalException:
|
83
22
|
Enabled: true
|
84
23
|
|
85
|
-
|
24
|
+
Style/SingleLineBlockParams:
|
86
25
|
Enabled: true
|
87
26
|
|
88
|
-
|
27
|
+
Style/SingleLineMethods:
|
89
28
|
Enabled: true
|
90
29
|
|
91
|
-
|
30
|
+
Style/TrailingCommaInArguments:
|
92
31
|
Enabled: true
|
93
32
|
|
94
|
-
|
33
|
+
Style/TrailingCommaInLiteral:
|
95
34
|
Enabled: true
|
96
35
|
|
97
|
-
|
36
|
+
Metrics/AbcSize:
|
98
37
|
Enabled: true
|
99
38
|
|
100
|
-
|
39
|
+
Metrics/ClassLength:
|
101
40
|
Enabled: true
|
102
41
|
|
103
|
-
|
104
|
-
Enabled: false
|
105
|
-
|
106
|
-
Lambda:
|
42
|
+
Metrics/ModuleLength:
|
107
43
|
Enabled: true
|
108
44
|
|
109
|
-
|
45
|
+
Metrics/CyclomaticComplexity:
|
110
46
|
Enabled: true
|
111
47
|
|
112
|
-
|
48
|
+
Metrics/MethodLength:
|
113
49
|
Enabled: true
|
114
50
|
|
115
|
-
|
51
|
+
Metrics/ParameterLists:
|
116
52
|
Enabled: true
|
117
53
|
|
118
|
-
|
54
|
+
Metrics/PerceivedComplexity:
|
119
55
|
Enabled: true
|
120
56
|
|
121
|
-
|
57
|
+
Lint/AssignmentInCondition:
|
122
58
|
Enabled: true
|
123
59
|
|
124
|
-
|
60
|
+
Style/AccessorMethodName:
|
125
61
|
Enabled: true
|
126
62
|
|
127
|
-
|
128
|
-
Enabled: true
|
129
|
-
|
130
|
-
NilComparison:
|
131
|
-
Enabled: true
|
132
|
-
|
133
|
-
Not:
|
134
|
-
Enabled: true
|
135
|
-
|
136
|
-
NumericLiterals:
|
137
|
-
Enabled: true
|
138
|
-
|
139
|
-
OneLineConditional:
|
140
|
-
Enabled: true
|
141
|
-
|
142
|
-
OpMethod:
|
143
|
-
Enabled: true
|
144
|
-
|
145
|
-
ParameterLists:
|
146
|
-
Enabled: true
|
147
|
-
|
148
|
-
PercentLiteralDelimiters:
|
149
|
-
Enabled: true
|
150
|
-
|
151
|
-
PerlBackrefs:
|
152
|
-
Enabled: true
|
153
|
-
|
154
|
-
PredicateName:
|
155
|
-
NamePrefixBlacklist: []
|
156
|
-
|
157
|
-
Proc:
|
158
|
-
Enabled: true
|
159
|
-
|
160
|
-
RaiseArgs:
|
161
|
-
Enabled: true
|
162
|
-
|
163
|
-
RegexpLiteral:
|
164
|
-
Enabled: true
|
165
|
-
|
166
|
-
SelfAssignment:
|
167
|
-
Enabled: true
|
168
|
-
|
169
|
-
SingleLineBlockParams:
|
170
|
-
Enabled: true
|
171
|
-
|
172
|
-
SingleLineMethods:
|
173
|
-
Enabled: true
|
174
|
-
|
175
|
-
SignalException:
|
176
|
-
Enabled: true
|
177
|
-
|
178
|
-
SpecialGlobalVars:
|
179
|
-
Enabled: true
|
180
|
-
|
181
|
-
VariableInterpolation:
|
182
|
-
Enabled: true
|
183
|
-
|
184
|
-
TrailingComma:
|
185
|
-
Enabled: true
|
186
|
-
|
187
|
-
TrivialAccessors:
|
188
|
-
Enabled: true
|
189
|
-
|
190
|
-
VariableInterpolation:
|
191
|
-
Enabled: true
|
192
|
-
|
193
|
-
WhenThen:
|
194
|
-
Enabled: true
|
195
|
-
|
196
|
-
WhileUntilModifier:
|
197
|
-
Enabled: true
|
198
|
-
|
199
|
-
# Lint
|
200
|
-
|
201
|
-
AmbiguousOperator:
|
63
|
+
Style/Alias:
|
202
64
|
Enabled: true
|
65
|
+
EnforcedStyle: prefer_alias_method
|
203
66
|
|
204
|
-
|
67
|
+
Style/Documentation:
|
205
68
|
Enabled: true
|
206
69
|
|
207
|
-
|
70
|
+
Style/DoubleNegation:
|
208
71
|
Enabled: true
|
209
72
|
|
210
|
-
|
73
|
+
Style/EachWithObject:
|
211
74
|
Enabled: true
|
212
75
|
|
213
|
-
|
76
|
+
Style/EmptyLiteral:
|
214
77
|
Enabled: true
|
215
78
|
|
216
|
-
|
79
|
+
Style/ModuleFunction:
|
217
80
|
Enabled: true
|
218
81
|
|
219
|
-
|
82
|
+
Style/OneLineConditional:
|
220
83
|
Enabled: true
|
221
84
|
|
222
|
-
|
85
|
+
Style/PerlBackrefs:
|
223
86
|
Enabled: true
|
224
87
|
|
225
|
-
|
88
|
+
Style/SpecialGlobalVars:
|
226
89
|
Enabled: true
|
227
90
|
|
228
|
-
|
91
|
+
Style/VariableInterpolation:
|
229
92
|
Enabled: true
|
230
93
|
|
231
|
-
|
94
|
+
Style/WhenThen:
|
232
95
|
Enabled: true
|
233
96
|
|
234
|
-
|
97
|
+
Lint/EachWithObjectArgument:
|
235
98
|
Enabled: true
|
236
99
|
|
237
|
-
|
100
|
+
Lint/HandleExceptions:
|
238
101
|
Enabled: true
|
239
102
|
|
240
|
-
|
103
|
+
Lint/LiteralInCondition:
|
104
|
+
Description: Checks of literals used in conditions.
|
241
105
|
Enabled: true
|
242
106
|
|
243
|
-
|
107
|
+
Lint/LiteralInInterpolation:
|
108
|
+
Description: Checks for literals used in interpolation.
|
244
109
|
Enabled: true
|
data/.rubocop.yml
CHANGED
@@ -1,9 +1,20 @@
|
|
1
1
|
inherit_from:
|
2
2
|
- .rubocop.unhound.yml
|
3
3
|
|
4
|
+
AllCops:
|
5
|
+
Include:
|
6
|
+
- '**/Gemfile'
|
7
|
+
- '**/Rakefile'
|
8
|
+
Exclude:
|
9
|
+
- 'vendor/bundle/**/*'
|
10
|
+
TargetRubyVersion: 2.1
|
11
|
+
|
4
12
|
Metrics/LineLength:
|
5
13
|
Max: 100
|
6
14
|
|
15
|
+
Style/ClassAndModuleChildren:
|
16
|
+
EnforcedStyle: compact
|
17
|
+
|
7
18
|
Style/DotPosition:
|
8
19
|
EnforcedStyle: trailing
|
9
20
|
|
@@ -13,9 +24,18 @@ Style/Documentation:
|
|
13
24
|
Style/IndentHash:
|
14
25
|
EnforcedStyle: consistent
|
15
26
|
|
27
|
+
Style/IfUnlessModifier:
|
28
|
+
MaxLineLength: 100
|
29
|
+
|
30
|
+
Style/ParallelAssignment:
|
31
|
+
Enabled: false
|
32
|
+
|
16
33
|
Style/StringLiterals:
|
17
34
|
EnforcedStyle: single_quotes
|
18
35
|
|
36
|
+
Style/WhileUntilModifier:
|
37
|
+
MaxLineLength: 100
|
38
|
+
|
19
39
|
Style/WordArray:
|
20
40
|
Enabled: false
|
21
41
|
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -3,3 +3,30 @@
|
|
3
3
|
|
4
4
|
This is the library common between the web application and the evaluator for determining the
|
5
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.
|
@@ -29,4 +29,8 @@ programming languages supported in Coursemology.
|
|
29
29
|
spec.add_development_dependency 'codeclimate-test-reporter'
|
30
30
|
|
31
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'
|
32
36
|
end
|
@@ -0,0 +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,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
if defined?(ActiveRecord)
|
2
3
|
# :nocov:
|
3
4
|
# TODO: This is for compatibility with the Web application. A future refactoring might be able
|
@@ -45,6 +46,7 @@ class Coursemology::Polyglot::Language
|
|
45
46
|
|
46
47
|
extend concrete_class_methods
|
47
48
|
end
|
49
|
+
private_class_method :concrete_language
|
48
50
|
|
49
51
|
# Determines the concrete language subclasses of this language.
|
50
52
|
#
|
@@ -55,6 +57,31 @@ class Coursemology::Polyglot::Language
|
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
60
|
+
# The name of the lexer or mode to use with a given library. This is inherited by classes.
|
61
|
+
#
|
62
|
+
# @param [String|nil] default The default lexer/mode to use for each library.
|
63
|
+
# @param [String] rouge The overridden lexer to use for Rouge. This is optional and will
|
64
|
+
# default to +default+
|
65
|
+
# @param [String] ace The overridden mode to use for Ace. This is optional and will
|
66
|
+
# default to +default+
|
67
|
+
# @raise [ArgumentError] When no default is specified and the Rouge lexer or Ace mode is not
|
68
|
+
# specified.
|
69
|
+
def self.syntax_highlighter(default = nil, rouge: default, ace: default)
|
70
|
+
fail ArgumentError unless rouge && ace
|
71
|
+
|
72
|
+
syntax_highlighter_class_methods = Module.new do
|
73
|
+
define_method(:rouge_lexer) { rouge }
|
74
|
+
define_method(:ace_mode) { ace }
|
75
|
+
end
|
76
|
+
extend syntax_highlighter_class_methods
|
77
|
+
|
78
|
+
syntax_highlighter_instance_methods = Module.new do
|
79
|
+
delegate :rouge_lexer, :ace_mode, to: :class
|
80
|
+
end
|
81
|
+
include syntax_highlighter_instance_methods
|
82
|
+
end
|
83
|
+
private_class_method :syntax_highlighter
|
84
|
+
|
58
85
|
# Gets the display name of the language.
|
59
86
|
#
|
60
87
|
# @abstract
|
@@ -63,23 +90,19 @@ class Coursemology::Polyglot::Language
|
|
63
90
|
fail NotImplementedError
|
64
91
|
end
|
65
92
|
|
66
|
-
# The
|
67
|
-
#
|
68
|
-
# This should include the Rouge/Pygments stylesheet for formatting code.
|
93
|
+
# The Rouge lexer to use with this language.
|
69
94
|
#
|
70
95
|
# @abstract
|
71
|
-
# @return [
|
72
|
-
def self.
|
96
|
+
# @return [String]
|
97
|
+
def self.rouge_lexer
|
73
98
|
fail NotImplementedError
|
74
99
|
end
|
75
100
|
|
76
|
-
# The
|
77
|
-
#
|
78
|
-
# This should include the Ace mode for the language.
|
101
|
+
# The Ace mode to use with this language.
|
79
102
|
#
|
80
103
|
# @abstract
|
81
|
-
# @return [
|
82
|
-
def self.
|
104
|
+
# @return [String]
|
105
|
+
def self.ace_mode
|
83
106
|
fail NotImplementedError
|
84
107
|
end
|
85
108
|
end
|
@@ -1,4 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
class Coursemology::Polyglot::Language::Python < Coursemology::Polyglot::Language
|
3
|
+
syntax_highlighter 'python'
|
4
|
+
|
2
5
|
class Python2Point7 < Coursemology::Polyglot::Language::Python
|
3
6
|
concrete_language 'Python 2.7', docker_image: 'python:2.7'
|
4
7
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coursemology-polyglot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel Low
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -114,6 +114,26 @@ dependencies:
|
|
114
114
|
- - ">="
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: 4.2.2
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: railties
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: 4.2.0
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: 4.2.2
|
127
|
+
type: :development
|
128
|
+
prerelease: false
|
129
|
+
version_requirements: !ruby/object:Gem::Requirement
|
130
|
+
requirements:
|
131
|
+
- - "~>"
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: 4.2.0
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: 4.2.2
|
117
137
|
description: |
|
118
138
|
Common definitions shared between the web application and the evaluator for determining the
|
119
139
|
programming languages supported in Coursemology.
|
@@ -133,10 +153,12 @@ files:
|
|
133
153
|
- Gemfile
|
134
154
|
- README.md
|
135
155
|
- Rakefile
|
156
|
+
- app/assets/javascripts/coursemology/polyglot/ace-modes.js.erb
|
136
157
|
- coursemology-polyglot.gemspec
|
137
158
|
- lib/coursemology/polyglot.rb
|
138
159
|
- lib/coursemology/polyglot/concrete_language.rb
|
139
160
|
- lib/coursemology/polyglot/concrete_language/class_methods.rb
|
161
|
+
- lib/coursemology/polyglot/engine.rb
|
140
162
|
- lib/coursemology/polyglot/language.rb
|
141
163
|
- lib/coursemology/polyglot/language/python.rb
|
142
164
|
- lib/coursemology/polyglot/version.rb
|
@@ -160,7 +182,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
182
|
version: '0'
|
161
183
|
requirements: []
|
162
184
|
rubyforge_project:
|
163
|
-
rubygems_version: 2.
|
185
|
+
rubygems_version: 2.5.1
|
164
186
|
signing_key:
|
165
187
|
specification_version: 4
|
166
188
|
summary: Coursemology polyglot definitions
|