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
data/test/test_sources.rb DELETED
@@ -1,137 +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 'fileutils'
23
- require 'tmpdir'
24
- require_relative '../test/test__helper'
25
- require_relative '../lib/pdd/sources'
26
-
27
- # Sources test.
28
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
29
- # Copyright:: Copyright (c) 2014-2024 Yegor Bugayenko
30
- # License:: MIT
31
- class TestSources < Minitest::Test
32
- def test_iterator
33
- in_temp(['a.txt', 'b/c.txt']) do |dir|
34
- list = PDD::Sources.new(dir).fetch
35
- assert_equal 2, list.size
36
- end
37
- end
38
-
39
- def test_ignores_binary_files
40
- in_temp([]) do |dir|
41
- [
42
- 'README.md',
43
- '.git/index',
44
- 'test_assets/elegant-objects.png',
45
- 'test_assets/aladdin.jpg',
46
- 'test_assets/article.pdf',
47
- 'test_assets/cambria.woff',
48
- 'test_assets/favicon.ico'
49
- ].each { |f| FileUtils.cp(File.join(Dir.pwd, f), dir) }
50
- list = PDD::Sources.new(dir).fetch
51
- assert_equal 1, list.size
52
- end
53
- end
54
-
55
- def test_detects_all_text_files
56
- in_temp([]) do |dir|
57
- exts = %w[(xsl java rb cpp apt js xml c go h txt)]
58
- exts.each do |ext|
59
- File.write(File.join(dir, "test.#{ext}"), 'text')
60
- end
61
- list = PDD::Sources.new(dir).fetch
62
- assert_equal(
63
- exts.size, list.size,
64
- "Files found: #{list}"
65
- )
66
- end
67
- end
68
-
69
- def test_detects_xml_file
70
- in_temp(['a.xml']) do |dir|
71
- File.write(File.join(dir, 'a.xml'), '<?xml version="1.0"?><hello/>')
72
- list = PDD::Sources.new(dir).fetch
73
- assert_equal 1, list.size
74
- end
75
- end
76
-
77
- def test_detects_js_file
78
- in_temp(['a.js']) do |dir|
79
- File.write(File.join(dir, 'a.js'), "#!/usr/bin/env node\nconsole.log('Hi!');")
80
- list = PDD::Sources.new(dir).fetch
81
- assert_equal 1, list.size
82
- end
83
- end
84
-
85
- def test_excludes_by_pattern
86
- in_temp(['a/first.txt', 'b/c/d/second.txt']) do |dir|
87
- list = PDD::Sources.new(dir).exclude('b/c/d/second.txt').fetch
88
- assert_equal 1, list.size
89
- end
90
- end
91
-
92
- def test_excludes_recursively
93
- in_temp(['a/first.txt', 'b/c/second.txt', 'b/c/d/third.txt']) do |dir|
94
- list = PDD::Sources.new(dir).exclude('**/*').fetch
95
- assert_equal 0, list.size
96
- end
97
- end
98
-
99
- def test_includes_by_pattern
100
- in_temp(['a/first.txt', 'b/c/d/second.txt']) do |dir|
101
- list = PDD::Sources.new(dir).include('b/c/d/second.txt').fetch
102
- assert_equal 2, list.size
103
- end
104
- end
105
-
106
- def test_includes_recursively
107
- in_temp(['a/first.txt', 'b/c/second.txt', 'b/c/d/third.txt']) do |dir|
108
- sources = PDD::Sources.new(dir).exclude('b/c/**')
109
- sources.include('b/c/d/third.txt')
110
- list = sources.fetch
111
- assert_equal 2, list.size
112
- end
113
- end
114
-
115
- def test_fails_with_verbose_output
116
- in_temp do |dir|
117
- File.write(File.join(dir, 'z1.txt'), "\x40todobroken\n")
118
- error = assert_raises PDD::Error do
119
- PDD::Sources.new(dir).fetch[0].puzzles
120
- end
121
- assert error.message.start_with?('z1.txt; '), error.message
122
- end
123
- end
124
-
125
- private
126
-
127
- def in_temp(files = [])
128
- Dir.mktmpdir 'x' do |dir|
129
- files.each do |path|
130
- file = File.join(dir, path)
131
- FileUtils.mkdir_p(File.dirname(file))
132
- File.write(file, 'some test content')
133
- end
134
- yield dir
135
- end
136
- end
137
- end
data/test/test_text.rb DELETED
@@ -1,39 +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/text'
24
-
25
- # PDD::Rule::Text module tests.
26
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
27
- # Copyright:: Copyright (c) 2014-2024 Yegor Bugayenko
28
- # License:: MIT
29
- class TestText < Minitest::Test
30
- def test_min_words
31
- rule = PDD::Rule::Text::MinWords.new(
32
- Nokogiri::XML::Document.parse(
33
- '<puzzles><puzzle><body>short text</body></puzzle>
34
- <puzzle><body>body with four words</body></puzzle></puzzles>'
35
- ), 4
36
- )
37
- assert rule.errors.size == 1
38
- end
39
- end