xcop 0.5.3 → 0.5.4
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/.rubocop.yml +2 -0
- data/README.md +62 -1
- data/features/cli.feature +2 -4
- data/lib/xcop.rb +13 -2
- data/lib/xcop/version.rb +1 -1
- data/xcop.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65f4832fd6dcc3f17bec30dd2dd469779f6f99fe
|
4
|
+
data.tar.gz: 41882ead0d1b7481f9e1e9491122fccdaf8d9c4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 263c4b3643109e9dec1a7323661d3bc68793a1a893b4f95a673f90d191b2d29a676f694d67d504d805f276d2f9217d1cb03349d2fb157c4404ff9df049616fdb
|
7
|
+
data.tar.gz: '0845a146315f17aa769ac8db5cdfd2a39b95f9dd7f5bc90b943bb4ce88487b8973f4867d038f9c3c0cd2650571f138cdc62276ceeb40c31e4ce5f80f514ec3cd'
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -34,7 +34,27 @@ Run it locally and read its output:
|
|
34
34
|
$ xcop --help
|
35
35
|
```
|
36
36
|
|
37
|
-
|
37
|
+
To validate formatting of your XML files just pass their names
|
38
|
+
as arguments:
|
39
|
+
|
40
|
+
```bash
|
41
|
+
$ xcop file1.xml file2.xml
|
42
|
+
```
|
43
|
+
|
44
|
+
If your files are not formatted correctly and `xcop` complains, you
|
45
|
+
can ask it to "beautify" them, using `--fix` option:
|
46
|
+
|
47
|
+
```bash
|
48
|
+
$ xcop --fix broken-file.xml
|
49
|
+
```
|
50
|
+
|
51
|
+
To fix all files in the directory you can do:
|
52
|
+
|
53
|
+
```bash
|
54
|
+
$ xcop $(find . -name '*.xml')
|
55
|
+
```
|
56
|
+
|
57
|
+
## How to use in `Rakefile`?
|
38
58
|
|
39
59
|
This is what you need there:
|
40
60
|
|
@@ -48,6 +68,47 @@ Xcop::RakeTask.new(:xcop) do |task|
|
|
48
68
|
end
|
49
69
|
```
|
50
70
|
|
71
|
+
## How to use in Maven `pom.xml`?
|
72
|
+
|
73
|
+
You can integrate it with the help of
|
74
|
+
[maven-antrun-plugin](http://maven.apache.org/plugins/maven-antrun-plugin/):
|
75
|
+
|
76
|
+
```xml
|
77
|
+
<project>
|
78
|
+
[...]
|
79
|
+
<build>
|
80
|
+
[...]
|
81
|
+
<plugins>
|
82
|
+
[...]
|
83
|
+
<plugin>
|
84
|
+
<artifactId>maven-antrun-plugin</artifactId>
|
85
|
+
<version>1.8</version>
|
86
|
+
<executions>
|
87
|
+
<execution>
|
88
|
+
<phase>verify</phase>
|
89
|
+
<configuration>
|
90
|
+
<target>
|
91
|
+
<apply executable="xcop" failonerror="true">
|
92
|
+
<fileset dir=".">
|
93
|
+
<include name="**/*.xml"/>
|
94
|
+
<include name="**/*.xsd"/>
|
95
|
+
<exclude name="target/**/*"/>
|
96
|
+
<exclude name=".idea/**/*"/>
|
97
|
+
</fileset>
|
98
|
+
</apply>
|
99
|
+
</target>
|
100
|
+
</configuration>
|
101
|
+
<goals>
|
102
|
+
<goal>run</goal>
|
103
|
+
</goals>
|
104
|
+
</execution>
|
105
|
+
</executions>
|
106
|
+
</plugin>
|
107
|
+
</plugins>
|
108
|
+
</build>
|
109
|
+
</project>
|
110
|
+
```
|
111
|
+
|
51
112
|
## How to contribute?
|
52
113
|
|
53
114
|
Just submit a pull request. Make sure `rake` passes.
|
data/features/cli.feature
CHANGED
@@ -19,9 +19,8 @@ Feature: Command Line Processing
|
|
19
19
|
|
20
20
|
"""
|
21
21
|
When I run bin/xcop with "test.xml"
|
22
|
-
Then Stdout contains "
|
22
|
+
Then Stdout contains "pretty"
|
23
23
|
And Exit code is zero
|
24
|
-
And Stdout contains "Validating test.xml..."
|
25
24
|
|
26
25
|
Scenario: Validating correct XML file with license
|
27
26
|
Given I have a "licensed.xml" file with content:
|
@@ -40,9 +39,8 @@ Feature: Command Line Processing
|
|
40
39
|
which is very very strict!
|
41
40
|
"""
|
42
41
|
When I run bin/xcop with "--license LICENSE licensed.xml"
|
43
|
-
Then Stdout contains "
|
42
|
+
Then Stdout contains "pretty"
|
44
43
|
And Exit code is zero
|
45
|
-
And Stdout contains "Validating licensed.xml..."
|
46
44
|
|
47
45
|
Scenario: Validating incorrect XML file
|
48
46
|
Given I have a "abc.xml" file with content:
|
data/lib/xcop.rb
CHANGED
@@ -22,6 +22,7 @@
|
|
22
22
|
|
23
23
|
require 'nokogiri'
|
24
24
|
require 'differ'
|
25
|
+
require 'rainbow'
|
25
26
|
require_relative 'xcop/version'
|
26
27
|
|
27
28
|
# Xcop main module.
|
@@ -37,8 +38,9 @@ module Xcop
|
|
37
38
|
end
|
38
39
|
|
39
40
|
def run
|
41
|
+
puts 'Running xcop...'
|
42
|
+
puts "Inspecting #{pluralize(@files.length, 'file')}..."
|
40
43
|
@files.each do |f|
|
41
|
-
print "Validating #{f}... "
|
42
44
|
doc = Document.new(f)
|
43
45
|
diff = doc.diff
|
44
46
|
unless diff.empty?
|
@@ -52,8 +54,11 @@ module Xcop
|
|
52
54
|
raise "Broken license in #{f}"
|
53
55
|
end
|
54
56
|
end
|
55
|
-
print
|
57
|
+
print Rainbow('.').green
|
56
58
|
end
|
59
|
+
print "\n"
|
60
|
+
puts "#{pluralize(@files.length, 'file')} checked, \
|
61
|
+
everything looks #{Rainbow('pretty').green}"
|
57
62
|
end
|
58
63
|
|
59
64
|
# Fix them all.
|
@@ -64,6 +69,12 @@ module Xcop
|
|
64
69
|
print "done\n"
|
65
70
|
end
|
66
71
|
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def pluralize(num, text)
|
76
|
+
"#{num} #{num == 1 ? text : text + 's'}"
|
77
|
+
end
|
67
78
|
end
|
68
79
|
|
69
80
|
# One document.
|
data/lib/xcop/version.rb
CHANGED
data/xcop.gemspec
CHANGED
@@ -49,6 +49,7 @@ Gem::Specification.new do |s|
|
|
49
49
|
s.add_runtime_dependency 'nokogiri', '~>1.8'
|
50
50
|
s.add_runtime_dependency 'differ', '~>0.1.2'
|
51
51
|
s.add_runtime_dependency 'slop', '~>4.4'
|
52
|
+
s.add_runtime_dependency 'rainbow', '~>2.2'
|
52
53
|
s.add_development_dependency 'rake', '12.0.0'
|
53
54
|
s.add_development_dependency 'codecov', '0.1.10'
|
54
55
|
s.add_development_dependency 'rdoc', '4.2.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xcop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '4.4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rainbow
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.2'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.2'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rake
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|