pronto-xmllint 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6b4c55f784f295bfdfbfa761bcab60ebaaae374a2b38b1c365568e7ba04d5ea8
4
+ data.tar.gz: 2ff429434206d0f18fd007a9317eedb1068d35163f912cfff4d030c1ceea516c
5
+ SHA512:
6
+ metadata.gz: d12e21a40a3a7398ed2a965d57d1f383dad6a0ddddaf435942a098adb2e1350e3e3975e717df3abbfe314589f8e762a57bf0f56628d9fa0ff00e4e7dd73590d1
7
+ data.tar.gz: ece266ac57a309ef17ea78af1324ff4b7ffe28754ec24eae13e5e22c1472bd107058aa5968bb946ab5e0524d3d69791edb9d610de97fcf9c68993137e755c982
@@ -0,0 +1,9 @@
1
+ # Pronto runner for xmllint
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/pronto-xmllint.svg)](http://badge.fury.io/rb/pronto-xmllint)
4
+
5
+ Pronto runner for [xmllint](http://xmlsoft.org/xmllint.html). [What is Pronto?](https://github.com/prontolabs/pronto)
6
+
7
+ ## Prerequisites
8
+
9
+ You need to have `xmllint` present in the system, found via `$PATH`
@@ -0,0 +1 @@
1
+ require_relative 'xmllint_runner'
@@ -0,0 +1,58 @@
1
+ require 'pronto'
2
+ require 'shellwords'
3
+
4
+ module Pronto
5
+ class XMLLintRunner < Runner
6
+ extend Forwardable
7
+
8
+ EXTENSION = /^\..*xml$/
9
+
10
+ def_delegator self, :checkable?
11
+
12
+ def run
13
+ return [] if !@patches || @patches.count.zero?
14
+
15
+ @patches
16
+ .select { |patch| patch.additions > 0 }
17
+ .map { |patch| inspect(patch) }
18
+ .flatten.compact
19
+ end
20
+
21
+ class << self
22
+ def checkable?(path)
23
+ path_has_extension?(path)
24
+ end
25
+
26
+ def path_has_extension?(path)
27
+ !(EXTENSION =~ path.extname).nil?
28
+ end
29
+
30
+ end
31
+
32
+ private :checkable?
33
+ private
34
+
35
+ def repo_path
36
+ @repo_path ||= @patches.first.repo.path
37
+ end
38
+
39
+ def inspect(patch)
40
+ new_message('XMLLint failed.') if run_xmllint(patch).nonzero?
41
+ end
42
+
43
+ def new_message(offence)
44
+ level = :error
45
+
46
+ Message.new(nil, nil, level, offence, nil, self.class)
47
+ end
48
+
49
+ def run_xmllint(patch)
50
+ Dir.chdir(repo_path) do
51
+ escaped_file_path = Shellwords.escape(patch.new_file_full_path.to_s)
52
+ `xmllint --noout #{escaped_file_path}`
53
+ end
54
+ return $?.exitstatus
55
+ end
56
+
57
+ end
58
+ end
@@ -0,0 +1,5 @@
1
+ module Pronto
2
+ module XMLLintVersion
3
+ VERSION = '0.1.0'.freeze
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pronto-xmllint
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Paulius Mazeika
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-06-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pronto
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.10.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.10.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '11.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '11.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.4'
55
+ description:
56
+ email:
57
+ executables: []
58
+ extensions: []
59
+ extra_rdoc_files:
60
+ - README.md
61
+ files:
62
+ - README.md
63
+ - lib/pronto/xmllint.rb
64
+ - lib/pronto/xmllint_runner.rb
65
+ - lib/pronto/xmllint_version.rb
66
+ homepage:
67
+ licenses: []
68
+ metadata: {}
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: 2.0.0
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements:
84
+ - xmllint (in PATH)
85
+ rubygems_version: 3.0.3
86
+ signing_key:
87
+ specification_version: 4
88
+ summary: Pronto runner for XMLLint
89
+ test_files: []