xcop 0.8.0 → 0.10.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.
@@ -1,3 +1,5 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2017-2026 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
1
3
  Feature: Gem Package
2
4
  As a source code writer I want to be able to
3
5
  package the Gem into .gem file
@@ -1,3 +1,5 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2017-2026 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
1
3
  Feature: Rake tasks
2
4
  As a source code writer I want to be able to
3
5
  run Xcop from Rakefile
@@ -1,37 +1,21 @@
1
- # Copyright (c) 2017-2025 Yegor Bugayenko
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the 'Software'), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- # SOFTWARE.
1
+ # SPDX-FileCopyrightText: Copyright (c) 2017-2026 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
20
3
 
4
+ require 'English'
21
5
  require 'nokogiri'
22
- require 'tmpdir'
23
6
  require 'slop'
24
- require 'English'
7
+ require 'tmpdir'
25
8
 
26
9
  Before do
27
10
  @cwd = Dir.pwd
28
11
  @dir = Dir.mktmpdir('test')
29
12
  FileUtils.mkdir_p(@dir)
30
13
  Dir.chdir(@dir)
31
- @opts = Slop.parse ['-v', '-s', @dir] do |o|
32
- o.bool '-v', '--verbose'
33
- o.string '-s', '--source'
34
- end
14
+ @opts =
15
+ Slop.parse(['-v', '-s', @dir]) do |o|
16
+ o.bool('-v', '--verbose')
17
+ o.string('-s', '--source')
18
+ end
35
19
  end
36
20
 
37
21
  After do
@@ -51,19 +35,19 @@ When(%r{^I run bin/xcop with "([^"]*)"$}) do |arg|
51
35
  end
52
36
 
53
37
  Then(/^Stdout contains "([^"]*)"$/) do |txt|
54
- raise "STDOUT doesn't contain '#{txt}':\n#{@stdout}" unless @stdout.include?(txt)
38
+ raise(StandardError, "STDOUT doesn't contain '#{txt}':\n#{@stdout}") unless @stdout.include?(txt)
55
39
  end
56
40
 
57
41
  Then(/^Stdout is empty$/) do
58
- raise "STDOUT is not empty:\n#{@stdout}" unless @stdout == ''
42
+ raise(StandardError, "STDOUT is not empty:\n#{@stdout}") unless @stdout == ''
59
43
  end
60
44
 
61
45
  Then(/^Exit code is zero$/) do
62
- raise "Non-zero exit #{@exitstatus}:\n#{@stdout}" unless @exitstatus.zero?
46
+ raise(StandardError, "Non-zero exit #{@exitstatus}:\n#{@stdout}") unless @exitstatus.zero?
63
47
  end
64
48
 
65
49
  Then(/^Exit code is not zero$/) do
66
- raise 'Zero exit code' if @exitstatus.zero?
50
+ raise(StandardError, 'Zero exit code') if @exitstatus.zero?
67
51
  end
68
52
 
69
53
  When(/^I run bash with "([^"]*)"$/) do |text|
@@ -1,21 +1,4 @@
1
- # Copyright (c) 2017-2025 Yegor Bugayenko
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the 'Software'), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- # SOFTWARE.
1
+ # SPDX-FileCopyrightText: Copyright (c) 2017-2026 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
20
3
 
21
4
  require 'simplecov'
data/lib/xcop/cli.rb CHANGED
@@ -1,56 +1,53 @@
1
- # Copyright (c) 2017-2025 Yegor Bugayenko
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the 'Software'), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- # SOFTWARE.
1
+ # SPDX-FileCopyrightText: Copyright (c) 2017-2026 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
20
3
 
21
- require 'nokogiri'
22
4
  require 'differ'
5
+ require 'nokogiri'
23
6
  require 'rainbow'
24
- require_relative 'version'
25
7
  require_relative 'document'
8
+ require_relative 'version'
26
9
 
27
10
  # Command line interface.
28
11
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
29
- # Copyright:: Copyright (c) 2017-2025 Yegor Bugayenko
12
+ # Copyright:: Copyright (c) 2017-2026 Yegor Bugayenko
30
13
  # License:: MIT
