pdd 0.23.2 → 0.24.1
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.
- checksums.yaml +4 -4
- data/.0pdd.yml +3 -0
- data/.github/workflows/actionlint.yml +25 -0
- data/.github/workflows/codecov.yml +18 -9
- data/.github/workflows/copyrights.yml +19 -0
- data/.github/workflows/markdown-lint.yml +19 -0
- data/.github/workflows/pdd.yml +8 -4
- data/.github/workflows/rake.yml +13 -8
- data/.github/workflows/reuse.yml +19 -0
- data/.github/workflows/typos.yml +19 -0
- data/.github/workflows/xcop.yml +6 -2
- data/.github/workflows/yamllint.yml +19 -0
- data/.gitignore +12 -5
- data/.markdownlint.yml +6 -0
- data/.pdd +1 -1
- data/.rubocop.yml +12 -2
- data/.rultor.yml +7 -2
- data/.simplecov +16 -36
- data/Gemfile +16 -30
- data/Gemfile.lock +173 -0
- data/LICENSE.txt +1 -1
- data/LICENSES/MIT.txt +21 -0
- data/README.md +152 -57
- data/REUSE.toml +43 -0
- data/Rakefile +7 -31
- data/assets/puzzles.xsd +3 -22
- data/assets/puzzles.xsl +3 -22
- data/assets/puzzles_json.xsl +60 -0
- data/bin/pdd +17 -24
- data/cucumber.yml +4 -0
- data/features/applies_rules.feature +2 -0
- data/features/avoiding_duplicates.feature +2 -0
- data/features/catches_broken_puzzles.feature +2 -0
- data/features/cli.feature +48 -5
- data/features/gem_package.feature +2 -0
- data/features/html_output.feature +2 -0
- data/features/json_output.feature +24 -0
- data/features/parsing.feature +2 -0
- data/features/rake.feature +2 -2
- data/features/remove.feature +2 -0
- data/features/step_definitions/steps.rb +11 -20
- data/features/support/env.rb +2 -19
- data/features/unicode.feature +2 -0
- data/features/uses_config.feature +2 -1
- data/lib/pdd/puzzle.rb +2 -19
- data/lib/pdd/rake_task.rb +3 -0
- data/lib/pdd/rule/duplicates.rb +2 -19
- data/lib/pdd/rule/estimates.rb +2 -19
- data/lib/pdd/rule/roles.rb +2 -19
- data/lib/pdd/rule/text.rb +2 -19
- data/lib/pdd/source.rb +34 -35
- data/lib/pdd/sources.rb +2 -19
- data/lib/pdd/version.rb +4 -21
- data/lib/pdd.rb +3 -20
- data/pdd.gemspec +8 -24
- data/test/test__helper.rb +24 -20
- data/test/test_duplicates.rb +5 -22
- data/test/test_estimates.rb +5 -22
- data/test/test_many.rb +3 -20
- data/test/test_pdd.rb +4 -21
- data/test/test_rake_task.rb +3 -0
- data/test/test_roles.rb +6 -23
- data/test/test_source.rb +17 -34
- data/test/test_source_todo.rb +121 -20
- data/test/test_sources.rb +4 -21
- data/test/test_text.rb +4 -21
- data/test_assets/aladdin.jpg +0 -0
- data/test_assets/elegant-objects.png +0 -0
- data/test_assets/puzzles/1-04e35eb3 +1 -1
- data/test_assets/puzzles/132-bc1dfafe +1 -1
- data/test_assets/puzzles/1425-59819ae3 +5 -5
- data/test_assets/puzzles/42-0d933cc0 +1 -1
- data/test_assets/puzzles/44-660e9d6f +2 -2
- data/test_assets/puzzles/91-ecb9aa47 +1 -1
- data/test_assets/puzzles/93-641fe341 +1 -1
- data/utils/glob.rb +2 -19
- metadata +33 -11
- data/.overcommit.yml +0 -96
data/test/test__helper.rb
CHANGED
@@ -1,29 +1,33 @@
|
|
1
|
-
# Copyright (c) 2014-
|
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) 2014-2025 Yegor Bugayenko
|
2
|
+
# SPDX-License-Identifier: MIT
|
20
3
|
|
21
4
|
$stdout.sync = true
|
22
5
|
|
23
6
|
require 'simplecov'
|
24
|
-
|
7
|
+
require 'simplecov-cobertura'
|
8
|
+
unless SimpleCov.running
|
9
|
+
SimpleCov.command_name('test')
|
10
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
|
11
|
+
[
|
12
|
+
SimpleCov::Formatter::HTMLFormatter,
|
13
|
+
SimpleCov::Formatter::CoberturaFormatter
|
14
|
+
]
|
15
|
+
)
|
16
|
+
SimpleCov.minimum_coverage 100
|
17
|
+
SimpleCov.minimum_coverage_by_file 100
|
18
|
+
SimpleCov.start do
|
19
|
+
add_filter 'test/'
|
20
|
+
add_filter 'vendor/'
|
21
|
+
add_filter 'target/'
|
22
|
+
track_files 'lib/**/*.rb'
|
23
|
+
track_files '*.rb'
|
24
|
+
end
|
25
|
+
end
|
25
26
|
|
26
27
|
require 'minitest/autorun'
|
28
|
+
require 'minitest/reporters'
|
29
|
+
Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new]
|
30
|
+
|
27
31
|
require_relative '../lib/pdd'
|
28
32
|
|
29
33
|
def stub_source_find_github_user(file, path = '')
|
data/test/test_duplicates.rb
CHANGED
@@ -1,22 +1,5 @@
|
|
1
|
-
# Copyright (c) 2014-
|
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) 2014-2025 Yegor Bugayenko
|
2
|
+
# SPDX-License-Identifier: MIT
|
20
3
|
|
21
4
|
require 'minitest/autorun'
|
22
5
|
require 'nokogiri'
|
@@ -24,7 +7,7 @@ require_relative '../lib/pdd/rule/duplicates'
|
|
24
7
|
|
25
8
|
# PDD::Rule::MaxDuplicates class test.
|
26
9
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
27
|
-
# Copyright:: Copyright (c) 2014-
|
10
|
+
# Copyright:: Copyright (c) 2014-2025 Yegor Bugayenko
|
28
11
|
# License:: MIT
|
29
12
|
class TestMaxDuplicates < Minitest::Test
|
30
13
|
def test_max_duplicates
|
@@ -34,7 +17,7 @@ class TestMaxDuplicates < Minitest::Test
|
|
34
17
|
<puzzle><body>test</body></puzzle></puzzles>'
|
35
18
|
), 1
|
36
19
|
)
|
37
|
-
|
20
|
+
refute_empty rule.errors, 'why it is empty?'
|
38
21
|
end
|
39
22
|
|
40
23
|
def test_max_duplicates_without_errors
|
@@ -43,6 +26,6 @@ class TestMaxDuplicates < Minitest::Test
|
|
43
26
|
'<puzzles><puzzle><body>hello</body></puzzle></puzzles>'
|
44
27
|
), 1
|
45
28
|
)
|
46
|
-
|
29
|
+
assert_empty rule.errors, 'it has to be empty!'
|
47
30
|
end
|
48
31
|
end
|
data/test/test_estimates.rb
CHANGED
@@ -1,22 +1,5 @@
|
|
1
|
-
# Copyright (c) 2014-
|
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) 2014-2025 Yegor Bugayenko
|
2
|
+
# SPDX-License-Identifier: MIT
|
20
3
|
|
21
4
|
require 'minitest/autorun'
|
22
5
|
require 'nokogiri'
|
@@ -24,7 +7,7 @@ require_relative '../lib/pdd/rule/estimates'
|
|
24
7
|
|
25
8
|
# PDD::Rule::Estimate module tests.
|
26
9
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
27
|
-
# Copyright:: Copyright (c) 2014-
|
10
|
+
# Copyright:: Copyright (c) 2014-2025 Yegor Bugayenko
|
28
11
|
# License:: MIT
|
29
12
|
class TestEstimates < Minitest::Test
|
30
13
|
def test_min
|
@@ -33,7 +16,7 @@ class TestEstimates < Minitest::Test
|
|
33
16
|
'<puzzles><puzzle><estimate>15</estimate></puzzle></puzzles>'
|
34
17
|
), 30
|
35
18
|
)
|
36
|
-
|
19
|
+
refute_empty rule.errors, 'why it is empty?'
|
37
20
|
end
|
38
21
|
|
39
22
|
def test_max
|
@@ -42,6 +25,6 @@ class TestEstimates < Minitest::Test
|
|
42
25
|
'<puzzles><puzzle><estimate>30</estimate></puzzle></puzzles>'
|
43
26
|
), 15
|
44
27
|
)
|
45
|
-
|
28
|
+
refute_empty rule.errors, 'why it is empty?'
|
46
29
|
end
|
47
30
|
end
|
data/test/test_many.rb
CHANGED
@@ -1,22 +1,5 @@
|
|
1
|
-
# Copyright (c) 2014-
|
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) 2014-2025 Yegor Bugayenko
|
2
|
+
# SPDX-License-Identifier: MIT
|
20
3
|
|
21
4
|
require 'minitest/autorun'
|
22
5
|
require 'tmpdir'
|
@@ -25,7 +8,7 @@ require_relative '../lib/pdd/sources'
|
|
25
8
|
|
26
9
|
# Test many puzzles to make sure their IDs are correct.
|
27
10
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
28
|
-
# Copyright:: Copyright (c) 2014-
|
11
|
+
# Copyright:: Copyright (c) 2014-2025 Yegor Bugayenko
|
29
12
|
# License:: MIT
|
30
13
|
class TestMany < Minitest::Test
|
31
14
|
def test_parsing
|
data/test/test_pdd.rb
CHANGED
@@ -1,22 +1,5 @@
|
|
1
|
-
# Copyright (c) 2014-
|
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) 2014-2025 Yegor Bugayenko
|
2
|
+
# SPDX-License-Identifier: MIT
|
20
3
|
|
21
4
|
require 'minitest/autorun'
|
22
5
|
require 'nokogiri'
|
@@ -26,7 +9,7 @@ require_relative '../lib/pdd'
|
|
26
9
|
|
27
10
|
# PDD main module test.
|
28
11
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
29
|
-
# Copyright:: Copyright (c) 2014-
|
12
|
+
# Copyright:: Copyright (c) 2014-2025 Yegor Bugayenko
|
30
13
|
# License:: MIT
|
31
14
|
class TestPDD < Minitest::Test
|
32
15
|
def test_basic
|
@@ -73,7 +56,7 @@ class TestPDD < Minitest::Test
|
|
73
56
|
echo '\x40todo #1 this is some puzzle' > '.это файл.txt'
|
74
57
|
cd ../..
|
75
58
|
git add -f .
|
76
|
-
git commit --quiet -am 'first version'
|
59
|
+
git commit --no-verify --quiet -am 'first version'
|
77
60
|
")
|
78
61
|
|
79
62
|
matches(
|
data/test/test_rake_task.rb
CHANGED
data/test/test_roles.rb
CHANGED
@@ -1,22 +1,5 @@
|
|
1
|
-
# Copyright (c) 2014-
|
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) 2014-2025 Yegor Bugayenko
|
2
|
+
# SPDX-License-Identifier: MIT
|
20
3
|
|
21
4
|
require 'minitest/autorun'
|
22
5
|
require 'nokogiri'
|
@@ -24,7 +7,7 @@ require_relative '../lib/pdd/rule/roles'
|
|
24
7
|
|
25
8
|
# PDD::Rule::Role module tests.
|
26
9
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
27
|
-
# Copyright:: Copyright (c) 2014-
|
10
|
+
# Copyright:: Copyright (c) 2014-2025 Yegor Bugayenko
|
28
11
|
# License:: MIT
|
29
12
|
class TestRoles < Minitest::Test
|
30
13
|
def test_incorrect_role
|
@@ -33,7 +16,7 @@ class TestRoles < Minitest::Test
|
|
33
16
|
'<puzzles><puzzle><role>D</role></puzzle></puzzles>'
|
34
17
|
), 'A,B,C'
|
35
18
|
)
|
36
|
-
|
19
|
+
refute_empty rule.errors, 'why it is empty?'
|
37
20
|
end
|
38
21
|
|
39
22
|
def test_correct_role
|
@@ -42,7 +25,7 @@ class TestRoles < Minitest::Test
|
|
42
25
|
'<puzzles><puzzle><role>F</role></puzzle></puzzles>'
|
43
26
|
), 'F,E,G'
|
44
27
|
)
|
45
|
-
|
28
|
+
assert_empty rule.errors, 'why it is not empty?'
|
46
29
|
end
|
47
30
|
|
48
31
|
def test_empty_role
|
@@ -51,6 +34,6 @@ class TestRoles < Minitest::Test
|
|
51
34
|
'<puzzles><puzzle></puzzle></puzzles>'
|
52
35
|
), 'T,R,L'
|
53
36
|
)
|
54
|
-
|
37
|
+
refute_empty rule.errors, 'why it is empty?'
|
55
38
|
end
|
56
39
|
end
|
data/test/test_source.rb
CHANGED
@@ -1,22 +1,5 @@
|
|
1
|
-
# Copyright (c) 2014-
|
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) 2014-2025 Yegor Bugayenko
|
2
|
+
# SPDX-License-Identifier: MIT
|
20
3
|
|
21
4
|
require 'minitest/autorun'
|
22
5
|
require 'tmpdir'
|
@@ -26,7 +9,7 @@ require_relative 'test__helper'
|
|
26
9
|
|
27
10
|
# Source test.
|
28
11
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
29
|
-
# Copyright:: Copyright (c) 2014-
|
12
|
+
# Copyright:: Copyright (c) 2014-2025 Yegor Bugayenko
|
30
13
|
# License:: MIT
|
31
14
|
class TestSource < Minitest::Test
|
32
15
|
def test_parsing
|
@@ -48,12 +31,12 @@ class TestSource < Minitest::Test
|
|
48
31
|
assert_equal 2, list.size
|
49
32
|
puzzle = list.first
|
50
33
|
assert_equal '2-3', puzzle.props[:lines]
|
51
|
-
assert_equal 'привет, how are you doing?',
|
34
|
+
assert_equal 'привет, how are you doing?',
|
52
35
|
puzzle.props[:body]
|
53
36
|
assert_equal '44', puzzle.props[:ticket]
|
54
|
-
|
55
|
-
|
56
|
-
|
37
|
+
assert_nil puzzle.props[:author]
|
38
|
+
assert_nil puzzle.props[:email]
|
39
|
+
assert_nil puzzle.props[:time]
|
57
40
|
end
|
58
41
|
end
|
59
42
|
end
|
@@ -136,7 +119,7 @@ class TestSource < Minitest::Test
|
|
136
119
|
* \x40todo #1 First one with
|
137
120
|
* a few lines
|
138
121
|
* \x40todo #1 Second one also
|
139
|
-
* with a few lines
|
122
|
+
* with a few lines of text
|
140
123
|
*/
|
141
124
|
"
|
142
125
|
)
|
@@ -145,7 +128,7 @@ class TestSource < Minitest::Test
|
|
145
128
|
assert_equal 2, source.puzzles.size
|
146
129
|
puzzle = source.puzzles.last
|
147
130
|
assert_equal '5-6', puzzle.props[:lines]
|
148
|
-
assert_equal 'Second one also with a few lines', puzzle.props[:body]
|
131
|
+
assert_equal 'Second one also with a few lines of text', puzzle.props[:body]
|
149
132
|
assert_equal '1', puzzle.props[:ticket]
|
150
133
|
end
|
151
134
|
end
|
@@ -210,7 +193,7 @@ class TestSource < Minitest::Test
|
|
210
193
|
error = assert_raises PDD::Error do
|
211
194
|
stub_source_find_github_user(file, 'ff', &:puzzles)
|
212
195
|
end
|
213
|
-
|
196
|
+
refute_nil error.to_s.index("\x40todo is not followed by")
|
214
197
|
end
|
215
198
|
end
|
216
199
|
|
@@ -236,7 +219,7 @@ class TestSource < Minitest::Test
|
|
236
219
|
error = assert_raises PDD::Error do
|
237
220
|
stub_source_find_github_user(file, 'hey', &:puzzles)
|
238
221
|
end
|
239
|
-
|
222
|
+
refute_nil error.message.index('is not followed by a puzzle marker')
|
240
223
|
end
|
241
224
|
end
|
242
225
|
|
@@ -252,7 +235,7 @@ class TestSource < Minitest::Test
|
|
252
235
|
error = assert_raises PDD::Error do
|
253
236
|
stub_source_find_github_user(file, 'x', &:puzzles)
|
254
237
|
end
|
255
|
-
|
238
|
+
refute_nil error.message.index("\x40todo must have a leading space")
|
256
239
|
end
|
257
240
|
end
|
258
241
|
|
@@ -268,7 +251,7 @@ class TestSource < Minitest::Test
|
|
268
251
|
error = assert_raises PDD::Error do
|
269
252
|
stub_source_find_github_user(file, 'x', &:puzzles)
|
270
253
|
end
|
271
|
-
|
254
|
+
refute_nil error.message.index('an unexpected space')
|
272
255
|
end
|
273
256
|
end
|
274
257
|
|
@@ -283,7 +266,7 @@ class TestSource < Minitest::Test
|
|
283
266
|
git config user.name test_unknown
|
284
267
|
echo '\x40todo #1 this is the puzzle' > a.txt
|
285
268
|
git add a.txt
|
286
|
-
git commit --quiet -am 'first version'
|
269
|
+
git commit --no-verify --quiet -am 'first version'
|
287
270
|
")
|
288
271
|
|
289
272
|
stub_source_find_github_user(File.join(dir, 'a.txt')) do |source|
|
@@ -312,7 +295,7 @@ class TestSource < Minitest::Test
|
|
312
295
|
git config user.name test
|
313
296
|
echo '\x40todo #1 this is the puzzle' > a.txt
|
314
297
|
git add a.txt
|
315
|
-
git commit --quiet -am 'first version'
|
298
|
+
git commit --no-verify --quiet -am 'first version'
|
316
299
|
")
|
317
300
|
|
318
301
|
stub_source_find_github_user(File.join(dir, 'a.txt')) do |source|
|
@@ -340,7 +323,7 @@ class TestSource < Minitest::Test
|
|
340
323
|
git config user.name test
|
341
324
|
echo '\x40todo #1 this is the puzzle' > a.txt
|
342
325
|
git add a.txt
|
343
|
-
git commit --quiet -am 'first version'
|
326
|
+
git commit --no-verify --quiet -am 'first version'
|
344
327
|
")
|
345
328
|
|
346
329
|
stub_source_find_github_user(File.join(dir, 'a.txt')) do |source|
|
@@ -362,7 +345,7 @@ class TestSource < Minitest::Test
|
|
362
345
|
git config user.name test
|
363
346
|
echo 'hi' > a.txt
|
364
347
|
git add a.txt
|
365
|
-
git commit --quiet -am 'first version'
|
348
|
+
git commit --no-verify --quiet -am 'first version'
|
366
349
|
echo '\x40todo #1 this is a puzzle uncommitted' > a.txt
|
367
350
|
")
|
368
351
|
|
data/test/test_source_todo.rb
CHANGED
@@ -1,27 +1,11 @@
|
|
1
|
-
# Copyright (c) 2014-
|
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) 2014-2025 Yegor Bugayenko
|
2
|
+
# SPDX-License-Identifier: MIT
|
20
3
|
|
21
4
|
require 'minitest/autorun'
|
22
5
|
require 'tmpdir'
|
23
6
|
require_relative '../lib/pdd'
|
24
7
|
require_relative '../lib/pdd/sources'
|
8
|
+
require_relative 'test__helper'
|
25
9
|
|
26
10
|
class TestSourceTodo < Minitest::Test
|
27
11
|
def check_valid_puzzle(text, lines, body, ticket, count = 1)
|
@@ -46,7 +30,22 @@ class TestSourceTodo < Minitest::Test
|
|
46
30
|
error = assert_raises PDD::Error do
|
47
31
|
stub_source_find_github_user(file, 'hey', &:puzzles)
|
48
32
|
end
|
49
|
-
|
33
|
+
refute_nil error.message.index(error_msg)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def check_missing_puzzle(text)
|
38
|
+
Dir.mktmpdir 'test' do |dir|
|
39
|
+
file = File.join(dir, 'a.txt')
|
40
|
+
File.write(file, text)
|
41
|
+
begin
|
42
|
+
stub_source_find_github_user(file, 'hey') do |source|
|
43
|
+
list = source.puzzles
|
44
|
+
assert_equal 0, list.size
|
45
|
+
end
|
46
|
+
rescue PDD::Error => e
|
47
|
+
assert_nil e, "Error is raised #{e.message}"
|
48
|
+
end
|
50
49
|
end
|
51
50
|
end
|
52
51
|
|
@@ -96,6 +95,17 @@ class TestSourceTodo < Minitest::Test
|
|
96
95
|
)
|
97
96
|
end
|
98
97
|
|
98
|
+
def test_todo_backslash_escape
|
99
|
+
check_valid_puzzle(
|
100
|
+
"
|
101
|
+
// TODO #45 task description with \\
|
102
|
+
",
|
103
|
+
'2-2',
|
104
|
+
'task description with \\',
|
105
|
+
'45'
|
106
|
+
)
|
107
|
+
end
|
108
|
+
|
99
109
|
def test_multiple_todo_colon
|
100
110
|
check_valid_puzzle(
|
101
111
|
"
|
@@ -121,6 +131,89 @@ class TestSourceTodo < Minitest::Test
|
|
121
131
|
)
|
122
132
|
end
|
123
133
|
|
134
|
+
def test_todo_colon_parsing_multi_line_with_empty_line
|
135
|
+
check_valid_puzzle(
|
136
|
+
"
|
137
|
+
// TODO: #45 task description
|
138
|
+
//
|
139
|
+
// second line after empty line is not a puzzle text
|
140
|
+
",
|
141
|
+
'2-2',
|
142
|
+
'task description',
|
143
|
+
'45'
|
144
|
+
)
|
145
|
+
end
|
146
|
+
|
147
|
+
def test_todo_colon_parsing_multi_line_with_empty_line_and_space
|
148
|
+
check_valid_puzzle(
|
149
|
+
'
|
150
|
+
// TODO: #46 task description
|
151
|
+
// \
|
152
|
+
// second line after empty line is a part of the puzzle in case of backslash exists
|
153
|
+
',
|
154
|
+
'2-4',
|
155
|
+
'task description second line after empty line is a part ' \
|
156
|
+
'of the puzzle in case of backslash exists',
|
157
|
+
'46'
|
158
|
+
)
|
159
|
+
end
|
160
|
+
|
161
|
+
def test_todo_colon_parsing_double_puzzle_with_empty_line
|
162
|
+
check_valid_puzzle(
|
163
|
+
'
|
164
|
+
// TODO: #46 task description for first
|
165
|
+
// \
|
166
|
+
// TODO: #47 task description
|
167
|
+
',
|
168
|
+
'2-2',
|
169
|
+
'task description for first',
|
170
|
+
'46',
|
171
|
+
2
|
172
|
+
)
|
173
|
+
end
|
174
|
+
|
175
|
+
def test_todo_parsing_puzzle_javadoc_with_empty_line
|
176
|
+
check_valid_puzzle(
|
177
|
+
'
|
178
|
+
/**
|
179
|
+
* TODO: #46 task description
|
180
|
+
* \
|
181
|
+
*/
|
182
|
+
* some text
|
183
|
+
',
|
184
|
+
'3-3',
|
185
|
+
'task description',
|
186
|
+
'46'
|
187
|
+
)
|
188
|
+
end
|
189
|
+
|
190
|
+
def test_todo_parsing_puzzle_last_empty_line
|
191
|
+
check_valid_puzzle(
|
192
|
+
'
|
193
|
+
/**
|
194
|
+
* TODO: #47 task description
|
195
|
+
* \
|
196
|
+
',
|
197
|
+
'3-3',
|
198
|
+
'task description',
|
199
|
+
'47'
|
200
|
+
)
|
201
|
+
end
|
202
|
+
|
203
|
+
def test_todo_colon_parsing_multi_line_random_prefix
|
204
|
+
check_valid_puzzle(
|
205
|
+
'
|
206
|
+
~~
|
207
|
+
~~ @todo #44 First
|
208
|
+
~~ and
|
209
|
+
~~ second
|
210
|
+
',
|
211
|
+
'3-4',
|
212
|
+
'First and',
|
213
|
+
'44'
|
214
|
+
)
|
215
|
+
end
|
216
|
+
|
124
217
|
def test_todo_failing_no_ticket
|
125
218
|
check_invalid_puzzle(
|
126
219
|
"
|
@@ -174,4 +267,12 @@ class TestSourceTodo < Minitest::Test
|
|
174
267
|
'TODO must have a leading space'
|
175
268
|
)
|
176
269
|
end
|
270
|
+
|
271
|
+
def test_todo_not_puzzle
|
272
|
+
check_missing_puzzle(
|
273
|
+
"
|
274
|
+
TODOS_DIR=$PWD
|
275
|
+
"
|
276
|
+
)
|
277
|
+
end
|
177
278
|
end
|
data/test/test_sources.rb
CHANGED
@@ -1,22 +1,5 @@
|
|
1
|
-
# Copyright (c) 2014-
|
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) 2014-2025 Yegor Bugayenko
|
2
|
+
# SPDX-License-Identifier: MIT
|
20
3
|
|
21
4
|
require 'minitest/autorun'
|
22
5
|
require 'fileutils'
|
@@ -26,7 +9,7 @@ require_relative '../lib/pdd/sources'
|
|
26
9
|
|
27
10
|
# Sources test.
|
28
11
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
29
|
-
# Copyright:: Copyright (c) 2014-
|
12
|
+
# Copyright:: Copyright (c) 2014-2025 Yegor Bugayenko
|
30
13
|
# License:: MIT
|
31
14
|
class TestSources < Minitest::Test
|
32
15
|
def test_iterator
|
@@ -118,7 +101,7 @@ class TestSources < Minitest::Test
|
|
118
101
|
error = assert_raises PDD::Error do
|
119
102
|
PDD::Sources.new(dir).fetch[0].puzzles
|
120
103
|
end
|
121
|
-
assert error.message.start_with?('z1.txt; '), error.message
|
104
|
+
assert error.message.start_with?('z1.txt; '), "here: #{error.message}"
|
122
105
|
end
|
123
106
|
end
|
124
107
|
|