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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa06bb31a6307eaf1ce56b0795be9724317f602a
4
- data.tar.gz: 626fd201fd723fd081fc112cb40e282f3d972a95
3
+ metadata.gz: 01042721d40f4868f1355ca93371d489f1b464c7
4
+ data.tar.gz: 6503c87b8e09558e0ca2b4431feee7aca28242d1
5
5
  SHA512:
6
- metadata.gz: 8329081d4b7977c9be2afcca650704e5dc77370af182772538dc27bf1c8568e1bd9e29a26a85c5d1ea52af1eb0feeedbb62ebf6ae4bd592b93f8143c11b2637f
7
- data.tar.gz: 1702c751578d7ff9ca5c6ad4b8353d9f21b7c907627d74d0d68980a535527c6481e35ab91333d163660c77c49958d77891dee22dbe24975af179bd82b79ba933
6
+ metadata.gz: ce82cc3f7318a3a0fc66f33159eec3f62432cda9280df83473ff8f32abbe22936fd5806138dd580f5ca24a5009386bbada55ffc47ed99e0097eb6a570f200581
7
+ data.tar.gz: eb150e198aa055abbf30b4510be56c0533750c5d8a02bb941b66f63dce59f39b6eb4b0c5c13e48737dbb07a8b6422984275879077612445e271e22ed0ec66d73
@@ -8,7 +8,7 @@ Feature: Rake tasks
8
8
  """
9
9
  require 'xcop/rake_task'
10
10
  Xcop::RakeTask.new(:xcop) do |task|
11
- task.includes = ['**/*.xml']
11
+ task.includes = ['good.xml']
12
12
  end
13
13
  """
14
14
  And I have a "good.xml" file with content:
@@ -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
@@ -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
- Differ.format = :color
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
- Differ.format = :color
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
@@ -25,5 +25,5 @@
25
25
  # Copyright:: Copyright (c) 2017 Yegor Bugayenko
26
26
  # License:: MIT
27
27
  module Xcop
28
- VERSION = '0.5.5'.freeze
28
+ VERSION = '0.5.6'.freeze
29
29
  end
@@ -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.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-14 00:00:00.000000000 Z
11
+ date: 2017-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri