reviser 0.0.3.4 → 0.0.4
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/README.md +130 -49
- data/ext/web_validators.rb +1 -1
- data/lib/reviser/component.rb +10 -7
- data/lib/reviser/components/generator.rb +12 -16
- data/lib/reviser/components/generators.rb +3 -3
- data/lib/reviser/config.rb +4 -2
- data/lib/reviser/criteria/compilation.rb +2 -1
- data/lib/reviser/criteria/execution.rb +7 -4
- data/lib/reviser/exec.rb +14 -25
- data/lib/reviser/loggers/logger.rb +9 -3
- data/lib/reviser/loggers/modes.rb +1 -1
- data/lib/reviser.rb +26 -2
- data/res/{css → reviser/css}/component.css +0 -0
- data/res/{css → reviser/css}/normalize.css +0 -0
- data/res/{css → reviser/css}/style_logs.css +0 -0
- data/res/{scss → reviser/scss}/style_logs.scss +0 -0
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b63cbac6d816c0a769775138b27e75b82710350
|
4
|
+
data.tar.gz: 15b90eb7be2b8f4f2d5583b9dd8cf10b550f5a33
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfd41b950b81b43fc88b78dbf97653ae6648efe0cbd28435b24ed734509df459b8a23c6caf4d74b15ff1a0d1f12fd401b3b142705afc558b4e7fe01e2458fd7f
|
7
|
+
data.tar.gz: f5e2fe3c549763a5ee97ffaf65244fcfe300a88a04b9c141c1718c55441ad374815d576ad36d86445dccc4d01e8d7f9afa54660fe08b7cb4bfc629b3e4ade24c
|
data/README.md
CHANGED
@@ -62,12 +62,12 @@ Lives in *config.yml*.
|
|
62
62
|
|*src*|Path to the archive containing projects|||
|
63
63
|
|*dest*|Path to a directory where projects will be extracted|||
|
64
64
|
|*projects_names*|Naming convention for projects|`^GROUP_NAME_NAME` `^GROUP_NAME(_NAME)*` `^TP_NAME_FIRSTN`||
|
65
|
-
|*create_git_repo*|Whether to create a git repository for each project or not (requires *git* gem)|Default `false`||
|
66
65
|
|*type*|The type of the project|`my_project` (*type/my_project.yml* must exist)||
|
67
66
|
|*criteria*|The criteria you want for analysis|`all_files` `src_files` `lines_count` `comments_count` `compile` `execute`||
|
68
67
|
|*extensions*|The list of extensions you want for analysis|See below||
|
68
|
+
|*create_git_repo*|Whether to create a git repository for each project or not (requires *git* gem)|Default `false`||
|
69
69
|
|*out*|The name of the analysis output file|Default *results*||
|
70
|
-
|*out_format*|The formats that will be generated|Default `csv` `html` (`xls` also available
|
70
|
+
|*out_format*|The formats that will be generated|Default `csv` `html` (`xls` also available, but requires *spreadsheet* gem)||
|
71
71
|
|*options*|A hash to set options|`:verbose` `:log_dir` `:log_mode`||
|
72
72
|
|
73
73
|
###Project configuration
|
@@ -107,7 +107,7 @@ As of now, there are 2 extensions:
|
|
107
107
|
|Extension|Description|Add it to your workspace extensions|
|
108
108
|
|------------|--------------|----------------------------------------------|
|
109
109
|
|Valgrind|Runs a memcheck through system call to valgrind|`memleaks`|
|
110
|
-
|WebValidators|Validates HTML and CSS through W3C API calls|`validate_web`|
|
110
|
+
|WebValidators|Validates HTML and CSS through W3C API calls (requires *w3c_validators* gem)|`validate_web`|
|
111
111
|
|
112
112
|
###Working on your own
|
113
113
|
|
@@ -116,67 +116,144 @@ You'll then need to load your components at the right time, and register your ex
|
|
116
116
|
|
117
117
|
####Custom components
|
118
118
|
|
119
|
-
|
119
|
+
We're going to show you how to create a custom generator that will generate a nice-looking HTML table using jQuery dataTables.
|
120
120
|
|
121
|
-
|
122
|
-
require 'json'
|
123
|
-
require 'reviser'
|
121
|
+
*example/my_generator.rb*
|
124
122
|
|
123
|
+
``` ruby
|
125
124
|
#
|
126
|
-
#
|
127
|
-
#
|
125
|
+
# This is a simple component showing how to extend Reviser
|
126
|
+
# We are going to build a custom HTML generator with jQuery :-)
|
128
127
|
#
|
129
|
-
|
130
|
-
|
131
|
-
|
128
|
+
require 'reviser'
|
129
|
+
|
130
|
+
class MyGenerator < Reviser::Component
|
132
131
|
#
|
133
|
-
#
|
134
|
-
# component, @data will contains it
|
132
|
+
# We're expecting results from Checker as data
|
135
133
|
#
|
136
134
|
def initialize data
|
137
135
|
super data
|
138
|
-
|
139
|
-
|
136
|
+
#
|
137
|
+
# We want the HTML output
|
138
|
+
#
|
139
|
+
@data.each do |project, results|
|
140
|
+
results.each do |criterion, value|
|
141
|
+
@data[project][criterion] = value.html
|
142
|
+
end
|
143
|
+
end
|
140
144
|
end
|
141
145
|
|
142
|
-
#
|
143
|
-
# All components must implement a run method
|
144
|
-
#
|
145
146
|
def run
|
146
|
-
|
147
|
+
#
|
148
|
+
# Get our template file
|
149
|
+
#
|
150
|
+
template = resource('html/results_template.html').read
|
147
151
|
|
148
|
-
|
149
|
-
|
150
|
-
|
152
|
+
out = '<thead><tr>'
|
153
|
+
#
|
154
|
+
# Each criterion as headings
|
155
|
+
#
|
156
|
+
@data.values.first.keys.unshift.unshift('Projet').each { |crit| out += "<th>#{crit}</th>" }
|
157
|
+
|
158
|
+
out += '</tr></thead><tbody>'
|
159
|
+
# Values for each project as rows
|
160
|
+
@data.keys.each do |proj|
|
161
|
+
out += "<tr><th>#{proj}</th>"
|
162
|
+
@data[proj].each do |k, v|
|
163
|
+
out += "<td>#{v.to_s.strip}</td>"
|
164
|
+
end
|
165
|
+
out += '</tr>'
|
151
166
|
end
|
152
|
-
|
167
|
+
out += '</tbody>'
|
168
|
+
|
169
|
+
#
|
170
|
+
# Kind of a hacky template engine
|
171
|
+
# We replace placeholders with actual values
|
172
|
+
#
|
173
|
+
template.sub! '[DATA]', out
|
174
|
+
template.sub! '[MAINCSS_PATH]', resource('css/main.css').to_path
|
175
|
+
|
176
|
+
File.open('my_results.html', 'w') { |f| f.write template }
|
177
|
+
end
|
153
178
|
end
|
154
179
|
```
|
155
180
|
|
181
|
+
*example/res/my_generator/html/results_template.html*
|
182
|
+
``` html
|
183
|
+
<!DOCTYPE html>
|
184
|
+
<html>
|
185
|
+
<head>
|
186
|
+
<meta charset= "UTF-8">
|
187
|
+
<link rel="stylesheet" type="text/css" href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css">
|
188
|
+
<link rel="stylesheet" type="text/css" href="http://cdn.datatables.net/plug-ins/f2c75b7247b/integration/bootstrap/3/dataTables.bootstrap.css">
|
189
|
+
<link rel="stylesheet" type="text/css" href="[MAINCSS_PATH]">
|
190
|
+
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
|
191
|
+
<script type="text/javascript" src="http://cdn.datatables.net/1.10.5/js/jquery.dataTables.min.js"></script>
|
192
|
+
<script type="text/javascript" src="http://cdn.datatables.net/plug-ins/f2c75b7247b/integration/bootstrap/3/dataTables.bootstrap.js"></script>
|
193
|
+
<title>My results</title>
|
194
|
+
<script type="text/javascript">
|
195
|
+
$(document).ready(function() {
|
196
|
+
$('#results').dataTable({"dom":' <"search"fl><"top">rt<"bottom"ip><"clear">'});
|
197
|
+
});
|
198
|
+
</script>
|
199
|
+
</head>
|
200
|
+
<body>
|
201
|
+
<table id="results">
|
202
|
+
[DATA]
|
203
|
+
</table>
|
204
|
+
<script type="text/javascript">
|
205
|
+
$('#results').removeClass('display').addClass('table table-striped table-bordered');
|
206
|
+
</script>
|
207
|
+
</body>
|
208
|
+
</html>
|
209
|
+
```
|
210
|
+
|
156
211
|
####Custom extensions
|
157
212
|
|
213
|
+
Now let's create a custom criterion !
|
214
|
+
This one is very simple : it will calculate project's size thanks to *filesize* gem.
|
215
|
+
|
216
|
+
Creating an extension is as simple as creating a module.
|
217
|
+
In fact, when you register that module as an extension, its methods become available for you to add in *extensions* configuration key.
|
218
|
+
|
158
219
|
*example/my_extension.rb*
|
159
220
|
|
160
221
|
``` ruby
|
222
|
+
require 'find'
|
223
|
+
require 'reviser'
|
224
|
+
|
161
225
|
#
|
162
226
|
# A custom criteria for reviser
|
163
227
|
#
|
164
|
-
require 'reviser'
|
165
|
-
|
166
228
|
module MyExtension
|
167
229
|
#
|
168
230
|
# This helper has the 'sources' methods
|
169
231
|
# that allow you to retrieve all sources
|
170
232
|
# files (files matching language extension)
|
233
|
+
# as well as the 'manufacture' method,
|
234
|
+
# needed to adapt results to out format
|
171
235
|
#
|
172
236
|
include Reviser::Helpers::Project
|
173
237
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
238
|
+
#
|
239
|
+
# Keep in mind that this method will be run
|
240
|
+
# in each project's directory !
|
241
|
+
# (that's why we use FileUtils.pwd)
|
242
|
+
#
|
243
|
+
def project_size
|
244
|
+
#
|
245
|
+
# That's the way we require gems without worrying
|
246
|
+
# of them being installed or not !
|
247
|
+
# require_gem is in global scope, and will raise an
|
248
|
+
# exception if the given gem is not installed.
|
249
|
+
# It will include it otherwise
|
250
|
+
#
|
251
|
+
unless defined? Filesize
|
252
|
+
require_gem 'filesize'
|
178
253
|
end
|
179
254
|
|
255
|
+
size_in_bytes = size(FileUtils.pwd)
|
256
|
+
results = Filesize.from("#{size_in_bytes} B").pretty
|
180
257
|
#
|
181
258
|
# The manufacture method excepts
|
182
259
|
# a block which must describe the result contents
|
@@ -185,24 +262,23 @@ module MyExtension
|
|
185
262
|
# for all formats.
|
186
263
|
#
|
187
264
|
manufacture do |format|
|
188
|
-
format.html {
|
189
|
-
format.csv {
|
265
|
+
format.html { '<span style="font-weight:bold;">' + results + '</span>' }
|
266
|
+
format.csv { results }
|
190
267
|
format.xls { results }
|
191
268
|
end
|
192
269
|
end
|
193
270
|
|
194
271
|
private
|
195
272
|
#
|
196
|
-
#
|
273
|
+
# Returns the size of all the given
|
274
|
+
# files (even if there are also dirs)
|
275
|
+
# in bytes
|
197
276
|
#
|
198
|
-
def
|
199
|
-
|
200
|
-
|
201
|
-
html << "<li>#{el}</li>"
|
202
|
-
end
|
203
|
-
html << '</ul>'
|
277
|
+
def size(dir)
|
278
|
+
bytes = 0
|
279
|
+
Find.find(*Dir["#{dir}/**/*"]) { |f| bytes += File.stat(f).size }
|
204
280
|
|
205
|
-
|
281
|
+
bytes.to_f
|
206
282
|
end
|
207
283
|
end
|
208
284
|
```
|
@@ -212,16 +288,18 @@ end
|
|
212
288
|
|
213
289
|
``` yaml
|
214
290
|
extensions:
|
215
|
-
-
|
291
|
+
- project_size
|
216
292
|
```
|
217
293
|
|
218
294
|
*example/my_app.rb*
|
219
295
|
|
296
|
+
This file shows how to plug your custom component into reviser's workflow as well as how to make your custom extension available.
|
297
|
+
|
220
298
|
``` ruby
|
221
299
|
require 'reviser'
|
222
300
|
|
223
|
-
require_relative 'my_component'
|
224
301
|
require_relative 'my_extension'
|
302
|
+
require_relative 'my_generator'
|
225
303
|
|
226
304
|
module MyApp
|
227
305
|
include Reviser
|
@@ -232,6 +310,9 @@ module MyApp
|
|
232
310
|
#
|
233
311
|
Reviser::setup config_file
|
234
312
|
|
313
|
+
#
|
314
|
+
# You can now use MyExtension's methods for analysis
|
315
|
+
#
|
235
316
|
Reviser::register :extension => 'MyExtension'
|
236
317
|
|
237
318
|
#
|
@@ -243,16 +324,16 @@ module MyApp
|
|
243
324
|
#
|
244
325
|
Reviser::load :component => 'archiver'
|
245
326
|
Reviser::load :component => 'organiser', :input_from => 'archiver'
|
246
|
-
|
327
|
+
Reviser::load :component => 'checker', :input_from => 'organiser'
|
247
328
|
#
|
248
|
-
#
|
249
|
-
# in its core ones but to let us include it
|
250
|
-
# ourselves instead
|
329
|
+
# We run our custom generator instead :-)
|
251
330
|
#
|
252
|
-
|
331
|
+
# With :local => true, we tell reviser not to look for our component
|
332
|
+
# in its core ones but to let us include it ourselves instead
|
333
|
+
#
|
334
|
+
Reviser::load :component => 'my_generator', :input_from => 'checker', :local => true
|
253
335
|
|
254
|
-
Reviser::load :component => '
|
255
|
-
Reviser::load :component => 'generator', :input_from => 'checker'
|
336
|
+
# Reviser::load :component => 'generator', :input_from => 'checker'
|
256
337
|
|
257
338
|
#
|
258
339
|
# Run reviser
|
data/ext/web_validators.rb
CHANGED
@@ -78,7 +78,7 @@ module Reviser
|
|
78
78
|
files = sources.select { |s| File.extname(s) == ".#{lang}" }
|
79
79
|
files.each do |f|
|
80
80
|
begin
|
81
|
-
response = validator.validate_file(File.new(f
|
81
|
+
response = validator.validate_file(File.new(f))
|
82
82
|
results[f] = {
|
83
83
|
:valid => response.errors.length == 0,
|
84
84
|
:errors => response.errors.length
|
data/lib/reviser/component.rb
CHANGED
@@ -38,7 +38,11 @@ module Reviser
|
|
38
38
|
# creates a hash for child to easily access config file values
|
39
39
|
#
|
40
40
|
def initialize(data = nil)
|
41
|
-
|
41
|
+
#
|
42
|
+
# Deep copy to ensure everything goes well
|
43
|
+
# (we DO NOT want to copy references)
|
44
|
+
#
|
45
|
+
@data = Marshal.load(Marshal.dump(data))
|
42
46
|
|
43
47
|
ext = options[:log_mode]
|
44
48
|
log_file = File.join(options[:log_dir], "#{self.class.name.split('::').last}.#{ext}")
|
@@ -46,7 +50,7 @@ module Reviser
|
|
46
50
|
# For now, we output to stderr if verbose option is not set
|
47
51
|
# In the future, it would be a good idea to always have logs,
|
48
52
|
# but to let the user change the level
|
49
|
-
@logger = Loggers::Logger.new
|
53
|
+
@logger = Loggers::Logger.new log_file
|
50
54
|
end
|
51
55
|
|
52
56
|
# Place-holder
|
@@ -71,14 +75,13 @@ module Reviser
|
|
71
75
|
# Be kind to our childs and let them access
|
72
76
|
# ressources files easily
|
73
77
|
#
|
78
|
+
# Note: you must store your component's files
|
79
|
+
# int res/your_component/
|
80
|
+
#
|
74
81
|
# @return The specified resource path
|
75
|
-
# TODO : put resources in dedicated folders
|
76
|
-
# for each component or extension, so that
|
77
|
-
# the user can omit <lang>/<ext_name>/ when
|
78
|
-
# calling this method
|
79
82
|
#
|
80
83
|
def resource path
|
81
|
-
Cfg::resource path
|
84
|
+
Cfg::resource File.join(self.class.name.split('::').last.underscore, path)
|
82
85
|
end
|
83
86
|
|
84
87
|
protected
|
@@ -42,26 +42,22 @@ module Reviser
|
|
42
42
|
|
43
43
|
# Runs the generation of results file in all asked formats by user.
|
44
44
|
def run
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
arg = Marshal.load(Marshal.dump(@data))
|
45
|
+
i = 0
|
46
|
+
Cfg[:out_format].each do |format|
|
47
|
+
# Deep copy !!!
|
48
|
+
arg = Marshal.load(Marshal.dump(@data))
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
end
|
50
|
+
puts "----[#{i+1}/#{Cfg[:out_format].size}] #{format.upcase}"
|
51
|
+
arg.each do |project, results|
|
52
|
+
results.each do |criterion, value|
|
53
|
+
arg[project][criterion] = value.send(format.to_sym).to_s.encode! 'utf-8', :invalid => :replace
|
56
54
|
end
|
55
|
+
end
|
57
56
|
|
58
|
-
|
57
|
+
send format.to_sym, arg
|
59
58
|
|
60
|
-
|
61
|
-
|
62
|
-
#rescue Object => e
|
63
|
-
# @logger.h1 Logger::FATAL, "Wrong format : #{e.to_s}"
|
64
|
-
#end
|
59
|
+
i += 1
|
60
|
+
end
|
65
61
|
end
|
66
62
|
|
67
63
|
# Gets all criterias of marking
|
@@ -100,8 +100,8 @@ module Reviser
|
|
100
100
|
def html data, ext = '.html'
|
101
101
|
out = '<!DOCTYPE html><html><head>'
|
102
102
|
out += '<meta charset= "UTF-8">'
|
103
|
-
out += "<link rel=\"stylesheet\" href=\"#{Cfg.resource('/css/component.css').to_path}\" />"
|
104
|
-
out += "<link rel=\"stylesheet\" href=\"#{Cfg.resource('/css/normalize.css').to_path}\" />"
|
103
|
+
out += "<link rel=\"stylesheet\" href=\"#{Cfg.resource('reviser/css/component.css').to_path}\" />"
|
104
|
+
out += "<link rel=\"stylesheet\" href=\"#{Cfg.resource('reviser/css/normalize.css').to_path}\" />"
|
105
105
|
out += '<title>Results</title>'
|
106
106
|
out += "</head>\n<body><table><thead><tr>"
|
107
107
|
|
@@ -112,7 +112,7 @@ module Reviser
|
|
112
112
|
data.keys.each do |proj|
|
113
113
|
out += "<tr><th>#{proj}</th>"
|
114
114
|
data[proj].each do |k, v|
|
115
|
-
out += "<td
|
115
|
+
out += "<td>#{v}</td>"
|
116
116
|
end
|
117
117
|
out += '</tr>'
|
118
118
|
end
|
data/lib/reviser/config.rb
CHANGED
@@ -67,7 +67,9 @@ module Reviser
|
|
67
67
|
# @return The specified
|
68
68
|
def self.workspace_file f
|
69
69
|
path = File.join @@workspace_root, f
|
70
|
-
|
70
|
+
raise Errno::ENOENT, "#{path}".magenta unless File.exists?(path)
|
71
|
+
|
72
|
+
File.new(path)
|
71
73
|
end
|
72
74
|
|
73
75
|
#
|
@@ -84,7 +86,7 @@ module Reviser
|
|
84
86
|
|
85
87
|
def self.load(cfg_file)
|
86
88
|
@@mem = {}
|
87
|
-
@@workspace_root = File.dirname(cfg_file)
|
89
|
+
@@workspace_root = File.expand_path(File.dirname(cfg_file))
|
88
90
|
|
89
91
|
#
|
90
92
|
# read our main config file
|
@@ -19,6 +19,7 @@
|
|
19
19
|
# You should have received a copy of the GNU General Public License
|
20
20
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
21
21
|
#
|
22
|
+
require 'cgi'
|
22
23
|
|
23
24
|
module Reviser
|
24
25
|
module Criteria
|
@@ -59,7 +60,7 @@ module Reviser
|
|
59
60
|
result = "#{out[:stdout]}\r#{out[:stderr]}"
|
60
61
|
|
61
62
|
manufacture do |format|
|
62
|
-
format.html { '<div class="console">' + result + '</div>' }
|
63
|
+
format.html { '<div class="console">' + ::CGI.escapeHTML(result) + '</div>' }
|
63
64
|
format.csv { result }
|
64
65
|
format.xls { result }
|
65
66
|
end
|
@@ -19,6 +19,7 @@
|
|
19
19
|
# You should have received a copy of the GNU General Public License
|
20
20
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
21
21
|
#
|
22
|
+
require 'cgi'
|
22
23
|
require 'timeout'
|
23
24
|
|
24
25
|
module Reviser
|
@@ -62,7 +63,7 @@ module Reviser
|
|
62
63
|
|
63
64
|
result = outputs.join("\r")
|
64
65
|
manufacture do |format|
|
65
|
-
format.html { '<div class="console">' + result + '</div>' }
|
66
|
+
format.html { '<div class="console">' + CGI.escapeHTML(result) + '</div>' }
|
66
67
|
format.csv { result }
|
67
68
|
format.xls { result }
|
68
69
|
end
|
@@ -91,9 +92,11 @@ module Reviser
|
|
91
92
|
#
|
92
93
|
# if it's a file, we change the param to its path
|
93
94
|
#
|
94
|
-
|
95
|
-
|
96
|
-
param =
|
95
|
+
old_param = param
|
96
|
+
begin
|
97
|
+
param = Cfg.resource(param).to_path
|
98
|
+
rescue Errno::ENOENT
|
99
|
+
param = old_param
|
97
100
|
end
|
98
101
|
|
99
102
|
cmd = "#{Cfg[:execute_command]} #{program} #{param}"
|
data/lib/reviser/exec.rb
CHANGED
@@ -36,7 +36,7 @@ module Reviser
|
|
36
36
|
#
|
37
37
|
class Exec < Thor
|
38
38
|
|
39
|
-
VERSION = '0.0.
|
39
|
+
VERSION = '0.0.4'
|
40
40
|
|
41
41
|
map '--version' => :version
|
42
42
|
map '-v' => :version
|
@@ -98,20 +98,12 @@ module Reviser
|
|
98
98
|
desc 'work', 'Run components to analyse computing projects'
|
99
99
|
def work
|
100
100
|
if File.exists? 'config.yml'
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
Reviser::run
|
108
|
-
rescue Interrupt => i
|
109
|
-
puts 'Bye bye'
|
110
|
-
rescue Gem::LoadError => e
|
111
|
-
message('Missing gem'.light_red, e.message)
|
112
|
-
rescue Exception => e
|
113
|
-
message('Error'.red, e.message)
|
114
|
-
end
|
101
|
+
Reviser::load :component => 'archiver'
|
102
|
+
Reviser::load :component => 'organiser', :input_from => 'archiver'
|
103
|
+
Reviser::load :component => 'checker', :input_from => 'organiser'
|
104
|
+
Reviser::load :component => 'generator', :input_from => 'checker'
|
105
|
+
|
106
|
+
Reviser::run
|
115
107
|
else
|
116
108
|
message('Error'.red, "'config.yml' file doesn't exist! @see 'reviser init'")
|
117
109
|
end
|
@@ -119,17 +111,13 @@ module Reviser
|
|
119
111
|
|
120
112
|
desc 'extract', 'Extract and organise all computing projects'
|
121
113
|
def extract
|
122
|
-
|
114
|
+
if File.exists? 'config.yml'
|
123
115
|
Reviser::load :component => 'archiver'
|
124
116
|
Reviser::load :component => 'organiser', :input_from => 'archiver'
|
125
117
|
|
126
118
|
Reviser::run
|
127
|
-
|
128
|
-
|
129
|
-
rescue Gem::LoadError => e
|
130
|
-
message('Missing gem'.yellow, e.message)
|
131
|
-
rescue Exception => e
|
132
|
-
message('Error'.red, e.message)
|
119
|
+
else
|
120
|
+
message('Error'.red, "'config.yml' file doesn't exist! @see 'reviser init'")
|
133
121
|
end
|
134
122
|
end
|
135
123
|
|
@@ -156,8 +144,8 @@ module Reviser
|
|
156
144
|
|
157
145
|
no_tasks do
|
158
146
|
# A Formatter message for command line
|
159
|
-
|
160
|
-
|
147
|
+
def message(keyword, desc)
|
148
|
+
puts "\t#{keyword}\t\t#{desc}"
|
161
149
|
end
|
162
150
|
|
163
151
|
def setup(config_file)
|
@@ -193,4 +181,5 @@ module Reviser
|
|
193
181
|
|
194
182
|
end
|
195
183
|
end
|
196
|
-
|
184
|
+
|
185
|
+
Reviser::Exec.start(ARGV)
|
@@ -38,6 +38,8 @@ module Reviser
|
|
38
38
|
#
|
39
39
|
class Logger
|
40
40
|
|
41
|
+
@@default_mode = 'org'
|
42
|
+
|
41
43
|
# Creates logger.
|
42
44
|
# The extension determines the mode to use (logger mode).
|
43
45
|
# @param filename [String] name of logger.
|
@@ -45,14 +47,18 @@ module Reviser
|
|
45
47
|
ext = File.extname filename
|
46
48
|
@basename = File.basename filename, ext
|
47
49
|
ext = ext.delete '.'
|
50
|
+
dirname = File.dirname filename
|
51
|
+
|
48
52
|
# Include mode aksed by user (config file)
|
49
53
|
begin
|
50
54
|
self.class.send :prepend, Modes.const_get("#{ext.downcase.capitalize}")
|
55
|
+
@logger = ::Logger.new File.open(filename, 'w')
|
51
56
|
rescue => e
|
52
|
-
|
57
|
+
@logger = ::Logger.new File.open(File.join(dirname,(@basename + '.'+@@default_mode)), 'w')
|
58
|
+
@logger.error("Mode #{ext} doesn\'t exist. Org mode by default.")
|
59
|
+
self.class.send :include, Modes::Org
|
53
60
|
end
|
54
|
-
|
55
|
-
@logger = ::Logger.new File.open(filename, 'w')
|
61
|
+
|
56
62
|
@logger.level = ::Logger::DEBUG
|
57
63
|
end
|
58
64
|
|
@@ -86,7 +86,7 @@ module Reviser
|
|
86
86
|
def header
|
87
87
|
add_tag "<!DOCTYPE html><html><head>
|
88
88
|
<meta charset= \"UTF-8\">
|
89
|
-
<link rel=\"stylesheet\" href=\"#{Cfg.resource('/css/style_logs.css').to_path}\" />
|
89
|
+
<link rel=\"stylesheet\" href=\"#{Cfg.resource('reviser/css/style_logs.css').to_path}\" />
|
90
90
|
<title>#{@basename} logs</title>
|
91
91
|
</head>\n<body>
|
92
92
|
<header>
|
data/lib/reviser.rb
CHANGED
@@ -27,7 +27,21 @@ require_relative 'reviser/component'
|
|
27
27
|
require_relative 'reviser/config'
|
28
28
|
|
29
29
|
require_relative 'reviser/helpers/project'
|
30
|
-
require_relative 'reviser/helpers/system'
|
30
|
+
require_relative 'reviser/helpers/system'
|
31
|
+
|
32
|
+
class String
|
33
|
+
#
|
34
|
+
# We need this method from Rails to
|
35
|
+
# convert CamelCaseNames to underscore_names
|
36
|
+
#
|
37
|
+
def underscore
|
38
|
+
self.gsub(/::/, '/').
|
39
|
+
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
40
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
41
|
+
tr("-", "_").
|
42
|
+
downcase
|
43
|
+
end
|
44
|
+
end
|
31
45
|
|
32
46
|
#
|
33
47
|
# Very handy (that's why it's in global scope)
|
@@ -124,7 +138,17 @@ module Reviser
|
|
124
138
|
|
125
139
|
c = eval("#{namespace}#{Reviser.titleize comp}").new param
|
126
140
|
|
127
|
-
|
141
|
+
begin
|
142
|
+
@@loaded_components[comp][:data] = c.work
|
143
|
+
rescue Interrupt => i
|
144
|
+
puts 'Bye bye'
|
145
|
+
rescue Gem::LoadError => e
|
146
|
+
puts 'Missing gem'.light_red + "\t" + e.message
|
147
|
+
exit
|
148
|
+
rescue Exception => ex
|
149
|
+
puts 'Error'.red + "\t" + ex.message
|
150
|
+
exit
|
151
|
+
end
|
128
152
|
|
129
153
|
puts "[ " + "Done".green + " ]"
|
130
154
|
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
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.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Renan Strauss
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-03-
|
14
|
+
date: 2015-03-31 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: colorize
|
@@ -73,8 +73,10 @@ dependencies:
|
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 0.19.1
|
76
|
-
description: A semi-automatic tool for
|
77
|
-
email:
|
76
|
+
description: A semi-automatic tool for students' projects evaluation
|
77
|
+
email:
|
78
|
+
- renan.strauss@gmail.com
|
79
|
+
- pronoyann@gmail.com
|
78
80
|
executables:
|
79
81
|
- reviser
|
80
82
|
extensions: []
|
@@ -113,12 +115,12 @@ files:
|
|
113
115
|
- lib/reviser/loggers/logger.rb
|
114
116
|
- lib/reviser/loggers/modes.rb
|
115
117
|
- lib/reviser/result.rb
|
116
|
-
- res/css/component.css
|
117
|
-
- res/css/normalize.css
|
118
|
-
- res/css/style_logs.css
|
119
118
|
- res/example/data.json
|
120
119
|
- res/example/labfich11.txt
|
121
|
-
- res/
|
120
|
+
- res/reviser/css/component.css
|
121
|
+
- res/reviser/css/normalize.css
|
122
|
+
- res/reviser/css/style_logs.css
|
123
|
+
- res/reviser/scss/style_logs.scss
|
122
124
|
- type/example/CProject.yml
|
123
125
|
- type/example/HelloWorldRuby.yml
|
124
126
|
- type/example/HtmlASRALL.yml
|