xcop 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d0587f8d49aed88e6e268948e67eea7c8ec6557e
4
- data.tar.gz: 834e3b41d80ecdaa50d0b1a4357d69009eaeee5a
3
+ metadata.gz: 65f4832fd6dcc3f17bec30dd2dd469779f6f99fe
4
+ data.tar.gz: 41882ead0d1b7481f9e1e9491122fccdaf8d9c4e
5
5
  SHA512:
6
- metadata.gz: d906e4dee068262203da8a251e7d4f1c225a53793f88f306efe671edc0a142351dc4a5c9d4f6601e994dd60c1064ff7cce9cd6980da857a54e6ecd07304dbee4
7
- data.tar.gz: 8b8f1c85855c25586c2d0d41a10e7941f551e560bc987bbb895597f3acdc7cc7c30d7912cc7e29570c344a5366845281faad99fa177e104f99fa5274550b0719
6
+ metadata.gz: 263c4b3643109e9dec1a7323661d3bc68793a1a893b4f95a673f90d191b2d29a676f694d67d504d805f276d2f9217d1cb03349d2fb157c4404ff9df049616fdb
7
+ data.tar.gz: '0845a146315f17aa769ac8db5cdfd2a39b95f9dd7f5bc90b943bb4ce88487b8973f4867d038f9c3c0cd2650571f138cdc62276ceeb40c31e4ce5f80f514ec3cd'
@@ -8,3 +8,5 @@ Metrics/MethodLength:
8
8
  Enabled: false
9
9
  Style/MultilineMethodCallIndentation:
10
10
  Enabled: false
11
+ Metrics/AbcSize:
12
+ Enabled: false
data/README.md CHANGED
@@ -34,7 +34,27 @@ Run it locally and read its output:
34
34
  $ xcop --help
35
35
  ```
36
36
 
37
- ## How to use in Rakefile?
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.
@@ -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 "OK"
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 "OK"
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:
@@ -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 "OK\n"
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.
@@ -25,5 +25,5 @@
25
25
  # Copyright:: Copyright (c) 2017 Yegor Bugayenko
26
26
  # License:: MIT
27
27
  module Xcop
28
- VERSION = '0.5.3'.freeze
28
+ VERSION = '0.5.4'.freeze
29
29
  end
@@ -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.3
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-25 00:00:00.000000000 Z
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