reviser 0.0.1.1.pre.beta → 0.0.2.rc1

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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +18 -0
  3. data/README.md +46 -0
  4. data/ext/valgrind.rb +21 -18
  5. data/ext/web_validators.rb +132 -0
  6. data/lang/HTML.yml +2 -14
  7. data/lib/component.rb +41 -39
  8. data/lib/components/archiver.rb +105 -101
  9. data/lib/components/checker.rb +46 -52
  10. data/lib/components/extractors.rb +121 -120
  11. data/lib/components/generator.rb +40 -37
  12. data/lib/components/generators.rb +113 -109
  13. data/lib/components/organiser.rb +165 -153
  14. data/lib/config.rb +53 -35
  15. data/lib/criteria/code_analysis.rb +54 -0
  16. data/lib/criteria/compilation.rb +42 -0
  17. data/lib/criteria/execution.rb +78 -0
  18. data/lib/exec.rb +109 -94
  19. data/lib/helpers/criteria.rb +152 -154
  20. data/lib/helpers/git.rb +23 -21
  21. data/lib/helpers/project.rb +198 -19
  22. data/lib/helpers/system.rb +50 -39
  23. data/lib/loggers/logger.rb +39 -30
  24. data/lib/loggers/modes.rb +118 -54
  25. data/lib/reviser.rb +63 -41
  26. data/res/css/style_logs.css +166 -0
  27. data/res/css/web_validators/css-base.css +733 -0
  28. data/res/css/web_validators/css-results.css +257 -0
  29. data/res/css/web_validators/html-base.css +746 -0
  30. data/res/css/web_validators/html-results.css +489 -0
  31. data/res/labys/labfich11.txt +19 -0
  32. data/res/labys/test.txt +3 -0
  33. data/res/labys/yoda.txt +19 -0
  34. data/res/scss/style_logs.scss +134 -0
  35. data/type/JavaProject.yml +18 -0
  36. data/type/Pendu.yml +22 -0
  37. data/type/Web.yml +23 -0
  38. metadata +144 -10
  39. data/ext/html_validator.rb +0 -21
  40. data/lib/helpers/code_analysis.rb +0 -64
  41. data/lib/helpers/compilation.rb +0 -40
  42. data/lib/helpers/execution.rb +0 -83
  43. data/lib/project.rb +0 -155
data/type/Web.yml ADDED
@@ -0,0 +1,23 @@
1
+ language: HTML
2
+
3
+ #
4
+ # The list of project's sources extensions
5
+ #
6
+ extension:
7
+ - .html
8
+ - .css
9
+
10
+ #
11
+ # The criteria's extensions.
12
+ # Here we're using web_validators
13
+ #
14
+ extensions:
15
+ - validate_web
16
+
17
+ #
18
+ # Let's configure it!
19
+ # We tell the extension to save analysis details files
20
+ # it got from W3C validator, so that we can check those
21
+ # files ourselves for analysis :-)
22
+ #
23
+ web_validators_save_results: true
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reviser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.1.pre.beta
4
+ version: 0.0.2.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Renan Strauss
@@ -11,8 +11,128 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-03-16 00:00:00.000000000 Z
15
- dependencies: []
14
+ date: 2015-03-25 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: colorize
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - "~>"
21
+ - !ruby/object:Gem::Version
22
+ version: '0.7'
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: 0.7.5
26
+ type: :runtime
27
+ prerelease: false
28
+ version_requirements: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '0.7'
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: 0.7.5
36
+ - !ruby/object:Gem::Dependency
37
+ name: thor
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '0.19'
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 0.19.1
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '0.19'
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 0.19.1
56
+ - !ruby/object:Gem::Dependency
57
+ name: rubyzip
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.1'
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: 1.1.7
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - "~>"
71
+ - !ruby/object:Gem::Version
72
+ version: '1.1'
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 1.1.7
76
+ - !ruby/object:Gem::Dependency
77
+ name: spreadsheet
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: 1.0.3
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - "~>"
91
+ - !ruby/object:Gem::Version
92
+ version: '1.0'
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 1.0.3
96
+ - !ruby/object:Gem::Dependency
97
+ name: git
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '1.2'
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: 1.2.9.1
106
+ type: :runtime
107
+ prerelease: false
108
+ version_requirements: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - "~>"
111
+ - !ruby/object:Gem::Version
112
+ version: '1.2'
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: 1.2.9.1
116
+ - !ruby/object:Gem::Dependency
117
+ name: rest-client
118
+ requirement: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - "~>"
121
+ - !ruby/object:Gem::Version
122
+ version: '1.7'
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: 1.7.3
126
+ type: :runtime
127
+ prerelease: false
128
+ version_requirements: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: '1.7'
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: 1.7.3
16
136
  description: A semi-automatic tool for student's projects evaluation
