pdd 0.24.0 → 0.24.2

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.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +17 -30
  3. data/Gemfile.lock +194 -0
  4. data/LICENSE.txt +1 -1
  5. data/LICENSES/MIT.txt +21 -0
  6. data/README.md +99 -100
  7. data/REUSE.toml +41 -0
  8. data/Rakefile +4 -31
  9. data/assets/puzzles.xsd +3 -22
  10. data/assets/puzzles.xsl +3 -22
  11. data/assets/puzzles_json.xsl +4 -23
  12. data/bin/pdd +6 -22
  13. data/cucumber.yml +3 -0
  14. data/features/applies_rules.feature +2 -0
  15. data/features/avoiding_duplicates.feature +2 -0
  16. data/features/catches_broken_puzzles.feature +2 -0
  17. data/features/cli.feature +2 -0
  18. data/features/gem_package.feature +2 -0
  19. data/features/html_output.feature +2 -0
  20. data/features/json_output.feature +2 -0
  21. data/features/parsing.feature +2 -0
  22. data/features/rake.feature +2 -2
  23. data/features/remove.feature +3 -0
  24. data/features/step_definitions/steps.rb +2 -19
  25. data/features/support/env.rb +2 -19
  26. data/features/unicode.feature +2 -0
  27. data/features/uses_config.feature +2 -1
  28. data/lib/pdd/puzzle.rb +2 -19
  29. data/lib/pdd/rake_task.rb +3 -1
  30. data/lib/pdd/rule/duplicates.rb +2 -19
  31. data/lib/pdd/rule/estimates.rb +2 -19
  32. data/lib/pdd/rule/roles.rb +2 -19
  33. data/lib/pdd/rule/text.rb +2 -19
  34. data/lib/pdd/source.rb +2 -19
  35. data/lib/pdd/sources.rb +2 -19
  36. data/lib/pdd/version.rb +4 -21
  37. data/lib/pdd.rb +3 -20
  38. data/pdd.gemspec +9 -25
  39. data/test_assets/aladdin.jpg +0 -0
  40. data/test_assets/elegant-objects.png +0 -0
  41. data/test_assets/puzzles/1-04e35eb3 +1 -1
  42. data/test_assets/puzzles/132-bc1dfafe +1 -1
  43. data/test_assets/puzzles/1425-59819ae3 +5 -5
  44. data/test_assets/puzzles/42-0d933cc0 +1 -1
  45. data/test_assets/puzzles/91-ecb9aa47 +1 -1
  46. data/test_assets/puzzles/93-641fe341 +1 -1
  47. data/utils/glob.rb +2 -19
  48. metadata +24 -33
  49. data/.0pdd.yml +0 -9
  50. data/.gitattributes +0 -12
  51. data/.github/workflows/codecov.yml +0 -23
  52. data/.github/workflows/pdd.yml +0 -15
  53. data/.github/workflows/rake.yml +0 -24
  54. data/.github/workflows/xcop.yml +0 -15
  55. data/.gitignore +0 -8
  56. data/.overcommit.yml +0 -96
  57. data/.pdd +0 -27
  58. data/.rubocop.yml +0 -32
  59. data/.rultor.yml +0 -22
  60. data/.simplecov +0 -35
  61. data/test/test__helper.rb +0 -43
  62. data/test/test_duplicates.rb +0 -48
  63. data/test/test_estimates.rb +0 -47
  64. data/test/test_many.rb +0 -42
  65. data/test/test_pdd.rb +0 -111
  66. data/test/test_rake_task.rb +0 -18
  67. data/test/test_roles.rb +0 -56
  68. data/test/test_source.rb +0 -396
  69. data/test/test_source_todo.rb +0 -295
  70. data/test/test_sources.rb +0 -137
  71. data/test/test_text.rb +0 -39
@@ -1,48 +0,0 @@
1
- # Copyright (c) 2014-2024 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.
20
-
21
- require 'minitest/autorun'
22
- require 'nokogiri'
23
- require_relative '../lib/pdd/rule/duplicates'
24
-
25
- # PDD::Rule::MaxDuplicates class test.
26
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
27
- # Copyright:: Copyright (c) 2014-2024 Yegor Bugayenko
28
- # License:: MIT
29
- class TestMaxDuplicates < Minitest::Test
30
- def test_max_duplicates
31
- rule = PDD::Rule::MaxDuplicates.new(
32
- Nokogiri::XML::Document.parse(
33
- '<puzzles><puzzle><body>test</body></puzzle>
34
- <puzzle><body>test</body></puzzle></puzzles>'
35
- ), 1
36
- )
37
- assert !rule.errors.empty?, 'why it is empty?'
38
- end
39
-
40
- def test_max_duplicates_without_errors
41
- rule = PDD::Rule::MaxDuplicates.new(
42
- Nokogiri::XML::Document.parse(
43
- '<puzzles><puzzle><body>hello</body></puzzle></puzzles>'
44
- ), 1
45
- )
46
- assert rule.errors.empty?, 'it has to be empty!'
47
- end
48
- end
@@ -1,47 +0,0 @@
1
- # Copyright (c) 2014-2024 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.
20
-
21
- require 'minitest/autorun'
22
- require 'nokogiri'
23
- require_relative '../lib/pdd/rule/estimates'
24
-
25
- # PDD::Rule::Estimate module tests.
26
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
27
- # Copyright:: Copyright (c) 2014-2024 Yegor Bugayenko
28
- # License:: MIT
29
- class TestEstimates < Minitest::Test
30
- def test_min
31
- rule = PDD::Rule::Estimate::Min.new(
32
- Nokogiri::XML::Document.parse(
33
- '<puzzles><puzzle><estimate>15</estimate></puzzle></puzzles>'
34
- ), 30
35
- )
36
- assert !rule.errors.empty?, 'why it is empty?'
37
- end
38
-
39
- def test_max
40
- rule = PDD::Rule::Estimate::Max.new(
41
- Nokogiri::XML::Document.parse(
42
- '<puzzles><puzzle><estimate>30</estimate></puzzle></puzzles>'
43
- ), 15
44
- )
45
- assert !rule.errors.empty?, 'why it is empty?'
46
- end
47
- end
data/test/test_many.rb DELETED
@@ -1,42 +0,0 @@
1
- # Copyright (c) 2014-2024 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.
20
-
21
- require 'minitest/autorun'
22
- require 'tmpdir'
23
- require_relative '../lib/pdd'
24
- require_relative '../lib/pdd/sources'
25
-
26
- # Test many puzzles to make sure their IDs are correct.
27
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
28
- # Copyright:: Copyright (c) 2014-2024 Yegor Bugayenko
29
- # License:: MIT
30
- class TestMany < Minitest::Test
31
- def test_parsing
32
- Dir['./test_assets/puzzles/**'].each do |p|
33
- name = File.basename(p)
34
- list = PDD::Source.new("./test_assets/puzzles/#{name}", 'hey').puzzles
35
- assert_equal 1, list.size
36
- puzzle = list.first
37
- puts "#{name}: \"#{puzzle.props[:body]}\""
38
- next if name.start_with?('_')
39
- assert_equal name, puzzle.props[:id]
40
- end
41
- end
42
- end
data/test/test_pdd.rb DELETED
@@ -1,111 +0,0 @@
1
- # Copyright (c) 2014-2024 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.
20
-
21
- require 'minitest/autorun'
22
- require 'nokogiri'
23
- require 'tmpdir'
24
- require 'slop'
25
- require_relative '../lib/pdd'
26
-
27
- # PDD main module test.
28
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
29
- # Copyright:: Copyright (c) 2014-2024 Yegor Bugayenko
30
- # License:: MIT
31
- class TestPDD < Minitest::Test
32
- def test_basic
33
- Dir.mktmpdir 'test' do |dir|
34
- opts = opts(['-q', '-s', dir, '-e', '**/*.png', '-r', 'max-estimate:15'])
35
- File.write(File.join(dir, 'a.txt'), "\x40todo #55 hello!")
36
- matches(
37
- Nokogiri::XML(PDD::Base.new(opts).xml),
38
- [
39
- '/processing-instruction("xml-stylesheet")[contains(.,".xsl")]',
40
- '/puzzles/@version',
41
- '/puzzles/@date',
42
- '/puzzles[count(puzzle)=1]',
43
- '/puzzles/puzzle[file="a.txt"]'
44
- ]
45
- )
46
- end
47
- end
48
-
49
- def test_rules_failure
50
- Dir.mktmpdir 'test' do |dir|
51
- opts = opts(['-q', '-s', dir, '-e', '**/*.png', '-r', 'min-estimate:30'])
52
- File.write(File.join(dir, 'a.txt'), "\x40todo #90 hello!")
53
- assert_raises PDD::Error do
54
- PDD::Base.new(opts).xml
55
- end
56
- end
57
- end
58
-
59
- def test_git_repo
60
- skip if Gem.win_platform?
61
- Dir.mktmpdir 'test' do |dir|
62
- opts = opts(['-q', '-s', dir])
63
- raise unless system("
64
- set -e
65
- cd '#{dir}'
66
- git init --quiet .
67
- git config user.email test@teamed.io
68
- git config user.name 'Mr. Tester'
69
- mkdir 'a long dir name'
70
- cd 'a long dir name'
71
- mkdir 'a kid'
72
- cd 'a kid'
73
- echo '\x40todo #1 this is some puzzle' > '.это файл.txt'
74
- cd ../..
75
- git add -f .
76
- git commit --quiet -am 'first version'
77
- ")
78
-
79
- matches(
80
- Nokogiri::XML(PDD::Base.new(opts).xml),
81
- [
82
- '/puzzles[count(puzzle)=1]',
83
- '/puzzles/puzzle[id]',
84
- '/puzzles/puzzle[file="a long dir name/a kid/.это файл.txt"]',
85
- '/puzzles/puzzle[author="Mr. Tester"]',
86
- '/puzzles/puzzle[email="test@teamed.io"]',
87
- '/puzzles/puzzle[time]'
88
- ]
89
- )
90
- end
91
- end
92
-
93
- private
94
-
95
- def opts(args)
96
- Slop.parse args do |o|
97
- o.bool '-v', '--verbose'
98
- o.bool '-q', '--quiet'
99
- o.bool '--skip-errors'
100
- o.string '-s', '--source'
101
- o.array '-e', '--exclude'
102
- o.array '-r', '--rule'
103
- end
104
- end
105
-
106
- def matches(xml, xpaths)
107
- xpaths.each do |xpath|
108
- raise "doesn't match '#{xpath}': #{xml}" unless xml.xpath(xpath).size == 1
109
- end
110
- end
111
- end
@@ -1,18 +0,0 @@
1
- require 'minitest/autorun'
2
- require 'tmpdir'
3
- require 'rake'
4
- require_relative '../lib/pdd/rake_task'
5
-
6
- # Test for RakeTask
7
- class TestRakeTask < Minitest::Test
8
- def test_basic
9
- Dir.mktmpdir 'test' do |dir|
10
- file = File.join(dir, 'a.txt')
11
- File.write(file, "\x40todo #55 hello!")
12
- PDD::RakeTask.new(:pdd1) do |task|
13
- task.quiet = true
14
- end
15
- Rake::Task['pdd1'].invoke
16
- end
17
- end
18
- end
data/test/test_roles.rb DELETED
@@ -1,56 +0,0 @@
1
- # Copyright (c) 2014-2024 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.
20
-
21
- require 'minitest/autorun'
22
- require 'nokogiri'
23
- require_relative '../lib/pdd/rule/roles'
24
-
25
- # PDD::Rule::Role module tests.
26
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
27
- # Copyright:: Copyright (c) 2014-2024 Yegor Bugayenko
28
- # License:: MIT
29
- class TestRoles < Minitest::Test
30
- def test_incorrect_role
31
- rule = PDD::Rule::Roles::Available.new(
32
- Nokogiri::XML::Document.parse(
33
- '<puzzles><puzzle><role>D</role></puzzle></puzzles>'
34
- ), 'A,B,C'
35
- )
36
- assert !rule.errors.empty?, 'why it is empty?'
37
- end
38
-
39
- def test_correct_role
40
- rule = PDD::Rule::Roles::Available.new(
41
- Nokogiri::XML::Document.parse(
42
- '<puzzles><puzzle><role>F</role></puzzle></puzzles>'
43
- ), 'F,E,G'
44
- )
45
- assert rule.errors.empty?, 'why it is not empty?'
46
- end
47
-
48
- def test_empty_role
49
- rule = PDD::Rule::Roles::Available.new(
50
- Nokogiri::XML::Document.parse(
51
- '<puzzles><puzzle></puzzle></puzzles>'
52
- ), 'T,R,L'
53
- )
54
- assert !rule.errors.empty?, 'why it is empty?'
55
- end
56
- end