reviser 0.0.2.rc1 → 0.0.2
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/Gemfile +1 -1
- data/README.md +143 -10
- data/bin/reviser +1 -1
- data/config.yml +1 -6
- data/ext/valgrind.rb +7 -3
- data/ext/web_validators.rb +44 -80
- data/lang/HTML.yml +5 -0
- data/lib/exec.rb +36 -24
- data/lib/{component.rb → reviser/component.rb} +17 -3
- data/lib/{components → reviser/components}/archiver.rb +4 -8
- data/lib/{components → reviser/components}/checker.rb +6 -3
- data/lib/{components → reviser/components}/extractors.rb +1 -1
- data/lib/{components → reviser/components}/generator.rb +16 -8
- data/lib/{components → reviser/components}/generators.rb +14 -37
- data/lib/{components → reviser/components}/organiser.rb +0 -0
- data/lib/reviser/config.rb +104 -0
- data/lib/{criteria → reviser/criteria}/code_analysis.rb +0 -0
- data/lib/{criteria → reviser/criteria}/compilation.rb +14 -7
- data/lib/{criteria → reviser/criteria}/execution.rb +13 -13
- data/lib/{helpers → reviser/helpers}/criteria.rb +6 -3
- data/lib/{helpers → reviser/helpers}/git.rb +0 -0
- data/lib/{helpers → reviser/helpers}/project.rb +17 -12
- data/lib/{helpers → reviser/helpers}/system.rb +0 -0
- data/lib/{loggers → reviser/loggers}/logger.rb +1 -2
- data/lib/{loggers → reviser/loggers}/modes.rb +1 -1
- data/lib/reviser/result.rb +30 -0
- data/lib/reviser.rb +15 -15
- data/res/css/component.css +3 -1
- data/res/example/data.json +4 -0
- data/type/{CProject.yml → example/CProject.yml} +0 -0
- data/type/{HelloWorldRuby.yml → example/HelloWorldRuby.yml} +0 -0
- data/type/{HtmlASRALL.yml → example/HtmlASRALL.yml} +0 -0
- data/type/{JavaProject.yml → example/JavaProject.yml} +0 -0
- data/type/{Labyrinthe.yml → example/Labyrinthe.yml} +0 -0
- data/type/{Pendu.yml → example/Pendu.yml} +0 -0
- data/type/{Web.yml → example/Web.yml} +0 -0
- metadata +37 -43
- data/lib/config.rb +0 -66
- data/res/js/jquery.stickyheader.js +0 -149
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63f5c9bb8b13e12e15bfaa88826b18e740fd9c9c
|
4
|
+
data.tar.gz: 7b6da00d754cd3a1cf240b74dbfbff1210877b2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 702d6ac5c42ba91b81c366d85d42f560a1243ba780c4575148da466137a690f01fe038d8ea411ee6f258ca8d42e615fad807625eb524c5d510cc4145c83a9c51
|
7
|
+
data.tar.gz: 75be96c7c3560d4385b6f2fd08e9543a0dc1b83aab5fcb1ad59e89e24c9a5d466d2ff4025ad77bafeda6c062f7acf131446bf3c87a85b1b48c281e63dea702e7
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,32 +1,165 @@
|
|
1
1
|
Reviser
|
2
2
|
====================
|
3
3
|
|
4
|
-
Description
|
4
|
+
###Description
|
5
5
|
---------------
|
6
6
|
[Reviser](https://rubygems.org/gems/reviser) is a semi-automatic tool for student's projects evaluation, written in Ruby.
|
7
7
|
|
8
|
-
Installation
|
8
|
+
###Installation
|
9
9
|
---------------
|
10
10
|
|
11
|
-
###Gem Installation
|
12
|
-
|
13
11
|
Download and install the gem with the following command line.
|
14
12
|
|
15
13
|
gem install reviser
|
16
14
|
|
17
15
|
|
18
|
-
###
|
16
|
+
###Basic usage
|
17
|
+
---------------
|
18
|
+
|
19
|
+
To create a new workspace in the current directory, simply run the following command in a terminal:
|
20
|
+
|
19
21
|
|
20
|
-
|
22
|
+
reviser init .
|
21
23
|
|
22
|
-
|
24
|
+
Create res
|
25
|
+
Create type
|
26
|
+
Create config.yml
|
23
27
|
|
24
|
-
|
28
|
+
You see reviser has created *res* and *type/example* folders for you.
|
29
|
+
Now you'll have to customize *config.yml* to your own needs, and add a *type/your_project.yml*
|
25
30
|
|
26
|
-
To
|
31
|
+
To perform the analysis, simply run:
|
27
32
|
|
28
33
|
reviser work
|
29
34
|
|
35
|
+
###Configuration
|
36
|
+
---------------
|
37
|
+
|
38
|
+
This tool was thought to be very adaptable, thus it relies on YAML configuration files.
|
39
|
+
|
40
|
+
###Global configuration
|
41
|
+
Lives in *config.yml*.
|
42
|
+
|
43
|
+
|Key |Description|Values|Required|
|
44
|
+
|------|-----------|-----|:--------:|
|
45
|
+
|*src*|Path to the archive containing projects|||
|
46
|
+
|*dest*|Path to a directory where projects will be extracted|||
|
47
|
+
|*projects_names*|Naming convention for projects|`^GROUP_NAME_NAME` `^GROUP_NAME(_NAME)*` `^TP_NAME_FIRSTN`||
|
48
|
+
|*type*|The type of the project|`my_project` (*type/my_project.yml* must exist)||
|
49
|
+
|*criteria*|The criteria you want for analysis|`all_files` `src_files` `lines_count` `comments_count` `compile` `execute`||
|
50
|
+
|*extensions*|The list of extensions you want for analysis|See below||
|
51
|
+
|*out*|The name of the analysis output file|Default *results*||
|
52
|
+
|*out_format*|The formats that will be generated|Default `html` `xls` `csv`||
|
53
|
+
|*options*|A hash to set options|`:verbose` `:log_dir` `:log_mode`||
|
54
|
+
|
55
|
+
###Project configuration
|
56
|
+
Lives in *type/my_project.yml*.
|
57
|
+
|
58
|
+
|Key |Description|Values|Required|
|
59
|
+
|------|-----------|-----|:--------:|
|
60
|
+
|*language*|The target language|`C` `Java` `HTML` `Ruby`||
|
61
|
+
|*timeout*|In seconds. Compilation and execution will halt if not completed within the defined timeout|Default *4*||
|
62
|
+
|*required_files*|A list of required files|Tip: you can use regular expressions||
|
63
|
+
|*preferred_build_command*|The command to build the program with|`make`||
|
64
|
+
|*execute_command*|The name of the interpreter|`java` `ruby`||
|
65
|
+
|*program_prefix*|The program prefix|`pkg.` for Java||
|
66
|
+
|*program_name*|The name of the program|`a.out` `Main`||
|
67
|
+
|*execution_count*|The amount of times to execute the program|Default *1*||
|
68
|
+
|*execution_value*|The optional parameter to pass to the program when executing|A list of values whose length shall be one if *execution_count* is not greater than 1|||
|
69
|
+
|
70
|
+
###Extensions
|
71
|
+
Extensions are in fact Criteria we didn't want to include into reviser's core.
|
72
|
+
Reviser's core aims to rely as much as possible on native Ruby APIs to ensure its portability.
|
73
|
+
That's why Extensions exist: they basically are Criteria which relies on platform-spefic-features.
|
74
|
+
|
75
|
+
As of now, there are 2 extensions:
|
76
|
+
|
77
|
+
|Extension|Description|Add it to your workspace extensions|
|
78
|
+
|------------|--------------|----------------------------------------------|
|
79
|
+
|Valgrind|Runs a memcheck through system call to valgrind|`memleaks`|
|
80
|
+
|WebValidators|Validates HTML and CSS through W3C API calls|`validate_web` `validate_html` `validate_css`|
|
81
|
+
|
82
|
+
###Extending
|
83
|
+
|
84
|
+
####Custom components
|
85
|
+
```
|
86
|
+
#!ruby
|
87
|
+
|
88
|
+
require 'json'
|
89
|
+
require 'reviser'
|
90
|
+
|
91
|
+
#
|
92
|
+
# Let's build a custom component !
|
93
|
+
# It just parses an example JSON file and prints it
|
94
|
+
#
|
95
|
+
class MyComponent < Reviser::Component
|
96
|
+
#
|
97
|
+
# Don't forget to call super !
|
98
|
+
#
|
99
|
+
# If you told Reviser to take input from another
|
100
|
+
# component, @data will contains it
|
101
|
+
#
|
102
|
+
def initialize data
|
103
|
+
super data
|
104
|
+
|
105
|
+
@logger.info { "Initialized, got data => #{data}" }
|
106
|
+
end
|
107
|
+
|
108
|
+
#
|
109
|
+
# All components must implement a run method
|
110
|
+
#
|
111
|
+
def run
|
112
|
+
puts 'Hello World from MyComponent, got @data = ' + @data.to_s
|
113
|
+
|
114
|
+
my_resource = resource 'example/data.json'
|
115
|
+
JSON.parse(File.read(my_resource)).each do |k, v|
|
116
|
+
puts "Got #{k} => #{v}"
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
#
|
122
|
+
# Then we run it
|
123
|
+
#
|
124
|
+
module MyApp
|
125
|
+
include Reviser
|
126
|
+
|
127
|
+
def self.run config_file = '../config.yml'
|
128
|
+
#
|
129
|
+
# Setup reviser
|
130
|
+
#
|
131
|
+
Reviser::setup config_file
|
132
|
+
|
133
|
+
#
|
134
|
+
# You can load any built-in component (archiver, organiser, checker, generator)
|
135
|
+
# But be aware that they have to be ran in this order, and that
|
136
|
+
# organiser takes input from archiver, checker from organiser and generator from checker
|
137
|
+
# If you don't respect that, nothing will work.
|
138
|
+
# But you can run your component at any step, this won't break the process.
|
139
|
+
#
|
140
|
+
# Reviser::load :component => 'archiver'
|
141
|
+
# Reviser::load :component => 'organiser', :input_from => 'archiver'
|
142
|
+
|
143
|
+
#
|
144
|
+
# Tell reviser not to look for our component
|
145
|
+
# in its core ones but to let us include it
|
146
|
+
# ourselves instead
|
147
|
+
#
|
148
|
+
Reviser::load :component => 'my_component', :local => true #, :input_from => 'archiver'
|
149
|
+
|
150
|
+
# Reviser::load :component => 'checker', :input_from => 'organiser'
|
151
|
+
# Reviser::load :component => 'generator', :input_from => 'checker'
|
152
|
+
|
153
|
+
#
|
154
|
+
# Run reviser
|
155
|
+
#
|
156
|
+
Reviser::run
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
MyApp::run
|
161
|
+
```
|
162
|
+
|
30
163
|
Team
|
31
164
|
----
|
32
165
|
[Anthony Cerf]()
|
@@ -43,4 +176,4 @@ Other stuff
|
|
43
176
|
|
44
177
|
|Question | Answer |
|
45
178
|
| ------------- | ------------------------------ |
|
46
|
-
| Requires | Ruby
|
179
|
+
| Requires | Ruby 1.9.3 or later |
|
data/bin/reviser
CHANGED
data/config.yml
CHANGED
@@ -36,15 +36,10 @@ out_format:
|
|
36
36
|
- csv
|
37
37
|
- html
|
38
38
|
|
39
|
-
# Ressources directory
|
40
|
-
# (needed for html format)
|
41
|
-
res_dir: res
|
42
|
-
|
43
|
-
|
44
39
|
######## Reviser config ########
|
45
40
|
|
46
41
|
# The type of project (<type>.yml must exists)
|
47
|
-
type: Labyrinthe
|
42
|
+
type: example/Labyrinthe
|
48
43
|
|
49
44
|
# Default timeout
|
50
45
|
# shall be overriden in sorts
|
data/ext/valgrind.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module Reviser
|
2
2
|
module Extensions
|
3
3
|
module Valgrind
|
4
|
-
|
5
4
|
include Helpers::System
|
6
5
|
|
7
6
|
VALGRIND_FILE = "valgrind.txt"
|
@@ -19,9 +18,14 @@ module Reviser
|
|
19
18
|
cmd = "valgrind --leak-check=full --track-origins=yes --show-reachable=yes #{program} #{param}"
|
20
19
|
out = exec_with_timeout cmd
|
21
20
|
File.open(VALGRIND_FILE, 'w') { |f| f.write "$ #{cmd}\r#{out[:stdout]}\r#{out[:stderr]}" }
|
22
|
-
|
21
|
+
|
22
|
+
result = File.join(FileUtils.pwd, VALGRIND_FILE)
|
23
|
+
manufacture do |format|
|
24
|
+
format.html { '<a href="' + result + '" target="_blank">' + result + '</a>' }
|
25
|
+
format.csv { result }
|
26
|
+
format.xls { result }
|
27
|
+
end
|
23
28
|
end
|
24
|
-
|
25
29
|
end
|
26
30
|
end
|
27
31
|
end
|
data/ext/web_validators.rb
CHANGED
@@ -7,15 +7,26 @@
|
|
7
7
|
# It's very simple at that point, but feel free to
|
8
8
|
# make the extension better :-)
|
9
9
|
#
|
10
|
-
require '
|
10
|
+
require 'w3c_validators'
|
11
11
|
|
12
12
|
module Reviser
|
13
13
|
module Extensions
|
14
14
|
module WebValidators
|
15
15
|
include Helpers::Project
|
16
|
+
include W3CValidators
|
16
17
|
|
17
18
|
def validate_web
|
18
|
-
|
19
|
+
results = validate(:html)
|
20
|
+
results.merge! validate(:css)
|
21
|
+
|
22
|
+
#
|
23
|
+
# We want a pretty HTML output :-)
|
24
|
+
#
|
25
|
+
manufacture do |format|
|
26
|
+
format.html { prettify results }
|
27
|
+
format.csv { results }
|
28
|
+
format.xls { results }
|
29
|
+
end
|
19
30
|
end
|
20
31
|
|
21
32
|
def validate_html
|
@@ -27,105 +38,58 @@ module Reviser
|
|
27
38
|
end
|
28
39
|
|
29
40
|
private
|
30
|
-
|
31
41
|
#
|
32
42
|
# @returns a hash matching all files for this lang to a resultset
|
33
43
|
#
|
34
44
|
def validate lang
|
35
45
|
results = {}
|
46
|
+
validator = nil
|
47
|
+
case lang
|
48
|
+
when :html
|
49
|
+
validator = MarkupValidator.new
|
50
|
+
when :css
|
51
|
+
validator = CSSValidator.new
|
52
|
+
end
|
53
|
+
|
54
|
+
raise ArgumentError unless validator != nil
|
36
55
|
|
37
56
|
files = sources.select { |s| File.extname(s) == ".#{lang}" }
|
38
57
|
files.each do |f|
|
39
|
-
|
40
|
-
|
41
|
-
if response.is_a?(Hash) && response.has_key?(:exception)
|
42
|
-
results[f] = { :status => response[:exception].to_s }
|
43
|
-
else
|
58
|
+
begin
|
59
|
+
response = validator.validate_file(File.new(f))
|
44
60
|
results[f] = {
|
45
|
-
:
|
46
|
-
:errors => response.
|
47
|
-
:warnings => response.headers.has_key?(:x_w3c_validator_warnings) && response.headers[:x_w3c_validator_warnings] || 'Not available'
|
61
|
+
:valid => response.errors.length == 0,
|
62
|
+
:errors => response.errors.length
|
48
63
|
}
|
49
|
-
end
|
50
64
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
# Generate a file
|
55
|
-
# Simply add 'web_validators_save_results: true'
|
56
|
-
# in your project's type config file
|
57
|
-
#
|
58
|
-
Cfg[:web_validators_save_results] ||= false
|
59
|
-
|
60
|
-
#
|
61
|
-
# We generate only if config key is set and
|
62
|
-
# response is not a raw string
|
63
|
-
#
|
64
|
-
if Cfg[:web_validators_save_results] and not response.headers.empty?
|
65
|
-
body = response.to_str
|
66
|
-
#
|
67
|
-
# W3C uses scss so we need to replace imports by the
|
68
|
-
# actual css...
|
69
|
-
#
|
70
|
-
case lang
|
71
|
-
when :html
|
72
|
-
body.sub! '@import "./style/base";', File.read(Cfg::resource 'css/web_validators/html-base.css')
|
73
|
-
body.sub! '@import "./style/results";', File.read(Cfg::resource 'css/web_validators/html-results.css')
|
74
|
-
when :css
|
75
|
-
body.sub! 'style/base.css', Cfg::resource('css/web_validators/css-base.css').to_path
|
76
|
-
body.sub! 'style/results.css', Cfg::resource('css/web_validators/css-results.css').to_path
|
77
|
-
|
78
|
-
body.sub! 'file://localhost/TextArea', f
|
79
|
-
end
|
80
|
-
|
81
|
-
File.open(f + '.WEB_VALIDATORS.html', 'w') { |x| x.write body }
|
65
|
+
puts "\t\t#{f} => #{results[f][:valid]}"
|
66
|
+
rescue ValidatorUnavailable => e
|
67
|
+
results[f] = { :status => 'Unknown', :errors => 'Unknown' }
|
82
68
|
end
|
83
69
|
end
|
84
70
|
|
85
71
|
results
|
86
72
|
end
|
87
73
|
|
88
|
-
|
89
|
-
|
90
|
-
# W3C API
|
91
|
-
#
|
92
|
-
class W3C
|
93
|
-
VALIDATORS = {
|
94
|
-
:html => 'validator.w3.org/check',
|
95
|
-
:css => 'jigsaw.w3.org/css-validator/validator'
|
96
|
-
}
|
74
|
+
def prettify results
|
75
|
+
return results unless results.values.first
|
97
76
|
|
98
|
-
|
99
|
-
# @returns responses from the request made to the validator
|
100
|
-
#
|
101
|
-
def self::validate lang, file
|
102
|
-
raise ArgumentError unless VALIDATORS.include? lang
|
103
|
-
#
|
104
|
-
# W3C is a free service and we shall not overflow it
|
105
|
-
# with our requests so accordingly to their doc,
|
106
|
-
# we sleep 1s between each request
|
107
|
-
#
|
108
|
-
sleep 1
|
109
|
-
begin
|
110
|
-
send lang, file
|
111
|
-
rescue => e
|
112
|
-
{ exception: e }
|
113
|
-
end
|
114
|
-
end
|
77
|
+
headings = results.values.first.keys
|
115
78
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
def self::html file
|
120
|
-
RestClient.post(VALIDATORS[:html], :uploaded_file => File.new(file))
|
121
|
-
end
|
79
|
+
html = '<table><caption>WebValidators results</caption><tr><th>File</th>'
|
80
|
+
headings.each { |heading| html << "<th>#{heading}</th>" }
|
81
|
+
html << '</tr>'
|
122
82
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
83
|
+
results.each do |file, data|
|
84
|
+
html << '<tr>'
|
85
|
+
html << "<th>#{file}</th>"
|
86
|
+
data.values.each { |value| html << "<td>#{value}</td>" }
|
87
|
+
html << '</tr>'
|
128
88
|
end
|
89
|
+
|
90
|
+
html << '</table>'
|
91
|
+
|
92
|
+
html
|
129
93
|
end
|
130
94
|
end
|
131
95
|
end
|
data/lang/HTML.yml
CHANGED
@@ -16,6 +16,11 @@ extension:
|
|
16
16
|
# Whether it's a compiled or an interpreted language
|
17
17
|
compiled: false
|
18
18
|
|
19
|
+
#
|
20
|
+
# Regex for HTML comments
|
21
|
+
#
|
22
|
+
regex_comments: !ruby/regexp '/<!--(.*?)-->/'
|
23
|
+
|
19
24
|
#
|
20
25
|
# In all HTML projects, we'll need
|
21
26
|
# the html_validator extension
|
data/lib/exec.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
require 'thor'
|
2
2
|
require 'fileutils'
|
3
3
|
require 'colorize'
|
4
|
-
|
5
4
|
require_relative 'reviser'
|
6
|
-
require_relative 'helpers/criteria'
|
7
5
|
|
8
6
|
#
|
9
7
|
# Module used for managing all actions in command line
|
@@ -15,7 +13,7 @@ require_relative 'helpers/criteria'
|
|
15
13
|
module Reviser
|
16
14
|
class Exec < Thor
|
17
15
|
|
18
|
-
VERSION = '0.0.
|
16
|
+
VERSION = '0.0.2'
|
19
17
|
|
20
18
|
map '--version' => :version
|
21
19
|
map '-v' => :version
|
@@ -33,12 +31,22 @@ module Reviser
|
|
33
31
|
setup config_file if File.exist? config_file
|
34
32
|
end
|
35
33
|
|
36
|
-
|
37
34
|
# Create a environnment for checking projects
|
38
35
|
# This method only copies the config file into the current directory.
|
39
36
|
desc 'init DIRECTORY', 'Initialize Reviser workspace. DIRECTORY ||= \'.\''
|
40
37
|
def init(dir = '.')
|
41
38
|
pwd = FileUtils.pwd
|
39
|
+
|
40
|
+
[Cfg::RES_DIR, Cfg::TYPE_DIR].each do |d|
|
41
|
+
path = File.join(Cfg::ROOT, d)
|
42
|
+
if File.directory? path
|
43
|
+
unless File.directory? File.join(dir, d)
|
44
|
+
FileUtils.cp_r(path, dir)
|
45
|
+
message('Create', dir == '.' && d || File.join(dir, d))
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
42
50
|
msg = File.exist?(File.join(pwd,dir,File.basename($template_path))) && 'Recreate' || 'Create'
|
43
51
|
FileUtils.mkdir_p dir unless Dir.exist?(File.join(pwd, dir))
|
44
52
|
FileUtils.cp($template_path, dir)
|
@@ -46,13 +54,6 @@ module Reviser
|
|
46
54
|
|
47
55
|
setup File.expand_path(File.join(dir, File.basename($template_path))) unless @@setup
|
48
56
|
|
49
|
-
if not File.exist?(File.join(FileUtils.pwd, Cfg[:res_dir]))
|
50
|
-
path_res = File.join(File.dirname(File.dirname(__FILE__)),"#{Cfg[:res_dir]}")
|
51
|
-
FileUtils.cp_r(path_res, FileUtils.pwd) unless
|
52
|
-
|
53
|
-
message('Create', File.join(dir, Cfg[:res_dir]))
|
54
|
-
end
|
55
|
-
|
56
57
|
puts "Customize config.yml to your needs @see docs".yellow
|
57
58
|
puts 'Then simply execute \'reviser work\' to launch analysis.'.yellow
|
58
59
|
end
|
@@ -88,16 +89,21 @@ module Reviser
|
|
88
89
|
|
89
90
|
# Let do it for analysis.
|
90
91
|
# @param current_dir [String] the directory where the programm has to be launched.
|
91
|
-
desc 'work', 'Run components to
|
92
|
+
desc 'work', 'Run components to analyse computing projects'
|
92
93
|
def work
|
93
|
-
|
94
94
|
if File.exists? 'config.yml'
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
95
|
+
begin
|
96
|
+
Reviser::load :component => 'archiver'
|
97
|
+
Reviser::load :component => 'organiser', :input_from => 'archiver'
|
98
|
+
Reviser::load :component => 'checker', :input_from => 'organiser'
|
99
|
+
Reviser::load :component => 'generator', :input_from => 'checker'
|
100
|
+
|
101
|
+
Reviser::run
|
102
|
+
rescue Interrupt => i
|
103
|
+
message("...".yellow, "Bye bye")
|
104
|
+
rescue Exception => e
|
105
|
+
message('Error'.red, "#{e.message}")
|
106
|
+
end
|
101
107
|
else
|
102
108
|
message('Error'.red, "'config.yml' file doesn't exist! @see 'reviser init'")
|
103
109
|
end
|
@@ -105,10 +111,16 @@ module Reviser
|
|
105
111
|
|
106
112
|
desc 'extract', 'Extract and organise all computing projects'
|
107
113
|
def extract
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
114
|
+
begin
|
115
|
+
Reviser::load :component => 'archiver'
|
116
|
+
Reviser::load :component => 'organiser', :input_from => 'archiver'
|
117
|
+
|
118
|
+
Reviser::run
|
119
|
+
rescue Interrupt => i
|
120
|
+
message("...".yellow, "Bye bye")
|
121
|
+
rescue Exception => e
|
122
|
+
message('Error'.red, "#{e.message}")
|
123
|
+
end
|
112
124
|
end
|
113
125
|
|
114
126
|
#
|
@@ -129,7 +141,7 @@ module Reviser
|
|
129
141
|
desc 'version', 'Print out version information'
|
130
142
|
def version
|
131
143
|
puts "Reviser #{VERSION}"
|
132
|
-
puts 'Released under the
|
144
|
+
puts 'Released under the GPLv3 License.'
|
133
145
|
end
|
134
146
|
|
135
147
|
|
@@ -18,8 +18,9 @@ module Reviser
|
|
18
18
|
#
|
19
19
|
def initialize(data = nil)
|
20
20
|
@data = data
|
21
|
-
|
22
|
-
|
21
|
+
|
22
|
+
ext = options[:log_mode]
|
23
|
+
log_file = File.join(options[:log_dir], "#{self.class.name.split('::').last}.#{ext}")
|
23
24
|
|
24
25
|
# For now, we output to stderr if verbose option is not set
|
25
26
|
# In the future, it would be a good idea to always have logs,
|
@@ -45,11 +46,24 @@ module Reviser
|
|
45
46
|
data
|
46
47
|
end
|
47
48
|
|
49
|
+
# Be kind to our childs and let them access
|
50
|
+
# ressources files easily
|
51
|
+
#
|
52
|
+
# @returns The specified resource path
|
53
|
+
# TODO : put resources in dedicated folders
|
54
|
+
# for each component or extension, so that
|
55
|
+
# the user can omit <lang>/<ext_name>/ when
|
56
|
+
# calling this method
|
57
|
+
#
|
58
|
+
def resource path
|
59
|
+
Cfg::resource path
|
60
|
+
end
|
61
|
+
|
48
62
|
protected
|
49
63
|
#
|
50
64
|
# @return all options for all components if they exist in config file.
|
51
65
|
def options
|
52
|
-
|
66
|
+
Cfg[:options]
|
53
67
|
end
|
54
68
|
end
|
55
69
|
end
|
@@ -53,14 +53,15 @@ module Reviser
|
|
53
53
|
# @param destination [String] The destination directory.
|
54
54
|
#
|
55
55
|
def self.extract(file_name, destination = '.')
|
56
|
-
raise
|
56
|
+
raise "#{file_name} not found, please check in the current directory." unless File.exist? file_name
|
57
57
|
|
58
58
|
# Get extension of file_name to know which method calls
|
59
59
|
ext = File.extname(file_name)
|
60
60
|
ext = ext.delete('.')
|
61
61
|
|
62
62
|
# Raise exception if the format is unknown by Archiver
|
63
|
-
raise "Unknown format '#{
|
63
|
+
raise "Unknown compression format '#{ext}'" unless respond_to?(ext)
|
64
|
+
|
64
65
|
# Check if destination exists
|
65
66
|
self::destination? destination
|
66
67
|
|
@@ -93,7 +94,7 @@ module Reviser
|
|
93
94
|
|
94
95
|
ext = File.extname entry
|
95
96
|
basename = File.basename entry, ext
|
96
|
-
begin
|
97
|
+
#begin
|
97
98
|
file_name = File.join(@destination,File.basename(entry))
|
98
99
|
destination = File.join(@destination,basename)
|
99
100
|
|
@@ -104,11 +105,6 @@ module Reviser
|
|
104
105
|
@logger.h2 Logger::INFO, "extracting #{file_name} to #{destination}"
|
105
106
|
@results << basename
|
106
107
|
|
107
|
-
# In case of it can't extract the file
|
108
|
-
rescue => e
|
109
|
-
@logger.h2 Logger::ERROR, "Can't extract #{entry}: #{e.message}"
|
110
|
-
end
|
111
|
-
|
112
108
|
# Delete in all case the archive (useless after this step)
|
113
109
|
FileUtils.rm_rf file_name
|
114
110
|
end
|
@@ -9,6 +9,7 @@
|
|
9
9
|
#
|
10
10
|
require 'open3'
|
11
11
|
|
12
|
+
require_relative '../result'
|
12
13
|
require_relative '../helpers/criteria'
|
13
14
|
|
14
15
|
module Reviser
|
@@ -24,8 +25,8 @@ module Reviser
|
|
24
25
|
|
25
26
|
@logger.h1 Logger::INFO, "Loading modules"
|
26
27
|
|
27
|
-
load
|
28
|
-
load
|
28
|
+
load CRITERIA
|
29
|
+
load EXTENSIONS
|
29
30
|
|
30
31
|
@logger.h1 Logger::INFO, "Loading labels"
|
31
32
|
|
@@ -61,7 +62,9 @@ module Reviser
|
|
61
62
|
# for each method asked by user with its label
|
62
63
|
@output.each do |meth, label|
|
63
64
|
if @criteria.has_key? meth
|
64
|
-
|
65
|
+
result = call meth
|
66
|
+
data = result.is_a?(Result) && result || Result.new(result)
|
67
|
+
@results[proj][label] = data
|
65
68
|
else
|
66
69
|
@logger.h1(Logger::ERROR, "Unknown method '#{meth}'' for project #{proj}")
|
67
70
|
end
|
@@ -110,7 +110,7 @@ module Reviser
|
|
110
110
|
destination = Shellwords.escape(destination)
|
111
111
|
`unrar e #{src} #{destination}`
|
112
112
|
else
|
113
|
-
|
113
|
+
raise 'Please install unrar : sudo apt-get install unrar (winRar for Windows)'
|
114
114
|
end
|
115
115
|
end
|
116
116
|
|