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.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.0pdd.yml +3 -0
  3. data/.github/workflows/actionlint.yml +25 -0
  4. data/.github/workflows/codecov.yml +18 -9
  5. data/.github/workflows/copyrights.yml +19 -0
  6. data/.github/workflows/markdown-lint.yml +19 -0
  7. data/.github/workflows/pdd.yml +8 -4
  8. data/.github/workflows/rake.yml +13 -8
  9. data/.github/workflows/reuse.yml +19 -0
  10. data/.github/workflows/typos.yml +19 -0
  11. data/.github/workflows/xcop.yml +6 -2
  12. data/.github/workflows/yamllint.yml +19 -0
  13. data/.gitignore +12 -5
  14. data/.markdownlint.yml +6 -0
  15. data/.pdd +1 -1
  16. data/.rubocop.yml +12 -2
  17. data/.rultor.yml +7 -2
  18. data/.simplecov +16 -36
  19. data/Gemfile +16 -30
  20. data/Gemfile.lock +173 -0
  21. data/LICENSE.txt +1 -1
  22. data/LICENSES/MIT.txt +21 -0
  23. data/README.md +152 -57
  24. data/REUSE.toml +43 -0
  25. data/Rakefile +7 -31
  26. data/assets/puzzles.xsd +3 -22
  27. data/assets/puzzles.xsl +3 -22
  28. data/assets/puzzles_json.xsl +60 -0
  29. data/bin/pdd +17 -24
  30. data/cucumber.yml +4 -0
  31. data/features/applies_rules.feature +2 -0
  32. data/features/avoiding_duplicates.feature +2 -0
  33. data/features/catches_broken_puzzles.feature +2 -0
  34. data/features/cli.feature +48 -5
  35. data/features/gem_package.feature +2 -0
  36. data/features/html_output.feature +2 -0
  37. data/features/json_output.feature +24 -0
  38. data/features/parsing.feature +2 -0
  39. data/features/rake.feature +2 -2
  40. data/features/remove.feature +2 -0
  41. data/features/step_definitions/steps.rb +11 -20
  42. data/features/support/env.rb +2 -19
  43. data/features/unicode.feature +2 -0
  44. data/features/uses_config.feature +2 -1
  45. data/lib/pdd/puzzle.rb +2 -19
  46. data/lib/pdd/rake_task.rb +3 -0
  47. data/lib/pdd/rule/duplicates.rb +2 -19
  48. data/lib/pdd/rule/estimates.rb +2 -19
  49. data/lib/pdd/rule/roles.rb +2 -19
  50. data/lib/pdd/rule/text.rb +2 -19
  51. data/lib/pdd/source.rb +34 -35
  52. data/lib/pdd/sources.rb +2 -19
  53. data/lib/pdd/version.rb +4 -21
  54. data/lib/pdd.rb +3 -20
  55. data/pdd.gemspec +8 -24
  56. data/test/test__helper.rb +24 -20
  57. data/test/test_duplicates.rb +5 -22
  58. data/test/test_estimates.rb +5 -22
  59. data/test/test_many.rb +3 -20
  60. data/test/test_pdd.rb +4 -21
  61. data/test/test_rake_task.rb +3 -0
  62. data/test/test_roles.rb +6 -23
  63. data/test/test_source.rb +17 -34
  64. data/test/test_source_todo.rb +121 -20
  65. data/test/test_sources.rb +4 -21
  66. data/test/test_text.rb +4 -21
  67. data/test_assets/aladdin.jpg +0 -0
  68. data/test_assets/elegant-objects.png +0 -0
  69. data/test_assets/puzzles/1-04e35eb3 +1 -1
  70. data/test_assets/puzzles/132-bc1dfafe +1 -1
  71. data/test_assets/puzzles/1425-59819ae3 +5 -5
  72. data/test_assets/puzzles/42-0d933cc0 +1 -1
  73. data/test_assets/puzzles/44-660e9d6f +2 -2
  74. data/test_assets/puzzles/91-ecb9aa47 +1 -1
  75. data/test_assets/puzzles/93-641fe341 +1 -1
  76. data/utils/glob.rb +2 -19
  77. metadata +33 -11
  78. data/.overcommit.yml +0 -96