31
14
  class Xcop::CLI
15
+ EXTENSIONS = %w[xml xsd xhtml xsl html].freeze
16
+
32
17
  def initialize(files, nocolor: false)
33
- @files = files
18
+ @files = files.flat_map { |f| File.directory?(f) ? Xcop::CLI.expand(f) : [f] }
34
19
  @nocolor = nocolor
35
20
  end
36
21
 
22
+ # Recursively collect XML-like files inside a directory.
23
+ def self.expand(dir)
24
+ EXTENSIONS.flat_map { |ext| Dir.glob(File.join(dir, '**', "*.#{ext}")) }.sort
25
+ end
26
+
37
27
  def run
38
28
  @files.each do |f|
39
29
  doc = Xcop::Document.new(f)
40
30
  diff = doc.diff(nocolor: @nocolor)
41
31
  unless diff.empty?
42
- puts diff
43
- raise "Invalid XML formatting in #{f}"
32
+ puts(diff)
33
+ raise(StandardError, "Invalid XML formatting in #{f}")
34
+ end
35
+ errors = doc.validate
36
+ unless errors.empty?
37
+ puts(errors.join("\n"))
38
+ raise(StandardError, "XSD validation failed in #{f}")
44
39
  end
45
40
  yield(f) if block_given?
46
41
  end
47
42
  end
48
43
 
49
- # Fix them all.
44
+ # Fix them all. The block, when given, receives the file path and a
45
+ # status symbol that is +:fixed+ when the file was rewritten and
46
+ # +:untouched+ when the file was already canonical.
50
47
  def fix
51
48
  @files.each do |f|
52
- Xcop::Document.new(f).fix
53
- yield(f) if block_given?
49
+ status = Xcop::Document.new(f).fix
50
+ yield(f, status) if block_given?
54
51
  end
55
52
  end
56
53
  end
data/lib/xcop/document.rb CHANGED
@@ -1,31 +1,15 @@
1
- # Copyright (c) 2017-2025 Yegor Bugayenko
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the 'Software'), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- # SOFTWARE.
1
+ # SPDX-FileCopyrightText: Copyright (c) 2017-2026 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
20
3
 
21
- require 'nokogiri'
22
4
  require 'differ'
5
+ require 'nokogiri'
23
6
  require 'rainbow'
7
+ require 'set'
24
8
  require_relative 'version'
25
9
 
26
10
  # One document.
27
11
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
28
- # Copyright:: Copyright (c) 2017-2025 Yegor Bugayenko
12
+ # Copyright:: Copyright (c) 2017-2026 Yegor Bugayenko
29
13
  # License:: MIT
30
14
  class Xcop::Document
31
15
  # Ctor.
@@ -36,21 +20,118 @@ class Xcop::Document
36
20
 
37
21
  # Return the difference, if any (empty string if everything is clean).
38
22
  def diff(nocolor: false)
39
- xml = Nokogiri::XML(File.open(@path), &:noblanks)
40
- ideal = xml.to_xml(indent: 2)
41
- now = File.read(@path)
42
- differ(ideal, now, nocolor: nocolor)
23
+ differ(ideal, File.read(@path), nocolor: nocolor)
43
24
  end
44
25
 
45
- # Fixes the document.
26
+ # Fixes the document, returning +:fixed+ when the file content
27
+ # changed on disk and +:untouched+ when the file was already
28
+ # canonical.
46
29
  def fix
47
- xml = Nokogiri::XML(File.open(@path), &:noblanks)
48
- ideal = xml.to_xml(indent: 2)
49
- File.write(@path, ideal)
30
+ canonical = ideal
31
+ return :untouched if canonical == File.read(@path)
32
+ File.write(@path, canonical)
33
+ :fixed
34
+ end
35
+
36
+ # Validates the document against its declared XSD schema, if any.
37
+ # Returns an array of error message strings (empty when valid or no
38
+ # schema declared); a declared but missing schema is itself an error.
39
+ def validate
40
+ xml = Nokogiri::XML(File.read(@path))
41
+ xsd = schema(xml)
42
+ return [] unless xsd
43
+ return ["schema file is absent at #{xsd}"] unless File.exist?(xsd)
44
+ Nokogiri::XML::Schema(File.read(xsd)).validate(xml).map(&:message)
50
45
  end
