xcop 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/features/rake.feature +1 -1
- data/features/step_definitions/steps.rb +1 -1
- data/lib/xcop.rb +14 -6
- data/lib/xcop/version.rb +1 -1
- data/test/test_xcop.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01042721d40f4868f1355ca93371d489f1b464c7
|
4
|
+
data.tar.gz: 6503c87b8e09558e0ca2b4431feee7aca28242d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce82cc3f7318a3a0fc66f33159eec3f62432cda9280df83473ff8f32abbe22936fd5806138dd580f5ca24a5009386bbada55ffc47ed99e0097eb6a570f200581
|
7
|
+
data.tar.gz: eb150e198aa055abbf30b4510be56c0533750c5d8a02bb941b66f63dce59f39b6eb4b0c5c13e48737dbb07a8b6422984275879077612445e271e22ed0ec66d73
|
data/features/rake.feature
CHANGED
@@ -66,7 +66,7 @@ Then(/^Stdout is empty$/) do
|
|
66
66
|
end
|
67
67
|
|
68
68
|
Then(/^Exit code is zero$/) do
|
69
|
-
raise "Non-zero exit code #{@exitstatus}" unless @exitstatus == 0
|
69
|
+
raise "Non-zero exit code #{@exitstatus}:\n#{@stdout}" unless @exitstatus == 0
|
70
70
|
end
|
71
71
|
|
72
72
|
Then(/^Exit code is not zero$/) do
|
data/lib/xcop.rb
CHANGED
@@ -78,9 +78,7 @@ module Xcop
|
|
78
78
|
xml = Nokogiri::XML(File.open(@path), &:noblanks)
|
79
79
|
ideal = xml.to_xml(indent: 2)
|
80
80
|
now = File.read(@path)
|
81
|
-
|
82
|
-
return Differ.diff_by_line(ideal, now).to_s unless now == ideal
|
83
|
-
''
|
81
|
+
differ(ideal, now)
|
84
82
|
end
|
85
83
|
|
86
84
|
# Return the difference for the license.
|
@@ -89,9 +87,7 @@ module Xcop
|
|
89
87
|
comment = xml.xpath('/comment()')[0]
|
90
88
|
now = comment.nil? ? '' : comment.text.to_s.strip
|
91
89
|
ideal = license.strip
|
92
|
-
|
93
|
-
return Differ.diff_by_line(ideal, now).to_s unless now == ideal
|
94
|
-
''
|
90
|
+
differ(ideal, now)
|
95
91
|
end
|
96
92
|
|
97
93
|
# Fixes the document.
|
@@ -106,5 +102,17 @@ module Xcop
|
|
106
102
|
ideal = xml.to_xml(indent: 2)
|
107
103
|
File.write(@path, ideal)
|
108
104
|
end
|
105
|
+
|
106
|
+
private
|
107
|
+
|
108
|
+
def differ(ideal, fact)
|
109
|
+
return '' if ideal == fact
|
110
|
+
Differ.format = :color
|
111
|
+
Differ.diff_by_line(schars(ideal), schars(fact)).to_s
|
112
|
+
end
|
113
|
+
|
114
|
+
def schars(text)
|
115
|
+
text.gsub(/\n/, "\\n\n")
|
116
|
+
end
|
109
117
|
end
|
110
118
|
end
|
data/lib/xcop/version.rb
CHANGED
data/test/test_xcop.rb
CHANGED
@@ -39,6 +39,14 @@ class TestXcop < Minitest::Test
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
def test_file_without_tail_eol
|
43
|
+
Dir.mktmpdir 'test9' do |dir|
|
44
|
+
f = File.join(dir, 'no-eol.xml')
|
45
|
+
File.write(f, "<?xml version=\"1.0\"?>\n<x/>")
|
46
|
+
assert(Xcop::Document.new(f).diff != '')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
42
50
|
def test_license_presence
|
43
51
|
Dir.mktmpdir 'test2' do |dir|
|
44
52
|
f = File.join(dir, 'a.xml')
|
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.6
|
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-09-
|
11
|
+
date: 2017-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|