data/cucumber.yml CHANGED
@@ -1,3 +1,7 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2014-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
1
4
  default: --format pretty
2
5
  travis: --format progress
3
6
  html_report: --format progress --format html --out=features_report.html
7
+ json_report: --format progress --format json --out=features_report.json
@@ -1,3 +1,5 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2014-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
1
3
  Feature: Applies Post-Parsing Rules
2
4
  As a source code writer I want to be sure that
3
5
  certain post-parsing rules are applied
@@ -1,3 +1,5 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2014-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
1
3
  Feature: Avoiding Duplicate Puzzles
2
4
  As a source code writer I want to be sure that
3
5
  XML output doesn't contain any duplicates
@@ -1,3 +1,5 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2014-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
1
3
  Feature: Catches Broken Puzzles
2
4
  As a source code writer I want to be sure that
3
5
  broken puzzles won't be processed and will
data/features/cli.feature CHANGED
@@ -1,3 +1,5 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2014-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
1
3
  Feature: Command Line Processing
2
4
  As a source code writer I want to be able to
3
5
  call PDD as a command line tool
@@ -64,15 +66,14 @@ Feature: Command Line Processing
64
66
  Then Exit code is zero
65
67
  And XML file "out.xml" matches "/puzzles[count(puzzle)=0]"
66
68
 
67
- Scenario: Excluding unnecessary files from gitignore
68
- Given this step says to skip
69
- And I have a "a/b/c/test.txt" file with content:
69
+ Scenario: Excluding unnecessary files from .gitignore
70
+ Given I have a "a/b/c/test.txt" file with content:
70
71
  """
71
72
  ~~ @todo #44 some puzzle to be excluded
72
73
  """
73
74
  And I have a "f/g/h/hello.md" file with content:
74
75
  """
75
- ~~ @todo #44 some puzzle to be excluded as well
76
+ ~~ @todo #45 some puzzle to be excluded as well
76
77
  """
77
78
  And I have a ".gitignore" file with content:
78
79
  """
@@ -80,10 +81,52 @@ Feature: Command Line Processing
80
81
  a/**/*
81
82
  !/f
82
83
  """
83
- When I run bin/pdd with "> out.xml"
84
+ When I run bin/pdd with "--skip-gitignore > out.xml"
85
+ Then Exit code is zero
86
+ And XML file "out.xml" matches "/puzzles/puzzle[./ticket='45']"
87
+ And XML file "out.xml" matches "/puzzles[count(puzzle)=1]"
88
+
89
+ Scenario: Excluding unnecessary files from .gitignore and ignore comments
90
+ Given I have a "a/b/c/test.txt" file with content:
91
+ """
92
+ ~~ @todo #44 some puzzle to be excluded
93
+ """
94
+ And I have a "f/g/h/hello.md" file with content:
95
+ """
96
+ ~~ @todo #45 some puzzle to be excluded as well
97
+ """
98
+ And I have a ".gitignore" file with content:
99
+ """
100
+ # This is the list of patterns
101
+ # a/**/*
102
+ f/**/*
103
+ """
104
+ When I run bin/pdd with "--skip-gitignore > out.xml"
84
105
  Then Exit code is zero
106
+ And XML file "out.xml" matches "/puzzles/puzzle[./ticket='44']"
85
107
  And XML file "out.xml" matches "/puzzles[count(puzzle)=1]"
86
108
 