51
46
 
47
+ XSI_NS = 'http://www.w3.org/2001/XMLSchema-instance'.freeze
48
+
52
49
  private
53
50
 
51
+ # The canonical, well-formatted version of the document.
52
+ def ideal
53
+ xml = Nokogiri::XML(File.read(@path), &:noblanks)
54
+ reshape(xml)
55
+ text = xml.to_xml(indent: 2)
56
+ unused(xml).each do |prefix|
57
+ text =
58
+ if prefix.nil?
59
+ text.gsub(/\s+xmlns="[^"]*"/, '')
60
+ else
61
+ text.gsub(/\s+xmlns:#{Regexp.escape(prefix)}="[^"]*"/, '')
62
+ end
63
+ end
64
+ Nokogiri::XML(text, &:noblanks).to_xml(indent: 2)
65
+ end
66
+
67
+ # Rewrites every comment node into one of two canonical shapes so that
68
+ # +diff+ and +--fix+ can report and correct sloppy comment layout. A
69
+ # comment whose text has no end-of-line character is collapsed onto a
70
+ # single line as +<!-- text -->+. A comment whose text spans several
71
+ # lines is re-emitted with +<!--+ and +-->+ each alone on their own
72
+ # line and every body line trimmed to the comment's own indent.
73
+ def reshape(xml)
74
+ xml.traverse do |node|
75
+ next unless node.comment?
76
+ node.native_content = canonical(node)
77
+ end
78
+ end
79
+
80
+ # The canonical inner text (the part between +<!--+ and +-->+) for a
81
+ # single comment node, indented to match the node's depth.
82
+ def canonical(node)
83
+ raw = node.content
84
+ body = raw.strip
85
+ return " #{body} " unless raw.include?("\n")
86
+ indent = ' ' * depth(node)
87
+ body = body.split("\n").map { |line| line.strip.empty? ? '' : indent + line.strip }.join("\n")
88
+ "\n#{body}\n#{indent}"
89
+ end
90
+
91
+ # The number of ancestor elements of +node+, which equals the number
92
+ # of two-space indentation levels that +to_xml+ places before it.
93
+ def depth(node)
94
+ levels = 0
95
+ parent = node.parent
96
+ while parent && parent.element?
97
+ levels += 1
98
+ parent = parent.parent
99
+ end
100
+ levels
101
+ end
102
+
103
+ # Returns the set of namespace prefixes that are declared in +xml+
104
+ # but never referenced by any element or attribute. A +nil+ entry in
105
+ # the set represents the default namespace.
106
+ def unused(xml)
107
+ used = Set.new
108
+ declared = Set.new
109
+ xml.traverse do |node|
110
+ next unless node.is_a?(Nokogiri::XML::Element)
111
+ used << node.namespace.prefix if node.namespace
112
+ node.attribute_nodes.each do |attr|
113
+ used << attr.namespace.prefix if attr.namespace
114
+ end
115
+ node.namespace_definitions.each { |ns| declared << ns.prefix }
116
+ end
117
+ declared - used
118
+ end
119
+
120
+ def schema(xml)
121
+ root = xml.root
122
+ return unless root
123
+ plain = root.at_xpath('@xsi:noNamespaceSchemaLocation', 'xsi' => XSI_NS)
124
+ mapped = root.at_xpath('@xsi:schemaLocation', 'xsi' => XSI_NS)
125
+ location =
126
+ if plain
127
+ plain.value
128
+ elsif mapped
129
+ mapped.value.split.last
130
+ end
131
+ return unless location
132
+ File.expand_path(location, File.dirname(@path))
133
+ end
134
+
54
135
  def differ(ideal, fact, nocolor: false)
55
136
  return '' if ideal == fact
56
137
  if nocolor
@@ -1,22 +1,5 @@
1
- # Copyright (c) 2017-2025 Yegor Bugayenko
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the 'Software'), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- # SOFTWARE.
1
+ # SPDX-FileCopyrightText: Copyright (c) 2017-2026 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
20
3
 
