xlo 0.0.0.2 → 0.0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +21 -0
  3. data/bin/xlo +3 -3
  4. data/lib/xlo.rb +43 -25
  5. metadata +9 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 01beb03159bb72c950833c69c8ed0f5f07184529
4
- data.tar.gz: 3fdb630de4eacc67190f80048860858dd0ac746b
3
+ metadata.gz: 3030a9e4552d5b2b12aaaa956b74e7d5e4c993de
4
+ data.tar.gz: f53949894cdd67557bebfe49af4b2b383a178327
5
5
  SHA512:
6
- metadata.gz: d1517715c4bc0fdd15cb3a38fe8583376994e84820e72cbac3045118e60e3de73fc4935ceb8d77a5c98135f5c625c72ac9727cf1fc5648e73df253d357a61ee5
7
- data.tar.gz: 071cffed9cba6309f500bd82bdc2e328f44ef320da418ca586b351cbe3afb7198bcb88588b34490fc18b6eef01785f869cb533e82259d165cf60922857eed1a7
6
+ metadata.gz: ff9776f81a8d9031398cf7a0b1b8b2fa4f08fdd81ba2d50a2c5f75d44e532acefdf5ee3dbdc3e2eaa0dd6bc8c32fd16d4f3691ed630c1132bc1f0f2e3b69b213
7
+ data.tar.gz: 7e5d3e4ff0d02dfdca9b75c14b69184a277d1fa2bd52d61fbe243eaefeb3392ce4f06fab92794d0e1a2f9615329fed7f58ef60765fc6e86f7bebdbea9292702d
data/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # Xml Log Overview
2
+ XLO is a rnv/xmllint wrapper who captures the error generate by this validators and convert them into a csv file.
3
+
4
+ ## Instruction
5
+ 1. make all your xml file in the same folder
6
+ 2. execute xlo : `xlo rnc-schema xml-folder`
7
+
8
+ ## Installation
9
+
10
+ 1. `gem install xlo`
11
+ 2. `apt-get install rnv`
12
+ 3. `apt-get install xmllint`
13
+ 4. `xlo rnc-schema xml-folder`
14
+
15
+ ## Note
16
+ the code contains several functions who could be use to like a ruby api
17
+
18
+ ## Useful link
19
+
20
+ - http://www.davidashen.net/rnv.html
21
+ - http://rubygems.org/gems/xlo
data/bin/xlo CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'xlo'
3
+ require '../lib/xlo'
4
4
  rnv_arg = ARGV.shift
5
- xmllint_arg = ARGV.shift
5
+ folder_arg = ARGV.shift
6
6
  raise "missing argument(s) !" unless rnv_arg
7
- Xlo.main(rnv_arg,xmllint_arg)
7
+ Xlo.main(rnv_arg,folder_arg)
data/lib/xlo.rb CHANGED
@@ -1,27 +1,35 @@
1
+ require 'open3'
2
+
1
3
  class Xlo
2
4
 
3
- def self.fill_list (_dir)
5
+ def self.rnv_wrapper (_rnc, _dir)
4
6
  list = []
5
- Dir[_dir + "/" + "*.log"].each do |file|
6
- p file
7
- File.open(file, 'r') do |f1|
8
- while line = f1.gets
7
+ Dir[_dir + "/" + "*.xml"].each do |file|
8
+ stdout = Open3.capture3("rnv #{_rnc} #{file}")
9
+ stdout = stdout[1].split("\n")
10
+ stdout.each do |line|
9
11
  if (line.include?("error") && !line.include?("are invalid"))
10
12
  list << line
11
13
  end
12
- end
13
14
  end
14
15
  end
15
16
  return list
16
17
  end
17
18
 
18
- def self.create_error_dict (_list)
19
+ def self.rnv_error_dict (_list)
19
20
  error = {}
20
21
  _list.each do |el|
21
22
  type = el.split("error")[1].split(" ")[1]
