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
@@ -11,68 +11,62 @@ require 'open3'
11
11
 
12
12
  require_relative '../helpers/criteria'
13
13
 
14
- module Components
15
- class Checker < Component
16
- include Helpers::Criteria
14
+ module Reviser
15
+ module Components
16
+ class Checker < Component
17
+ include Helpers::Criteria
17
18
 
18
- def initialize(data)
19
- super data
19
+ def initialize(data)
20
+ super data
20
21
 
21
- init_criteria_helper
22
+ @criteria = Hash.new
23
+ @output = Hash.new
22
24
 
23
- @results = {}
24
- end
25
+ @logger.h1 Logger::INFO, "Loading modules"
25
26
 
26
- # Yann : je ne recupere pas les datas de l'organiser,
27
- # Je considere que tous les projets sont dans le dossier courant.
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
- @results
40
- end
30
+ @logger.h1 Logger::INFO, "Loading labels"
31
+
32
+ [:criteria, :extensions].each { |x| load_labels x }
41
33
 
42
- private
34
+ @results = {}
35
+ end
43
36
 
44
- #
45
- # Being called in the project's directory,
46
- # this methods maps all the criterias to
47
- # their analysis value
48
- #
49
- def check(proj)
50
- # Init results
51
- @results[proj] = {}
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 Components
4
+ module Reviser
5
+ module Components
5
6
 
6
- # The module contains all methods to extract an archive
7
- # regardless the format.
8
- #
9
- # Convention over configuration !
10
- #
11
- # To add a new format, maybe you need to install the a gem.
12
- # Find your gem which uncompress a specified format on rubygems.org.
13
- # Add the line "gem <gem>" in the Gemfile and execute "bundle install"
14
- #
15
- # Now, you can write the method corresponding to the format.
16
- # The name of the method corresponds to the format.
17
- # For example, if you want to use 'rar' format, the name of the method will be: "rar"
18
- # Don't forget to require the gem: "require <gem>" at the beginning of the method!
19
- # the header of method looks like the following block:
20
- #
21
- # def <format> (archive, destination)
22
- # require <gem>
23
- # ...
24
- # end
25
- #
26
- # @author Anthony Cerf
27
- # @author Yann Prono
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
- # Method which unzip 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
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
- 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)
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
- # 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
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
- end
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)
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
- 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?
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
- tar.close
98
- end
99
- stream.close
100
- end
99
+ stream.close
100
+ end
101
101
 
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'
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
- # 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
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
- # 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
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
@@ -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
- 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
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
- # Get 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
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
- # Quite handy
42
- def self.titleize(str)
43
- str.split(/_/).join(' ').capitalize
44
- end
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