21
4
  require 'rake'
22
5
  require 'rake/tasklib'
@@ -24,7 +7,7 @@ require_relative '../xcop/cli'
24
7
 
25
8
  # Xcop rake task.
26
9
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
27
- # Copyright:: Copyright (c) 2017-2025 Yegor Bugayenko
10
+ # Copyright:: Copyright (c) 2017-2026 Yegor Bugayenko
28
11
  # License:: MIT
29
12
  class Xcop::RakeTask < Rake::TaskLib
30
13
  attr_accessor :name, :fail_on_error, :excludes, :includes, :quiet
@@ -35,9 +18,9 @@ class Xcop::RakeTask < Rake::TaskLib
35
18
  @includes = %w[xml xsd xhtml xsl html].map { |e| "**/*.#{e}" }
36
19
  @excludes = []
37
20
  @quiet = false
38
- desc 'Run Xcop' unless ::Rake.application.last_description
21
+ desc('Run Xcop') unless ::Rake.application.last_description
39
22
  task(name, *args) do |_, task_args|
40
- RakeFileUtils.send(:verbose, true) do
23
+ RakeFileUtils.__send__(:verbose, true) do
41
24
  yield(*[self, task_args].slice(0, task_block.arity)) if block_given?
42
25
  run
43
26
  end
@@ -47,22 +30,23 @@ class Xcop::RakeTask < Rake::TaskLib
47
30
  private
48
31
 
49
32
  def run
50
- puts 'Running xcop...' unless @quiet
33
+ puts('Running xcop...') unless @quiet
51
34
  bad = Dir.glob(@excludes)
52
35
  good = Dir.glob(@includes).reject { |f| bad.include?(f) }
53
- puts "Inspecting #{pluralize(good.length, 'file')}..." unless @quiet
36
+ puts("Inspecting #{pluralize(good.length, 'file')}...") unless @quiet
54
37
  begin
55
38
  Xcop::CLI.new(good).run do
56
- print Rainbow('.').green unless @quiet
39
+ print(Rainbow('.').green) unless @quiet
57
40
  end
58
41
  rescue StandardError => e
59
- puts e.message
42
+ puts(e.message)
60
43
  abort(e.message)
61
44
  end
62
45
  return if @quiet
63
- puts \
46
+ puts(
64
47
  "\n#{pluralize(good.length, 'file')} checked, " \
65
48
  "everything looks #{Rainbow('pretty').green}"
49
+ )
66
50
  end
67
51
 
68
52
  def pluralize(num, text)
data/lib/xcop/version.rb CHANGED
@@ -1,27 +1,10 @@
1
- # Copyright (c) 2017-2025 Yegor Bugayenko
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the 'Software'), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- # SOFTWARE.
1
+ # SPDX-FileCopyrightText: Copyright (c) 2017-2026 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
20
3
 
21
4
  # Xcop main module.
22
5
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
23
- # Copyright:: Copyright (c) 2017-2025 Yegor Bugayenko
6
+ # Copyright:: Copyright (c) 2017-2026 Yegor Bugayenko
24
7
  # License:: MIT
25
8
  module Xcop
26
- VERSION = '0.8.0'.freeze
9
+ VERSION = '0.10.0'.freeze
27
10
  end
data/xcop.gemspec CHANGED
@@ -1,22 +1,5 @@
1
- # Copyright (c) 2017-2025 Yegor Bugayenko
2
- #
3
- # Permission is hereby granted, free of charge, to any person obtaining a copy
4
- # of this software and associated documentation files (the 'Software'), to deal
5
- # in the Software without restriction, including without limitation the rights
6
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
- # copies of the Software, and to permit persons to whom the Software is
8
- # furnished to do so, subject to the following conditions:
9
- #
10
- # The above copyright notice and this permission notice shall be included in all
11
- # copies or substantial portions of the Software.
12
- #
13
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
- # SOFTWARE.
1
+ # SPDX-FileCopyrightText: Copyright (c) 2017-2026 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
20
3
 
21
4
  require 'English'
22
5
 
@@ -25,7 +8,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
25
8
  require_relative 'lib/xcop/version'
26
9
 
27
10
  Gem::Specification.new do |s|