17
137
  email: renan.strauss@gmail.com
18
138
  executables:
@@ -20,10 +140,12 @@ executables:
20
140
  extensions: []
21
141
  extra_rdoc_files: []
22
142
  files:
143
+ - Gemfile
144
+ - README.md
23
145
  - bin/reviser
24
146
  - config.yml
25
- - ext/html_validator.rb
26
147
  - ext/valgrind.rb
148
+ - ext/web_validators.rb
27
149
  - labels.yml
28
150
  - lang/C.yml
29
151
  - lang/HTML.yml
@@ -37,33 +159,45 @@ files:
37
159
  - lib/components/generators.rb
38
160
  - lib/components/organiser.rb
39
161
  - lib/config.rb
162
+ - lib/criteria/code_analysis.rb
163
+ - lib/criteria/compilation.rb
164
+ - lib/criteria/execution.rb
40
165
  - lib/exec.rb
41
- - lib/helpers/code_analysis.rb
42
- - lib/helpers/compilation.rb
43
166
  - lib/helpers/criteria.rb
44
- - lib/helpers/execution.rb
45
167
  - lib/helpers/git.rb
46
168
  - lib/helpers/project.rb
47
169
  - lib/helpers/system.rb
48
170
  - lib/loggers/logger.rb
49
171
  - lib/loggers/modes.rb
50
- - lib/project.rb
51
172
  - lib/reviser.rb
52
173
  - res/css/component.css
53
174
  - res/css/normalize.css
175
+ - res/css/style_logs.css
176
+ - res/css/web_validators/css-base.css
177
+ - res/css/web_validators/css-results.css
178
+ - res/css/web_validators/html-base.css
179
+ - res/css/web_validators/html-results.css
54
180
  - res/js/jquery.stickyheader.js
181
+ - res/labys/labfich11.txt
182
+ - res/labys/test.txt
183
+ - res/labys/yoda.txt
184
+ - res/scss/style_logs.scss
55
185
  - type/CProject.yml
56
186
  - type/HelloWorldRuby.yml
57
187
  - type/HtmlASRALL.yml
188
+ - type/JavaProject.yml
58
189
  - type/Labyrinthe.yml
59
- homepage: http://rubygems.org/gems/reviser
190
+ - type/Pendu.yml
191
+ - type/Web.yml
192
+ homepage: http://rubygemspec.org/gems/reviser
60
193
  licenses:
61
- - MIT
194
+ - GPL-3
62
195
  metadata: {}
63
196
  post_install_message:
64
197
  rdoc_options: []
65
198
  require_paths:
66
199
  - lib
200
+ - lib/helpers
67
201
  required_ruby_version: !ruby/object:Gem::Requirement
68
202
  requirements:
69
203
  - - ">="