109
+ Scenario: Files from .gitignore is not excluded by default
110
+ Given I have a "a/b/c/test.txt" file with content:
111
+ """
112
+ ~~ @todo #44 some puzzle to be excluded
113
+ """
114
+ And I have a "f/g/h/hello.md" file with content:
115
+ """
116
+ ~~ @todo #45 some puzzle to be excluded as well
117
+ """
118
+ And I have a ".gitignore" file with content:
119
+ """
120
+ # This is the list of patterns
121
+ a/**/*
122
+ !/f
123
+ """
124
+ When I run bin/pdd with "> out.xml"
125
+ Then Exit code is zero
126
+ And XML file "out.xml" matches "/puzzles/puzzle[./ticket='44']"
127
+ And XML file "out.xml" matches "/puzzles/puzzle[./ticket='45']"
128
+ And XML file "out.xml" matches "/puzzles[count(puzzle)=2]"
129
+
87
130
  Scenario: Rejects unknown options
88
131
  Given I have a "test.txt" file with content:
89
132
  """
@@ -1,3 +1,5 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2014-2025 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) 2014-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
1
3
  Feature: HTML output
2
4
  As a source code writer I want to be able to
3
5
  call PDD as a command line tool, and retrieve an
@@ -0,0 +1,24 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2014-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ Feature: JSON output
4
+ As a source code writer I want to be able to
5
+ call PDD as a command line tool, and retrieve an
6
+ JSON report
7
+
8
+ Scenario: JSON report building
9
+ Given I have a "Sample.java" file with content:
10
+ """
11
+ public class Main {
12
+ /**
13
+ * @todo #13 Let's do json
14
+ * or maybe not json ":)"
15
+ */
16
+ public void main(String[] args) {
17
+ // later
18
+ }
19
+ }
20
+ """
21
+ When I run bin/pdd with "-v -s . -f out.json --format=json"
22
+ Then Exit code is zero
23
+ And Stdout contains "Reading from root dir ."
24
+ And Text File "out.json" contains "Let's do json or maybe not json “:)“"
@@ -1,3 +1,5 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2014-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
1
3
  Feature: Parsing
2
4
  As a source code writer I want to be able to
3
5
  collect all puzzles from all my text files and
@@ -1,3 +1,5 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2014-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
1
3
  Feature: Rake Task
2
4
  As a source code writer I want to be able to
3
5
  run PDD from Rakefile
@@ -17,5 +19,3 @@ Feature: Rake Task
17
19
 
18
20
  When I run bash with "rake pdd"
19
21
  Then Exit code is zero
20
-
21
-
@@ -1,3 +1,5 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2014-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
1
3
  Feature: Removing Puzzles
2
4
  As a source code writer I want to be able to
3
5
  remove PDD puzzles from source code
@@ -1,22 +1,5 @@
1
- # Copyright (c) 2014-2023 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) 2014-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
20
3
 
21
4
  require 'nokogiri'
22
5
  require 'tmpdir'
@@ -41,7 +24,7 @@ After do
41
24
  FileUtils.rm_rf(@dir)
42
25
  end
43
26
 
44
- Given(/skip/) do
27
+ Given(/skip test/) do
45
28
  skip_this_scenario
46
29
  end
47
30
 
@@ -95,6 +78,14 @@ Then(/^XML file "([^"]+)" matches "([^"]+)"$/) do |file, xpath|
95
78
  raise "XML file #{file} doesn't match \"#{xpath}\":\n#{xml}" if xml.xpath(xpath).empty?
96
79
  end
97
80
 
81
+ Then(/^Text File "([^"]+)" contains "([^"]+)"$/) do |file, substring|
82
+ raise "File #{file} doesn't exist" unless File.exist?(file)
83
+
84
+ content = File.read(file)
85
+ raise "File #{file} doesn't contain \"#{substring}\":\n#{content}" \
86
+ if content.index(substring).nil?
87
+ end
88
+
98
89
  Then(/^Exit code is zero$/) do
99
90
  raise "Non-zero exit code #{@exitstatus}" unless @exitstatus.zero?
100
91
  end
@@ -1,22 +1,5 @@
1
- # Copyright (c) 2014-2023 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) 2014-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
20
3
 
21
4
  require 'simplecov'
22
5
  require_relative '../../lib/pdd'
@@ -1,3 +1,5 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2014-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
1
3
  Feature: Unicode
2
4
  As a source code writer I want to be able to
3
5
  work with Unicode files
@@ -1,3 +1,5 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2014-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
1
3
  Feature: Using .pdd config file
2
4
  As a source code writer I want to be able to
3
5
  call PDD as a command line tool and configure
@@ -18,4 +20,3 @@ Feature: Using .pdd config file
18
20
  Then Exit code is zero
19
21
  And Stdout contains "Reading from root dir ."
20
22
  And XML file "out.xml" matches "/puzzles[count(puzzle)=1]"
21
-
data/lib/pdd/puzzle.rb CHANGED
@@ -1,22 +1,5 @@
1
- # Copyright (c) 2014-2023 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) 2014-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
20
3
 
21
4
  module PDD
22
5
  # Puzzle.
data/lib/pdd/rake_task.rb CHANGED
@@ -1,3 +1,6 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2014-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+
1
4
  require 'rake'
2
5
  require 'rake/tasklib'
3
6
  require 'minitest/autorun'
@@ -1,22 +1,5 @@
1
- # Copyright (c) 2014-2023 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) 2014-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
20
3
 
21
4
  module PDD
22
5
  module Rule
@@ -1,22 +1,5 @@
1
- # Copyright (c) 2014-2023 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) 2014-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
20
3
 
21
4
  module PDD
22
5
  module Rule
@@ -1,22 +1,5 @@
1
- # Copyright (c) 2014-2023 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) 2014-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
20
3
 
21
4
  module PDD
22
5
  module Rule
data/lib/pdd/rule/text.rb CHANGED
@@ -1,22 +1,5 @@
1
- # Copyright (c) 2014-2023 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) 2014-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
20
3
 
21
4
  module PDD
22
5
  module Rule
data/lib/pdd/source.rb CHANGED
@@ -1,22 +1,5 @@
1
- # Copyright (c) 2014-2023 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) 2014-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
20
3
 
21
4
  require 'digest/md5'
22
5
  require 'net/http'
@@ -51,7 +34,7 @@ module PDD
51
34
  /[^\s]TODO:?/.match(line) do |_|
52
35
  raise Error, get_no_leading_space_error('TODO')
53
36
  end
54
- /TODO(?!:?\s+#)/.match(line) do |_|
37
+ /TODO(?=[:\s])(?!:?\s+#)/.match(line) do |_|
55
38
  raise Error, get_no_puzzle_marker_error('TODO')
56
39
  end
57
40
  /TODO:?\s+#\s/.match(line) do |_|
@@ -140,26 +123,42 @@ against the rules explained here: https://github.com/cqfn/pdd#how-to-format"
140
123
  min
141
124
  end
142
125
 
143
- # rubocop:disable Metrics/CyclomaticComplexity
144
- # @todo #209:30min temporarily disabled cyclomatic complexity for the method.
145
- # below. Please fix soon.
146
- #
147
126
  # Fetch puzzle tail (all lines after the first one)
148
127
  def tail(lines, prefix, start)
128
+ return [] if lines.empty?
149
129
  prefix = " #{' ' * start}" if prefix.empty? # fallback to space indentation
150
- line = lines[0][prefix.length, lines[0].length] if lines[0]
151
- is_indented = line&.start_with?(' ')
152
- lines
153
- .take_while do |t|
154
- start = t.length > prefix.length ? prefix : prefix.rstrip
155
- match_markers(t).none? && t.start_with?(start)
130
+ tail_prefix = puzzle_tail_prefix(lines, prefix)
131
+ tail = lines
132
+ .take_while { |t| puzzle_text?(t, tail_prefix, prefix) }
133
+ .map do |t|
134
+ content = t[tail_prefix.length, t.length]&.lstrip
135
+ puzzle_empty_line?(content, '') ? '' : content
136
+ end
137
+ tail.pop if tail[-1].eql?('')
138
+ tail
139
+ end
140
+
141
+ def puzzle_tail_prefix(lines, prefix)
142
+ return prefix if lines.empty?
143
+ i = 0
144
+ while i < lines.length
145
+ unless puzzle_empty_line?(lines[i], prefix)
146
+ return lines[i].start_with?("#{prefix} ") ? "#{prefix} " : prefix
156
147
  end
157
- .take_while do |t|
158
- !is_indented || t[prefix.length, t.length].start_with?(' ')
159
- end
160
- .map { |t| t[prefix.length, t.length]&.lstrip }
148
+ i += 1
149
+ end
150
+ prefix
151
+ end
152
+
153
+ def puzzle_text?(line, prefix, intro_prefix)
154
+ return false unless match_markers(line).none?
155
+ line.start_with?(prefix) || puzzle_empty_line?(line, intro_prefix)
156
+ end
157
+
158
+ def puzzle_empty_line?(line, prefix)
159
+ return true if line.nil?
160
+ line.start_with?(prefix) && line.gsub(prefix, '').chomp.strip.eql?('\\')
161
161
  end
162
- # rubocop:enable Metrics/CyclomaticComplexity
163
162
 
164
163
  # @todo #75:30min Let's make it possible to fetch Subversion data
165
164
  # in a similar way as we are doing with Git. We should also just
data/lib/pdd/sources.rb CHANGED
@@ -1,22 +1,5 @@
1
- # Copyright (c) 2014-2023 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) 2014-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
20
3
 
21
4
  require 'rainbow'
22
5
  require 'English'
data/lib/pdd/version.rb CHANGED
@@ -1,27 +1,10 @@
1
- # Copyright (c) 2014-2023 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) 2014-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
20
3
 
21
4
  # PDD main module.
22
5
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
23
- # Copyright:: Copyright (c) 2014-2023 Yegor Bugayenko
6
+ # Copyright:: Copyright (c) 2014-2025 Yegor Bugayenko
24
7
  # License:: MIT
25
8
  module PDD
26
- VERSION = '0.23.2'.freeze
9
+ VERSION = '0.24.1'.freeze
27
10
  end
data/lib/pdd.rb CHANGED
@@ -1,22 +1,5 @@
1
- # Copyright (c) 2014-2023 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) 2014-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
20
3
 
21
4
  require 'nokogiri'
22
5
  require 'logger'
@@ -30,7 +13,7 @@ require_relative 'pdd/rule/roles'
30
13
 
31
14
  # PDD main module.
32
15
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
33
- # Copyright:: Copyright (c) 2014-2023 Yegor Bugayenko
16
+ # Copyright:: Copyright (c) 2014-2025 Yegor Bugayenko
34
17
  # License:: MIT
35
18
  module PDD
36
19
  # If it breaks.
data/pdd.gemspec CHANGED
@@ -1,22 +1,5 @@
1
- # Copyright (c) 2014-2023 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) 2014-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
20
3
 
21
4
  require 'English'
22
5
 
@@ -37,14 +20,15 @@ Gem::Specification.new do |s|
37
20
  s.description = 'Collects PDD puzzles from a source code base'
38
21
  s.authors = ['Yegor Bugayenko']
39
22
  s.email = 'yegor256@gmail.com'
40
- s.homepage = 'http://github.com/cqfn/pdd'
23
+ s.homepage = 'https://github.com/cqfn/pdd'
41
24
  s.files = `git ls-files`.split($RS)
42
25
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
43
26
  s.rdoc_options = ['--charset=UTF-8']
44
27
  s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
45
- s.add_runtime_dependency 'nokogiri', '~> 1.10'
46
- s.add_runtime_dependency 'rainbow', '~> 3.0'
47
- s.add_runtime_dependency 'ruby-filemagic', '~> 0.7.2'
48
- s.add_runtime_dependency 'slop', '~> 4.6'
28
+ s.add_dependency 'backtrace', '~>0.1'
29
+ s.add_dependency 'nokogiri', '~>1.10'
30
+ s.add_dependency 'rainbow', '~>3.0'
31
+ s.add_dependency 'ruby-filemagic', '~>0.7'
32
+ s.add_dependency 'slop', '~>4.6'
49
33
  s.metadata['rubygems_mfa_required'] = 'true'
50
34
  end