28
- s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
11
+ s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to?(:required_rubygems_version=)
29
12
  s.required_ruby_version = '>= 2.2'
30
13
  s.name = 'xcop'
31
14
  s.version = Xcop::VERSION
@@ -35,13 +18,13 @@ Gem::Specification.new do |s|
35
18
  s.description = 'Validates XML-like documents for proper formatting'
36
19
  s.authors = ['Yegor Bugayenko']
37
20
  s.email = 'yegor256@gmail.com'
38
- s.homepage = 'http://github.com/yegor256/xcop'
39
- s.files = `git ls-files`.split($RS)
21
+ s.homepage = 'https://github.com/yegor256/xcop'
22
+ s.files = `git ls-files | grep -v -E '^(test/|\\.|renovate)'`.split($RS)
40
23
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
41
24
  s.rdoc_options = ['--charset=UTF-8']
42
25
  s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
43
- s.add_dependency 'differ', '~>0.1.2'
44
- s.add_dependency 'nokogiri', '~>1.10'
45
- s.add_dependency 'rainbow', '~>3.0'
46
- s.add_dependency 'slop', '~>4.4'
26
+ s.add_dependency('differ', '~>0.1.2')
27
+ s.add_dependency('nokogiri', '~>1.8')
28
+ s.add_dependency('rainbow', '~>3.0')
29
+ s.add_dependency('slop', '~>4.4')
47
30
  end
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.8.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-18 00:00:00.000000000 Z
11
+ date: 2026-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: differ
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.10'
33
+ version: '1.8'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.10'
40
+ version: '1.8'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rainbow
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -75,26 +75,17 @@ extra_rdoc_files:
75
75
  - README.md
76
76
  - LICENSE.txt
77
77
  files:
78
- - ".0pdd.yml"
79
- - ".gitattributes"
80
- - ".github/workflows/actionlint.yml"
81
- - ".github/workflows/copyrights.yml"
82
- - ".github/workflows/pdd.yml"
83
- - ".github/workflows/rake.yml"
84
- - ".github/workflows/xcop.yml"
85
- - ".github/workflows/yamllint.yml"
86
- - ".gitignore"
87
- - ".pdd"
88
- - ".rubocop.yml"
89
- - ".rultor.yml"
90
- - ".simplecov"
91
78
  - Gemfile
79
+ - Gemfile.lock
92
80
  - LICENSE.txt
81
+ - LICENSES/MIT.txt
93
82
  - README.md
83
+ - REUSE.toml
94
84
  - Rakefile
95
85
  - bin/xcop
96
86
  - cucumber.yml
97
87
  - features/cli.feature
88
+ - features/comments.feature
98
89
  - features/gem_package.feature
99
90
  - features/rake.feature
100
91
  - features/step_definitions/steps.rb
@@ -104,12 +95,8 @@ files:
104
95
  - lib/xcop/rake_task.rb
105
96
  - lib/xcop/version.rb
106
97
  - logo.svg
107
- - renovate.json
108
- - test/test__helper.rb
109
- - test/test_document.rb
110
- - test/test_rake_task.rb
111
98
  - xcop.gemspec
112
- homepage: http://github.com/yegor256/xcop
99
+ homepage: https://github.com/yegor256/xcop
113
100
  licenses:
114
101
  - MIT
115
102
  metadata:
data/.0pdd.yml DELETED
@@ -1,31 +0,0 @@
1
- # (The MIT License)
2
- #
3
- # Copyright (c) 2017-2025 Yegor Bugayenko
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the 'Software'), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in all
13
- # copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- # SOFTWARE.
22
- ---
23
- errors:
24
- - yegor256@gmail.com
25
- # alerts:
26
- # github:
27
- # - yegor256
28
-
29
- tags:
30
- - pdd
31
- - bug
data/.gitattributes DELETED
@@ -1,7 +0,0 @@
1
- # Check out all text files in UNIX format, with LF as end of line
2
- # Don't change this file. If you have any ideas about it, please
3
- # submit a separate issue about it and we'll discuss.
4
-
5
- * text=auto eol=lf
6
- *.java ident
7
- *.xml ident