@@ -1,21 +0,0 @@
1
- require 'html5_validator/validator'
2
-
3
- module Extensions
4
- module HtmlValidator
5
- include Helpers::CodeAnalysis
6
-
7
- def validate_html
8
- validator = Html5Validator::Validator.new
9
-
10
- results = {}
11
- # Might need to take care of other extensions
12
- sources.each do |f|
13
- validator.validate_text File.read(f)
14
- results.store f, validator.errors
15
- end
16
-
17
- results
18
- end
19
- end
20
-
21
- end
@@ -1,64 +0,0 @@
1
- #
2
- # @Author Renan Strauss
3
- #
4
- # Basic stuff needed for Checker
5
- #
6
-
7
- module Helpers
8
- module CodeAnalysis
9
-
10
- def all_files
11
- files.join("\r")
12
- end
13
-
14
- #
15
- # @return all files matching the
16
- # extenstion language list (note that Cfg[:extension] must be an array)
17
- #
18
- def src_files
19
- sources.join("\r")
20
- end
21
-
22
- #
23
- # @return the total amount of lines of code
24
- #
25
- def lines_count
26
- count = sources.inject(0) { |sum, f|
27
- sum + File.open(f).readlines.select { |l| !l.chomp.empty? }.size
28
- }
29
-
30
- count - comments_count # FIXME
31
- end
32
-
33
- #
34
- # @return the number of lines of comments
35
- #
36
- def comments_count
37
- tab_comments = sources.inject([]) { |t, f| t << IO.read(f).scrub.scan(Cfg[:regex_comments]) }
38
- lines = tab_comments.inject('') { |s, comm| s << find_comments(comm) }.split "\n"
39
-
40
- lines.size
41
- end
42
-
43
- private
44
-
45
- #
46
- # @return all the files in the project's folder
47
- #
48
- def files
49
- Dir.glob("**/*").select { |f| (File.file?(f)) }
50
- end
51
-
52
- def sources
53
- files.select { |f| Cfg[:extension].include? File.extname(f) }
54
- end
55
-
56
- #
57
- # Translates a sub-match returned by scan
58
- # into raw comments string
59
- #
60
- def find_comments(comm)
61
- comm.inject('') { |t, l| t << l.detect { |a| (a != nil) && !a.strip.empty? } + "\n" }
62
- end
63
- end
64
- end
@@ -1,40 +0,0 @@
1
- #
2
- # @Author Yann Prono
3
- # @Author Renan Strauss
4
- #
5
- # Needed stuff for compiled languages
6
- # such as C, Java, and so on.
7
- #
8
-
9
- module Helpers
10
- module Compilation
11
- include Project
12
- include System
13
-
14
- #
15
- # Only here for compiled language,
16
- #
17
- def compile
18
- #
19
- # For now, we compile only if there's
20
- # no missing file
21
- # We should maybe make it more
22
- # understandable in the Cfg
23
- #
24
- if missing_files.empty?
25
- cmd = "#{Cfg[(Cfg.has_key? :preferred_build_command) && :preferred_build_command || :default_build_command]}"
26
- out = exec_with_timeout cmd
27
-
28
- if out.has_key? :process_status
29
- return "Exit status: 0\r#{out[:stdout]}" unless out[:process_status].exitstatus != 0
30
- end
31
-
32
- if Cfg.has_key? :preferred_build_command
33
- out = exec_with_timeout Cfg[:default_build_command]
34
- end
35
-
36
- (out[:process_status].exitstatus == 0) ? "Exit status: 0\r#{out[:stdout]}" : "#{out[:stdout]}\r#{out[:stderr]}"
37
- end
38
- end
39
- end
40
- end
@@ -1,83 +0,0 @@
1
- #
2
- # @Author Renan Strauss
3
- #
4
- # Needed stuff for Checker
5
- # when it comes to executing
6
- # both compiled and interpreted
7
- # languages
8
- #
9
-
10
- require 'timeout'
11
-
12
- module Helpers
13
- module Execution
14
- #
15
- # Determines how to execute the program
16
- # thanks to Cfg, then returns its exec
17
- # status(es)
18
- #
19
- def execute
20
- outputs = []
21
- if Cfg.has_key? :execution_value
22
- if Cfg[:execution_value].respond_to? 'each'
23
- Cfg[:execution_value].each do |v|
24
- outputs << exec(v)
25
- end
26
- else
27
- if Cfg.has_key? :execution_count
28
- outputs[Cfg[:execution_value]] = []
29
- Cfg[:execution_count].times do
30
- outputs << exec(Cfg[:execution_value])
31
- end
32
- else
33
- outputs << exec(Cfg[:execution_value])
34
- end
35
- end
36
- else
37
- if Cfg.has_key? :execution_count
38
- Cfg[:execution_count].times do
39
- outputs << exec
40
- end
41
- else
42
- return exec
43
- end
44
- end
45
-
46
- outputs.join("\r")
47
- end
48
-
49
- private
50
-
51
- #
52
- # The method that actually
53
- # executes the program.
54
- # If no program name is specified
55
- # in the Cfg, it executes the
56
- # first executable found.
57
- # It helps with C (a.out) when no
58
- # Makefile is avalaible, but it
59
- # might not be a good idea regarding
60
- # security
61
- #
62
- def exec(param = nil)
63
- program = (Cfg.has_key? :program_name) && Cfg[:program_name] || find_executable
64
-
65
- return 'Program not found' unless program != nil
66
-
67
- program = "#{Cfg[:program_prefix]}#{program}"
68
- argument = (param == nil) && '' || param
69
-
70
- cmd = "#{(Cfg.has_key? :execute_command) && Cfg[:execute_command] || ''} #{program} #{argument}"
71
- out = exec_with_timeout cmd
72
-
73
- "$ #{cmd}\r#{out[:stdout]}\r#{out[:stderr]}"
74
- end
75
-
76
- #
77
- # @return the first executable found
78
- #
79
- def find_executable
80
- Dir.glob('*').select {|f| File.executable?(f) && !File.directory?(f)}.first
81
- end
82
- end
83
- end
data/lib/project.rb DELETED
@@ -1,155 +0,0 @@
1
- # This modules is used to scan the name of project
2
- # in order to get all students who worked.
3
- # This analysis uses regex of convention given by teachers (config file).
4
- #
5
- # @author Yann Prono
6
- #
7
- module Project
8
-
9
- # Dictionnary for regex in config file
10
- SYMBOLS = {
11
- :group => 'GROUP',
12
- :firstname => 'FIRSTN',
13
- :name => 'NAME',
14
- :user => 'USER',
15
- :lambda => 'LAMBDA'
16
- }
17
-
18
- # Regex to associate, depending the used word in Cfg
19
- REGEX = {
20
- :group => '([A-Za-z0-9]+)',
21
- :firstname => '([A-Za-z\-]+)',
22
- :name => '([A-Za-z]+)',
23
- :user => '([^_]*)',
24
- :lambda => '[a-zA-Z0-9 _]*'
25
- }
26
-
27
-
28
- # Get formatter written in the config file
29
- # and count occurences of each word in the dictionnary SYMBOLS.
30
- # @return [Hash] sym => count.
31
- #
32
- def analyze_formatter
33
- regex = Cfg[:projects_names]
34
- # Foreach known symbols
35
- SYMBOLS.each do |k, _|
36
- # Get numbers of occurences of the word k in regex
37
- matches = regex.scan(SYMBOLS[k]).size
38
- # the word K => number of occurences
39
- @count_patterns[k] = matches if matches > 0
40
- end
41
- end
42
-
43
-
44
- # Analyze et get all informations
45
- # that could be useful in the name of the
46
- # directory project.
47
- # @param entry [String] name of directory to analysis.
48
- #
49
- def format entry
50
- ext = File.extname entry
51
- entry = File.basename entry, ext
52
-
53
- analyze_formatter if @count_patterns.empty?
54
-
55
- group = check_entry_name entry
56
- generate_label group
57
- end
58
-
59
-
60
- # Generate new name of project.
61
- # @param infos [Hash] All informations used for generate a name for the directory.
62
- # @return [String] the formatted name for directory project
63
- #
64
- def generate_label infos
65
- unless infos.empty?
66
- label = ''
67
- infos.reject { |k| k == :group }.each { |_, v|
68
- if v.respond_to?('each')
69
- v.each { |data|
70
- label += data +' ' }
71
- else
72
- label += v + ' '
73
- end
74
- }
75
- # Inject group of project before name : group/name
76
- label = infos.key?(:group) && File.join(infos[:group], label) || label
77
- label
78
- end
79
- end
80
-
81
- # I'm not pround of this method ...
82
- # associate to a symbol, his position in the regex
83
- # @example NAME_FIRSTN
84
- # will give : {
85
- # 1 => :name,
86
- # 2 => :firstname
87
- #}
88
- def get_position regex
89
- res = {}
90
- SYMBOLS.each do |k,v|
91
- regex.scan(v) do |_|
92
- res[$~.offset(0)[0]] = k
93
- end
94
- end
95
-
96
- res = (res.sort_by { |k, _| k }).to_h
97
- tmp = {}
98
-
99
- index = 1
100
- res.each do |_,v|
101
- tmp[index] = v
102
- index += 1
103
- end
104
- tmp
105
- end
106
-
107
-
108
- # Apply regex of user on the entry name
109
- # and try to get all interested matched values.
110
- def check_entry_name entry
111
- regex = Cfg[:projects_names]
112
- # who work on the current project (entry) ?
113
- position = get_position regex
114
-
115
- @count_patterns.each do |k, _|
116
- regex = regex.gsub SYMBOLS[k], REGEX[k]
117
- end
118
-
119
- # Apply created regex
120
- entry.match Regexp.new(regex)
121
- pos = 1
122
- infos = {}
123
-
124
- # Get matched values
125
- begin
126
- tmp = eval "$#{pos}"
127
- if tmp != nil && tmp != ''
128
- tmp = tmp.delete '_'
129
- infos.has_key?(position[pos]) && infos[position[pos]] << tmp || infos[position[pos]] = [tmp]
130
- else
131
- ask entry
132
- end
133
- pos += 1
134
- end while pos <= position.size
135
-
136
- sort_infos infos
137
- infos
138
- end
139
-
140
-
141
- # Put all datas found in respective variables (students, groups, teams ...).
142
- # @param infos [Hash] Informations found by regex.
143
- def sort_infos infos
144
- infos[:name].respond_to?('each') && infos[:name].each { |n| @students << n } || @students << infos[:name]
145
- infos[:group] = infos[:group][0].upcase if infos.key? :group
146
- @groups << infos[:group] if infos.has_key?(:group) && !@groups.include?(infos[:group])
147
- @binoms << infos[:name]
148
- end
149
-
150
-
151
- def ask entry
152
- # TODO, ask to user if the entry is correctly written
153
- end
154
-
155
- end