xlo 0.0.1.2 → 0.0.1.3
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/lib/xlo.rb +62 -50
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d00cebfb60d2fc43a0352b5459ece2ad2552ad8c
|
4
|
+
data.tar.gz: fc26cafa24e6c45efe222d45155e732f01e05ece
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 397058a1543886648f7db64835536e8a0698789c6236f5d04ac427b2c254958cc393ace3cee45be7c18827023378576884321c16ffc6dadab61a85b5a84d8cea
|
7
|
+
data.tar.gz: 9fb918377f7cb4680e56b30fa442a844da10ee9aabe160b50fffbcd268cee88d6e1121f2f2b377aedf130e16c617f1cf99e00d006027ac2a7961686aecd9d2e2
|
data/lib/xlo.rb
CHANGED
@@ -1,88 +1,100 @@
|
|
1
1
|
require 'open3'
|
2
2
|
|
3
3
|
class Xlo
|
4
|
+
attr_accessor :rnv, :xmllint, :csv
|
4
5
|
|
5
|
-
def
|
6
|
-
|
6
|
+
def initialize(_file)
|
7
|
+
@rnv = []
|
8
|
+
@xmllint = []
|
9
|
+
@csv = File.new(_file,"w+")
|
10
|
+
@csv << "type; error; freq; files \n"
|
11
|
+
@error = {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def rnv_wrapper (_rnc, _dir)
|
7
15
|
Dir[_dir + "/" + "*.xml"].each do |file|
|
8
16
|
stdout = Open3.capture3("rnv #{_rnc} #{file}")
|
9
17
|
stdout = stdout[1].split("\n")
|
10
18
|
stdout.each do |line|
|
11
|
-
|
12
|
-
list << line
|
13
|
-
end
|
19
|
+
@rnv << line
|
14
20
|
end
|
15
21
|
end
|
16
|
-
return list
|
17
22
|
end
|
18
23
|
|
19
|
-
def
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
error
|
24
|
+
def rnv_aggregate
|
25
|
+
@rnv.each do |el|
|
26
|
+
if (el.include?("error") && !el.include?("are invalid"))
|
27
|
+
|
28
|
+
type = el.split("error")[1].split(" ")[1]
|
29
|
+
|
30
|
+
if (type == "attribute" || type == "element")
|
31
|
+
key = type + "; " + el[/\^.*/][1..-1]
|
32
|
+
filename = File.basename(el.split("error")[0])
|
33
|
+
filename[filename.length - 2] = ""
|
34
|
+
else
|
35
|
+
type = "other"
|
36
|
+
key = type + "; " + el.split("error:")[1]
|
37
|
+
filename = File.basename(el.split("error")[0])
|
38
|
+
filename[filename.length - 2] = ""
|
39
|
+
end
|
40
|
+
|
41
|
+
if (@error.has_key?(key))
|
42
|
+
@error[key] << " || " + filename
|
43
|
+
else
|
44
|
+
@error[key] = filename
|
45
|
+
end
|
46
|
+
|
37
47
|
end
|
38
48
|
end
|
39
|
-
return error
|
40
49
|
end
|
41
50
|
|
42
|
-
def
|
43
|
-
list = []
|
51
|
+
def xmllint_wrapper (_dir)
|
44
52
|
Dir[_dir + "/" + "*.xml"].each do |file|
|
45
53
|
stdout = Open3.capture3("xmllint #{file}")
|
46
54
|
stdout = stdout[1].split("\n")
|
47
55
|
stdout.each do |line|
|
48
|
-
|
49
|
-
list << line.chomp
|
50
|
-
end
|
56
|
+
@xmllint << line
|
51
57
|
end
|
52
58
|
end
|
59
|
+
end
|
53
60
|
|
54
|
-
|
55
|
-
|
56
|
-
|
61
|
+
def xmllint_aggregate
|
62
|
+
|
63
|
+
@xmllint.delete_if {|el| el.include?("^")}
|
64
|
+
@xmllint.map { |e| e.chomp }
|
65
|
+
@xmllint = @xmllint.values_at(* @xmllint.each_index.select {|i| i.even?})
|
66
|
+
@xmllint.each do |el|
|
57
67
|
split_el = el.split(" ")
|
58
|
-
type = el[/element|attribute/]
|
68
|
+
type = el[/element|attribute|parser error/]
|
59
69
|
key = type + ";" + el.split(":")[-1]
|
60
70
|
filename = File.basename(split_el[0])[0..-2]
|
61
|
-
if (error.has_key?(key))
|
62
|
-
error[key] << " || " + filename
|
71
|
+
if (@error.has_key?(key))
|
72
|
+
@error[key] << " || " + filename
|
63
73
|
else
|
64
|
-
error[key] = filename
|
74
|
+
@error[key] = filename
|
65
75
|
end
|
66
76
|
end
|
67
|
-
|
77
|
+
end
|
78
|
+
|
79
|
+
def csv_writer
|
80
|
+
@error.each do |entry|
|
81
|
+
line = entry.dup
|
82
|
+
line[-1] = line[-1].split("||")[0..50].join
|
83
|
+
freq = entry[1].split("||").length
|
84
|
+
@csv.write(line.insert(1, freq.to_s).join(";")[0..-2] + "\n" )
|
85
|
+
end
|
68
86
|
end
|
69
87
|
|
70
88
|
def self.main(_rnv_arg,_folder_arg)
|
71
89
|
|
72
|
-
|
73
|
-
f = File.new("error.csv", "w+")
|
74
|
-
f.write("type; error; freq; files \n")
|
90
|
+
xlo = Xlo.new(File.new("error.csv", "w+"))
|
75
91
|
|
76
|
-
|
77
|
-
|
92
|
+
xlo.rnv_wrapper(_rnv_arg, _folder_arg)
|
93
|
+
xlo.rnv_aggregate
|
78
94
|
|
79
|
-
|
95
|
+
xlo.xmllint_wrapper(_folder_arg)
|
96
|
+
xlo.xmllint_aggregate
|
80
97
|
|
81
|
-
|
82
|
-
dict.each do |entry|
|
83
|
-
freq = entry[1].split("||").length.to_s
|
84
|
-
f.write(entry.insert(1, freq).join("; ")[0..-2] + "\n" )
|
85
|
-
end
|
86
|
-
end
|
98
|
+
xlo.csv_writer
|
87
99
|
end
|
88
100
|
end
|