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.
- checksums.yaml +4 -4
- data/Gemfile +18 -0
- data/README.md +46 -0
- data/ext/valgrind.rb +21 -18
- data/ext/web_validators.rb +132 -0
- data/lang/HTML.yml +2 -14
- data/lib/component.rb +41 -39
- data/lib/components/archiver.rb +105 -101
- data/lib/components/checker.rb +46 -52
- data/lib/components/extractors.rb +121 -120
- data/lib/components/generator.rb +40 -37
- data/lib/components/generators.rb +113 -109
- data/lib/components/organiser.rb +165 -153
- data/lib/config.rb +53 -35
- data/lib/criteria/code_analysis.rb +54 -0
- data/lib/criteria/compilation.rb +42 -0
- data/lib/criteria/execution.rb +78 -0
- data/lib/exec.rb +109 -94
- data/lib/helpers/criteria.rb +152 -154
- data/lib/helpers/git.rb +23 -21
- data/lib/helpers/project.rb +198 -19
- data/lib/helpers/system.rb +50 -39
- data/lib/loggers/logger.rb +39 -30
- data/lib/loggers/modes.rb +118 -54
- data/lib/reviser.rb +63 -41
- data/res/css/style_logs.css +166 -0
- data/res/css/web_validators/css-base.css +733 -0
- data/res/css/web_validators/css-results.css +257 -0
- data/res/css/web_validators/html-base.css +746 -0
- data/res/css/web_validators/html-results.css +489 -0
- data/res/labys/labfich11.txt +19 -0
- data/res/labys/test.txt +3 -0
- data/res/labys/yoda.txt +19 -0
- data/res/scss/style_logs.scss +134 -0
- data/type/JavaProject.yml +18 -0
- data/type/Pendu.yml +22 -0
- data/type/Web.yml +23 -0
- metadata +144 -10
- data/ext/html_validator.rb +0 -21
- data/lib/helpers/code_analysis.rb +0 -64
- data/lib/helpers/compilation.rb +0 -40
- data/lib/helpers/execution.rb +0 -83
- data/lib/project.rb +0 -155
data/lib/components/checker.rb
CHANGED
@@ -11,68 +11,62 @@ require 'open3'
|
|
11
11
|
|
12
12
|
require_relative '../helpers/criteria'
|
13
13
|
|
14
|
-
module
|
15
|
-
|
16
|
-
|
14
|
+
module Reviser
|
15
|
+
module Components
|
16
|
+
class Checker < Component
|
17
|
+
include Helpers::Criteria
|
17
18
|
|
18
|
-
|
19
|
-
|
19
|
+
def initialize(data)
|
20
|
+
super data
|
20
21
|
|
21
|
-
|
22
|
+
@criteria = Hash.new
|
23
|
+
@output = Hash.new
|
22
24
|
|
23
|
-
|
24
|
-
end
|
25
|
+
@logger.h1 Logger::INFO, "Loading modules"
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
# TODO a voir si cela marche dans certains cas particuliers
|
29
|
-
def run
|
30
|
-
# We'll work in the dest directory
|
31
|
-
Dir.chdir Cfg[:dest] do
|
32
|
-
projects = Dir.entries('.') - ['.','..']
|
33
|
-
projects.each_with_index do |proj, i|
|
34
|
-
puts "\t[#{i+1}/#{projects.size}]\t#{proj}"
|
35
|
-
Dir.chdir(proj) { check proj }
|
36
|
-
end
|
37
|
-
end
|
27
|
+
load PWD, '../criteria/*'
|
28
|
+
load EXT, '*'
|
38
29
|
|
39
|
-
|
40
|
-
|
30
|
+
@logger.h1 Logger::INFO, "Loading labels"
|
31
|
+
|
32
|
+
[:criteria, :extensions].each { |x| load_labels x }
|
41
33
|
|
42
|
-
|
34
|
+
@results = {}
|
35
|
+
end
|
43
36
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
# for each method asked by user with its label
|
54
|
-
@output.each do |meth, label|
|
55
|
-
if @criteria.has_key? meth
|
56
|
-
@results[proj][label] = call meth
|
57
|
-
else
|
58
|
-
@logger.h1(Logger::ERROR, "Unknown method '#{meth}'' for project #{proj}")
|
37
|
+
# Yann : je ne recupere pas les datas de l'organiser,
|
38
|
+
# Je considere que tous les projets sont dans le dossier courant.
|
39
|
+
# TODO a voir si cela marche dans certains cas particuliers
|
40
|
+
def run
|
41
|
+
@data.each_with_index do |proj, i|
|
42
|
+
path = File.join(Cfg[:dest], proj)
|
43
|
+
puts "\t[#{i+1}/#{@data.size}]\t#{proj}"
|
44
|
+
Dir.chdir(path) { check proj }
|
59
45
|
end
|
46
|
+
|
47
|
+
@results
|
60
48
|
end
|
61
|
-
end
|
62
49
|
|
63
|
-
|
64
|
-
# This method is what would be the constructor
|
65
|
-
# of criteria_helper if it was a class
|
66
|
-
#
|
67
|
-
def init_criteria_helper
|
68
|
-
@criteria = Hash.new
|
69
|
-
@output = Hash.new
|
70
|
-
@logger.h1 Logger::INFO, "Loading modules"
|
71
|
-
load PWD, '../helpers/*'
|
72
|
-
load EXT, '*'
|
73
|
-
@logger.h1 Logger::INFO, "Loading labels"
|
74
|
-
[:criteria, :extensions].each { |x| load_labels x }
|
75
|
-
end
|
50
|
+
private
|
76
51
|
|
52
|
+
#
|
53
|
+
# Being called in the project's directory,
|
54
|
+
# this methods maps all the criterias to
|
55
|
+
# their analysis value
|
56
|
+
#
|
57
|
+
def check(proj)
|
58
|
+
# Init results
|
59
|
+
@results[proj] = {}
|
60
|
+
|
61
|
+
# for each method asked by user with its label
|
62
|
+
@output.each do |meth, label|
|
63
|
+
if @criteria.has_key? meth
|
64
|
+
@results[proj][label] = call meth
|
65
|
+
else
|
66
|
+
@logger.h1(Logger::ERROR, "Unknown method '#{meth}'' for project #{proj}")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
77
71
|
end
|
78
72
|
end
|
@@ -1,139 +1,140 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'fileutils'
|
3
3
|
|
4
|
-
module
|
4
|
+
module Reviser
|
5
|
+
module Components
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
module Extractors
|
7
|
+
# The module contains all methods to extract an archive
|
8
|
+
# regardless the format.
|
9
|
+
#
|
10
|
+
# Convention over configuration !
|
11
|
+
#
|
12
|
+
# To add a new format, maybe you need to install the a gem.
|
13
|
+
# Find your gem which uncompress a specified format on rubygems.org.
|
14
|
+
# Add the line "gem <gem>" in the Gemfile and execute "bundle install"
|
15
|
+
#
|
16
|
+
# Now, you can write the method corresponding to the format.
|
17
|
+
# The name of the method corresponds to the format.
|
18
|
+
# For example, if you want to use 'rar' format, the name of the method will be: "rar"
|
19
|
+
# Don't forget to require the gem: "require <gem>" at the beginning of the method!
|
20
|
+
# the header of method looks like the following block:
|
21
|
+
#
|
22
|
+
# def <format> (archive, destination) require <gem> ... end
|
23
|
+
#
|
24
|
+
#
|
25
|
+
#
|
26
|
+
# @author Anthony Cerf
|
27
|
+
# @author Yann Prono
|
28
|
+
#
|
29
|
+
module Extractors
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
31
|
+
# Method which unzips a file.
|
32
|
+
# @param zip_file [String] the zip file.
|
33
|
+
# @param destination [String] Destination of extracted data.
|
34
|
+
def zip zip_file, destination
|
35
|
+
require 'zip'
|
36
|
+
# Cfg the gem
|
37
|
+
Zip.on_exists_proc = true
|
38
|
+
Zip.continue_on_exists_proc = true
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
Zip::File.open(zip_file) do |archive|
|
41
|
+
#Entry = file or directory
|
42
|
+
archive.each do |entry|
|
43
|
+
#Create filepath
|
44
|
+
filepath = File.join(destination, entry.name)
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
46
|
+
# Check if it doesn't exist because of directories (overwrite)
|
47
|
+
unless File.exist?(filepath)
|
48
|
+
# Create directories to access file
|
49
|
+
FileUtils.mkdir_p(File.dirname(filepath))
|
50
|
+
entry.extract(filepath)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
53
54
|
end
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
tar(unzipped, destination)
|
65
|
-
end
|
66
|
-
|
67
|
-
# Alias for format shortcut
|
68
|
-
# CC Dominique Colnet!
|
69
|
-
alias :tgz :gz
|
70
|
-
|
71
|
-
# Method which untar a tarfile.
|
72
|
-
# @param tar_file [String] the tar file.
|
73
|
-
# @param destination [String] Destination of extracted data.
|
74
|
-
def tar tar_file, destination
|
75
|
-
require 'rubygems/package'
|
76
|
-
# test if src is String (filename) or IO stream
|
77
|
-
if tar_file.is_a? String
|
78
|
-
stream = File.open(tar_file)
|
79
|
-
else
|
80
|
-
stream = tar_file
|
55
|
+
|
56
|
+
# Method which ungz a file.
|
57
|
+
# @param gz_file [String] the gz file.
|
58
|
+
# @param destination [String] Destination of extracted data.
|
59
|
+
def gz gz_file, destination
|
60
|
+
require 'zlib'
|
61
|
+
file = Zlib::GzipReader.open(gz_file)
|
62
|
+
unzipped = StringIO.new(file.read)
|
63
|
+
file.close
|
64
|
+
tar(unzipped, destination)
|
81
65
|
end
|
82
66
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
67
|
+
# Alias for format shortcut
|
68
|
+
# CC Dominique Colnet!
|
69
|
+
alias :tgz :gz
|
70
|
+
|
71
|
+
# Method which untar a tarfile.
|
72
|
+
# @param tar_file [String] the tar file.
|
73
|
+
# @param destination [String] Destination of extracted data.
|
74
|
+
def tar tar_file, destination
|
75
|
+
require 'rubygems/package'
|
76
|
+
# test if src is String (filename) or IO stream
|
77
|
+
if tar_file.is_a? String
|
78
|
+
stream = File.open(tar_file)
|
79
|
+
else
|
80
|
+
stream = tar_file
|
81
|
+
end
|
82
|
+
|
83
|
+
Gem::Package::TarReader.new(stream) do |tar|
|
84
|
+
tar.each do |tarfile|
|
85
|
+
destination_file = File.join destination, tarfile.full_name
|
86
|
+
if tarfile.directory?
|
87
|
+
FileUtils.mkdir_p destination_file
|
88
|
+
else
|
89
|
+
destination_directory = File.dirname(destination_file)
|
90
|
+
FileUtils.mkdir_p destination_directory unless File.directory?(destination_directory)
|
91
|
+
File.open destination_file, 'wb' do |f|
|
92
|
+
f.print tarfile.read
|
93
|
+
end
|
94
|
+
end
|
95
|
+
tarfile.close unless tarfile.closed?
|
96
|
+
end
|
97
|
+
tar.close
|
96
98
|
end
|
97
|
-
|
98
|
-
|
99
|
-
stream.close
|
100
|
-
end
|
99
|
+
stream.close
|
100
|
+
end
|
101
101
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
102
|
+
# Method which unrar a rar file, if it is possible (proprietary format grr ...)
|
103
|
+
# @param rar_file [String] the rar file.
|
104
|
+
# @param destination [String] Destination of extracted data.
|
105
|
+
def rar rar_file, destination
|
106
|
+
require 'shellwords'
|
107
|
+
`which unrar`
|
108
|
+
if $?.success?
|
109
|
+
src = Shellwords.escape(rar_file)
|
110
|
+
destination = Shellwords.escape(destination)
|
111
|
+
`unrar e #{src} #{destination}`
|
112
|
+
else
|
113
|
+
puts 'Please install unrar : sudo apt-get install unrar'
|
114
|
+
end
|
114
115
|
end
|
115
|
-
end
|
116
116
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
117
|
+
# Method which un7zip a 7zip file.
|
118
|
+
# @param seven_zip_file [String] the 7zip file.
|
119
|
+
# @param destination [String] Destination of extracted data.
|
120
|
+
def seven_zip seven_zip_file, destination
|
121
|
+
require 'seven_zip_ruby'
|
122
|
+
File.open(seven_zip_file, 'rb') do |file|
|
123
|
+
SevenZipRuby::Reader.open(file) do |szr|
|
124
|
+
szr.extract_all destination
|
125
|
+
end
|
126
|
+
end
|
126
127
|
end
|
127
|
-
end
|
128
128
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
129
|
+
# Use first of all for seven zip format (little tip, can't call it directly).
|
130
|
+
def method_missing(m, *args, &block)
|
131
|
+
if (ext = File.extname(args[0]).delete('.') == '7z')
|
132
|
+
seven_zip(args[0], args[1])
|
133
|
+
else
|
134
|
+
raise "Format '#{ext.delete('.')}' not supported"
|
135
|
+
end
|
136
|
+
end
|
137
137
|
|
138
|
+
end
|
138
139
|
end
|
139
140
|
end
|
data/lib/components/generator.rb
CHANGED
@@ -1,47 +1,50 @@
|
|
1
1
|
require_relative 'generators'
|
2
2
|
|
3
|
+
module Reviser
|
4
|
+
module Components
|
5
|
+
|
6
|
+
# Generator is used to create a file result after the analysis.
|
7
|
+
# Currently, Generator supports HTML, XLS and CSV format.
|
8
|
+
#
|
9
|
+
# @author Renan Strauss
|
10
|
+
# @author Yann Prono
|
11
|
+
#
|
12
|
+
class Generator < Component
|
13
|
+
|
14
|
+
# Include all supported formats
|
15
|
+
include Generators
|
16
|
+
|
17
|
+
def initialize(data)
|
18
|
+
super data
|
19
|
+
end
|
3
20
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
# Include all supported formats
|
15
|
-
include Generators
|
16
|
-
|
17
|
-
def initialize(data)
|
18
|
-
super data
|
19
|
-
end
|
20
|
-
|
21
|
-
# Run the generation of results file in all asked formats by user.
|
22
|
-
def run
|
23
|
-
begin
|
24
|
-
if Cfg[:out_format].respond_to? 'each'
|
25
|
-
Cfg[:out_format].each { |f| send f.to_sym }
|
26
|
-
else
|
27
|
-
send Cfg[:out_format].to_sym
|
21
|
+
# Runs the generation of results file in all asked formats by user.
|
22
|
+
def run
|
23
|
+
begin
|
24
|
+
if Cfg[:out_format].respond_to? 'each'
|
25
|
+
Cfg[:out_format].each { |f| send f.to_sym }
|
26
|
+
else
|
27
|
+
send Cfg[:out_format].to_sym
|
28
|
+
end
|
29
|
+
rescue Object => e
|
30
|
+
@logger.h1 Logger::FATAL, "Wrong format : #{e.to_s}"
|
28
31
|
end
|
29
|
-
rescue Object => e
|
30
|
-
@logger.h1 Logger::FATAL, "Wrong format : #{e.to_s}"
|
31
32
|
end
|
32
|
-
end
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
34
|
+
# Gets all criterias of marking
|
35
|
+
# used to display informations in documents.
|
36
|
+
# @return [Array] Array with all criterias.
|
37
|
+
def criterias
|
38
|
+
@data.values.first.keys.unshift.map! { |cri| Generator.titleize(cri.to_s) }
|
39
|
+
end
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
# Quite handy
|
42
|
+
# @param str [String] string to titleize
|
43
|
+
# @return [String] cute string !
|
44
|
+
def self.titleize(str)
|
45
|
+
str.split(/_/).join(' ').capitalize
|
46
|
+
end
|
45
47
|
|
48
|
+
end
|
46
49
|
end
|
47
50
|
end
|