22
- key = type + "; " + el[/\^.*/][1..-1]
23
- filename = File.basename(el.split("error")[0])
24
- filename[filename.length - 2] = ""
23
+ if (type == "attribute" || type == "element")
24
+ key = type + "; " + el[/\^.*/][1..-1]
25
+ filename = File.basename(el.split("error")[0])
26
+ filename[filename.length - 2] = ""
27
+ else
28
+ type = "other"
29
+ key = type + "; " + el.split("error:")[1]
30
+ filename = File.basename(el.split("error")[0])
31
+ filename[filename.length - 2] = ""
32
+ end
25
33
  if (error.has_key?(key))
26
34
  error[key] << " || " + filename
27
35
  else
@@ -31,40 +39,50 @@ class Xlo
31
39
  return error
32
40
  end
33
41
 
34
- def self.xmllint_error (_file,_error_dict)
42
+ def self.xmllint_wrapper (_dir)
35
43
  list = []
36
- File.open(_file).each do |line|
37
- if (!line.include?("^\n"))
38
- list << line.chomp
44
+ Dir[_dir + "/" + "*.xml"].each do |file|
45
+ stdout = Open3.capture3("xmllint #{file}")
46
+ stdout = stdout[1].split("\n")
47
+ stdout.each do |line|
48
+ if (!line.include?(" ^"))
49
+ list << line.chomp
50
+ end
39
51
  end
40
52
  end
41
53
 
54
+ error = {}
42
55
  list = list.values_at(* list.each_index.select {|i| i.even?})
43
56
  list.each do |el|
44
57
  split_el = el.split(" ")
45
58
  type = el[/element|attribute/]
46
59
  key = type + ";" + el.split(":")[-1]
47
60
  filename = File.basename(split_el[0])[0..-2]
48
- if (_error_dict.has_key?(key))
49
- _error_dict[key] << " || " + filename
61
+ if (error.has_key?(key))
62
+ error[key] << " || " + filename
50
63
  else
51
- _error_dict[key] = filename
64
+ error[key] = filename
52
65
  end
53
66
  end
67
+ return error
54
68
  end
55
69
 
56
- def self.main(_rnv_arg,_xmllint_arg)
70
+ def self.main(_rnv_arg,_folder_arg)
57
71
 
72
+ error = []
58
73
  f = File.new("error.csv", "w+")
59
74
  f.write("type; error; freq; files \n")
60
- error = self.create_error_dict(self.fill_list(_rnv_arg))
61
75
 
62
- if (_xmllint_arg != nil)
63
- xmllint_error(_xmllint_arg, error)
64
- end
65
- error.each do |entry|
66
- freq = entry[1].split("||").length.to_s
67
- f.write(entry.insert(1, freq).join("; ")[0..-2] + "\n" )
76
+ list = self.rnv_wrapper(_rnv_arg, _folder_arg)
77
+ error << self.rnv_error_dict(list)
78
+
79
+ error << self.xmllint_wrapper(_folder_arg)
80
+
81
+ error.each do |dict|
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
68
86
  end
69
87
  end
70
88
  end
metadata CHANGED
@@ -1,27 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xlo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.2
4
+ version: 0.0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Meoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-21 00:00:00.000000000 Z
11
+ date: 2016-06-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: An aggregator of xml log for rnv and xmllint error
14
14
  email: simonmeoni@aol.com
15
15
  executables:
16
16
  - xlo
17
17
  extensions: []
18
- extra_rdoc_files: []
18
+ extra_rdoc_files:
19
+ - README.md
19
20
  files:
21
+ - README.md
20
22
  - bin/xlo
21
23
  - lib/xlo.rb
22
24
  homepage: http://rubygems.org/gems/xlo
23
25
  licenses:
24
- - apache 2
26
+ - GPL-3.0
25
27
  metadata: {}
26
28
  post_install_message:
27
29
  rdoc_options: []
@@ -37,10 +39,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
37
39
  - - ">="
38
40
  - !ruby/object:Gem::Version
39
41
  version: '0'
40
- requirements: []
42
+ requirements:
43
+ - rnv, xmllint
41
44
  rubyforge_project:
42
45
  rubygems_version: 2.2.2
43
46
  signing_key:
44
47
  specification_version: 4
45
- summary: xml log overview
48
+ summary: Xml Log Overview
46
49
  test_files: []