pdd 0.20.6 → 0.21.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.
- checksums.yaml +4 -4
- data/.github/workflows/codecov.yml +20 -0
- data/.github/workflows/rake.yml +24 -0
- data/.gitignore +5 -5
- data/.overcommit.yml +96 -0
- data/.pdd +3 -0
- data/.rubocop.yml +3 -4
- data/.rultor.yml +8 -15
- data/.simplecov +6 -6
- data/Gemfile +1 -1
- data/LICENSE.txt +1 -1
- data/README.md +67 -37
- data/Rakefile +7 -1
- data/assets/puzzles.xsd +1 -1
- data/assets/puzzles.xsl +1 -1
- data/bin/pdd +31 -18
- data/features/catches_broken_puzzles.feature +3 -36
- data/features/cli.feature +1 -1
- data/features/html_output.feature +1 -1
- data/features/parsing.feature +31 -1
- data/features/rake.feature +14 -12
- data/features/step_definitions/steps.rb +7 -10
- data/features/support/env.rb +1 -1
- data/features/uses_config.feature +1 -1
- data/lib/pdd/puzzle.rb +1 -1
- data/lib/pdd/rake_task.rb +11 -12
- data/lib/pdd/rule/duplicates.rb +2 -1
- data/lib/pdd/rule/estimates.rb +1 -1
- data/lib/pdd/rule/roles.rb +2 -1
- data/lib/pdd/rule/text.rb +2 -1
- data/lib/pdd/source.rb +86 -75
- data/lib/pdd/sources.rb +42 -21
- data/lib/pdd/version.rb +3 -3
- data/lib/pdd.rb +20 -13
- data/pdd.gemspec +8 -5
- data/test/test__helper.rb +15 -2
- data/test/test_duplicates.rb +2 -2
- data/test/test_estimates.rb +2 -2
- data/test/test_pdd.rb +4 -2
- data/test/test_rake_task.rb +7 -4
- data/test/test_roles.rb +2 -2
- data/test/test_source.rb +168 -51
- data/test/test_source_todo.rb +38 -29
- data/test/test_sources.rb +18 -3
- data/test/test_text.rb +2 -2
- data/utils/glob.rb +65 -0
- metadata +37 -7
- data/.travis.yml +0 -13
- data/appveyor.yml +0 -21
data/test/test_source.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2014-
|
1
|
+
# Copyright (c) 2014-2022 Yegor Bugayenko
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -25,7 +25,7 @@ require_relative '../lib/pdd/sources'
|
|
25
25
|
|
26
26
|
# Source test.
|
27
27
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
28
|
-
# Copyright:: Copyright (c) 2014-
|
28
|
+
# Copyright:: Copyright (c) 2014-2022 Yegor Bugayenko
|
29
29
|
# License:: MIT
|
30
30
|
class TestSource < Minitest::Test
|
31
31
|
def test_parsing
|
@@ -42,32 +42,112 @@ class TestSource < Minitest::Test
|
|
42
42
|
~~ and it also has to work
|
43
43
|
"
|
44
44
|
)
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
45
|
+
stub_source_find_github_user(file, 'hey') do |source|
|
46
|
+
list = source.puzzles
|
47
|
+
assert_equal 2, list.size
|
48
|
+
puzzle = list.first
|
49
|
+
assert_equal '2-4', puzzle.props[:lines]
|
50
|
+
assert_equal 'привет, how are you doing? -something else', \
|
51
|
+
puzzle.props[:body]
|
52
|
+
assert_equal '44', puzzle.props[:ticket]
|
53
|
+
assert puzzle.props[:author].nil?
|
54
|
+
assert puzzle.props[:email].nil?
|
55
|
+
assert puzzle.props[:time].nil?
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_parsing_leading_spaces
|
61
|
+
Dir.mktmpdir 'test' do |dir|
|
62
|
+
file = File.join(dir, 'a.txt')
|
63
|
+
File.write(
|
64
|
+
file,
|
65
|
+
"
|
66
|
+
* \x40todo #56:30min this is a
|
67
|
+
* multi-line
|
68
|
+
* comment!
|
69
|
+
"
|
70
|
+
)
|
71
|
+
stub_source_find_github_user(file, 'hey') do |source|
|
72
|
+
list = source.puzzles
|
73
|
+
assert_equal 1, list.size
|
74
|
+
puzzle = list.first
|
75
|
+
assert_equal '2-4', puzzle.props[:lines]
|
76
|
+
assert_equal 'this is a multi-line comment!', puzzle.props[:body]
|
77
|
+
assert_equal '56', puzzle.props[:ticket]
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_multiple_puzzles_single_comment_block
|
83
|
+
Dir.mktmpdir 'test' do |dir|
|
84
|
+
file = File.join(dir, 'a.txt')
|
85
|
+
File.write(
|
86
|
+
file,
|
87
|
+
"
|
88
|
+
/*
|
89
|
+
* \x40todo #1 First one with
|
90
|
+
* a few lines
|
91
|
+
* \x40todo #1 Second one also
|
92
|
+
* with a few lines
|
93
|
+
*/
|
94
|
+
"
|
95
|
+
)
|
96
|
+
stub_source_find_github_user(file, 'hey') do |source|
|
97
|
+
PDD.opts = nil
|
98
|
+
assert_equal 2, source.puzzles.size
|
99
|
+
puzzle = source.puzzles.last
|
100
|
+
assert_equal '5-6', puzzle.props[:lines]
|
101
|
+
assert_equal 'Second one also with a few lines', puzzle.props[:body]
|
102
|
+
assert_equal '1', puzzle.props[:ticket]
|
103
|
+
end
|
54
104
|
end
|
55
105
|
end
|
56
106
|
|
57
|
-
def
|
107
|
+
def test_succeed_despite_bad_puzzles
|
58
108
|
Dir.mktmpdir 'test' do |dir|
|
59
109
|
file = File.join(dir, 'a.txt')
|
60
110
|
File.write(
|
61
111
|
file,
|
62
112
|
"
|
63
|
-
* \x40todo #44 this is
|
113
|
+
* \x40todo #44 this is a correctly formatted puzzle,
|
64
114
|
* with a second line without a leading space
|
115
|
+
Another badly formatted puzzle
|
116
|
+
* \x40todo this bad puzzle misses ticket name/number
|
117
|
+
Something else
|
118
|
+
* \x40todo #123 This puzzle is correctly formatted
|
65
119
|
"
|
66
120
|
)
|
67
|
-
|
68
|
-
|
121
|
+
PDD.opts = { 'skip-errors' => true }
|
122
|
+
stub_source_find_github_user(file, 'hey') do |source|
|
123
|
+
list = source.puzzles
|
124
|
+
PDD.opts = nil
|
125
|
+
assert_equal 2, list.size
|
126
|
+
puzzle = list.first
|
127
|
+
assert_equal '2-3', puzzle.props[:lines]
|
128
|
+
assert_equal 'this is a correctly formatted puzzle, with a second ' \
|
129
|
+
'line without a leading space', puzzle.props[:body]
|
130
|
+
assert_equal '44', puzzle.props[:ticket]
|
69
131
|
end
|
70
|
-
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_succeed_utf8_encoded_body
|
136
|
+
Dir.mktmpdir 'test' do |dir|
|
137
|
+
file = File.join(dir, 'a.txt')
|
138
|
+
File.write(
|
139
|
+
file,
|
140
|
+
"
|
141
|
+
* \x40todo #44 Привет, мир, мне кофе
|
142
|
+
* вторая линия
|
143
|
+
"
|
144
|
+
)
|
145
|
+
list = PDD::VerboseSource.new(file, PDD::Source.new(file, 'hey')).puzzles
|
146
|
+
assert_equal 1, list.size
|
147
|
+
puzzle = list.first
|
148
|
+
assert_equal '2-3', puzzle.props[:lines]
|
149
|
+
assert_equal 'Привет, мир, мне кофе вторая линия', puzzle.props[:body]
|
150
|
+
assert_equal '44', puzzle.props[:ticket]
|
71
151
|
end
|
72
152
|
end
|
73
153
|
|
@@ -81,7 +161,7 @@ class TestSource < Minitest::Test
|
|
81
161
|
"
|
82
162
|
)
|
83
163
|
error = assert_raises PDD::Error do
|
84
|
-
|
164
|
+
stub_source_find_github_user(file, 'ff', &:puzzles)
|
85
165
|
end
|
86
166
|
assert !error.to_s.index("\x40todo is not followed by").nil?
|
87
167
|
end
|
@@ -90,9 +170,9 @@ class TestSource < Minitest::Test
|
|
90
170
|
def test_failing_on_broken_unicode
|
91
171
|
Dir.mktmpdir 'test' do |dir|
|
92
172
|
file = File.join(dir, 'xx.txt')
|
93
|
-
File.write(file,
|
173
|
+
File.write(file, " * \\x40todo #44 this is a broken unicode: #{0x92.chr}")
|
94
174
|
assert_raises PDD::Error do
|
95
|
-
|
175
|
+
stub_source_find_github_user(file, 'xx', &:puzzles)
|
96
176
|
end
|
97
177
|
end
|
98
178
|
end
|
@@ -107,7 +187,7 @@ class TestSource < Minitest::Test
|
|
107
187
|
"
|
108
188
|
)
|
109
189
|
error = assert_raises PDD::Error do
|
110
|
-
|
190
|
+
stub_source_find_github_user(file, 'hey', &:puzzles)
|
111
191
|
end
|
112
192
|
assert !error.message.index('is not followed by a puzzle marker').nil?
|
113
193
|
end
|
@@ -123,7 +203,7 @@ class TestSource < Minitest::Test
|
|
123
203
|
"
|
124
204
|
)
|
125
205
|
error = assert_raises PDD::Error do
|
126
|
-
|
206
|
+
stub_source_find_github_user(file, 'x', &:puzzles)
|
127
207
|
end
|
128
208
|
assert !error.message.index("\x40todo must have a leading space").nil?
|
129
209
|
end
|
@@ -139,7 +219,7 @@ class TestSource < Minitest::Test
|
|
139
219
|
"
|
140
220
|
)
|
141
221
|
error = assert_raises PDD::Error do
|
142
|
-
|
222
|
+
stub_source_find_github_user(file, 'x', &:puzzles)
|
143
223
|
end
|
144
224
|
assert !error.message.index('an unexpected space').nil?
|
145
225
|
end
|
@@ -153,20 +233,24 @@ class TestSource < Minitest::Test
|
|
153
233
|
cd '#{dir}'
|
154
234
|
git init --quiet .
|
155
235
|
git config user.email test@teamed.io
|
156
|
-
git config user.name
|
236
|
+
git config user.name test_unknown
|
157
237
|
echo '\x40todo #1 this is the puzzle' > a.txt
|
158
238
|
git add a.txt
|
159
239
|
git commit --quiet -am 'first version'
|
160
240
|
")
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
241
|
+
|
242
|
+
stub_source_find_github_user(File.join(dir, 'a.txt')) do |source|
|
243
|
+
list = source.puzzles
|
244
|
+
assert_equal 1, list.size
|
245
|
+
puzzle = list.first
|
246
|
+
assert_equal '1-de87adc8', puzzle.props[:id]
|
247
|
+
assert_equal '1-1', puzzle.props[:lines]
|
248
|
+
assert_equal 'this is the puzzle', puzzle.props[:body]
|
249
|
+
assert_equal 'test_unknown', puzzle.props[:author]
|
250
|
+
assert_equal 'test@teamed.io', puzzle.props[:email]
|
251
|
+
assert_match(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/,
|
252
|
+
puzzle.props[:time])
|
253
|
+
end
|
170
254
|
end
|
171
255
|
end
|
172
256
|
|
@@ -183,15 +267,19 @@ class TestSource < Minitest::Test
|
|
183
267
|
git add a.txt
|
184
268
|
git commit --quiet -am 'first version'
|
185
269
|
")
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
270
|
+
|
271
|
+
stub_source_find_github_user(File.join(dir, 'a.txt')) do |source|
|
272
|
+
list = source.puzzles
|
273
|
+
assert_equal 1, list.size
|
274
|
+
puzzle = list.first
|
275
|
+
assert_equal '1-de87adc8', puzzle.props[:id]
|
276
|
+
assert_equal '1-1', puzzle.props[:lines]
|
277
|
+
assert_equal 'this is the puzzle', puzzle.props[:body]
|
278
|
+
assert_equal 'test', puzzle.props[:author]
|
279
|
+
assert_nil puzzle.props[:email]
|
280
|
+
assert_match(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/,
|
281
|
+
puzzle.props[:time])
|
282
|
+
end
|
195
283
|
end
|
196
284
|
end
|
197
285
|
|
@@ -207,10 +295,37 @@ class TestSource < Minitest::Test
|
|
207
295
|
git add a.txt
|
208
296
|
git commit --quiet -am 'first version'
|
209
297
|
")
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
298
|
+
|
299
|
+
stub_source_find_github_user(File.join(dir, 'a.txt')) do |source|
|
300
|
+
list = source.puzzles
|
301
|
+
assert_equal 1, list.size
|
302
|
+
puzzle = list.first
|
303
|
+
assert_equal '@yegor256', puzzle.props[:author]
|
304
|
+
end
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
def test_skips_uncommitted_changes
|
309
|
+
skip if Gem.win_platform?
|
310
|
+
Dir.mktmpdir 'test' do |dir|
|
311
|
+
raise unless system("
|
312
|
+
cd '#{dir}'
|
313
|
+
git init --quiet .
|
314
|
+
git config user.email yegor256@gmail.com
|
315
|
+
git config user.name test
|
316
|
+
echo 'hi' > a.txt
|
317
|
+
git add a.txt
|
318
|
+
git commit --quiet -am 'first version'
|
319
|
+
echo '\x40todo #1 this is a puzzle uncommitted' > a.txt
|
320
|
+
")
|
321
|
+
|
322
|
+
stub_source_find_github_user(File.join(dir, 'a.txt')) do |source|
|
323
|
+
list = source.puzzles
|
324
|
+
assert_equal 1, list.size
|
325
|
+
puzzle = list.first
|
326
|
+
assert_nil puzzle.props[:email]
|
327
|
+
assert_equal 'Not Committed Yet', puzzle.props[:author]
|
328
|
+
end
|
214
329
|
end
|
215
330
|
end
|
216
331
|
|
@@ -221,12 +336,14 @@ class TestSource < Minitest::Test
|
|
221
336
|
file,
|
222
337
|
'<!--/* @todo #123 puzzle info */-->'
|
223
338
|
)
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
339
|
+
stub_source_find_github_user(file, 'hey') do |source|
|
340
|
+
list = source.puzzles
|
341
|
+
assert_equal 1, list.size
|
342
|
+
puzzle = list.first
|
343
|
+
assert_equal '1-1', puzzle.props[:lines]
|
344
|
+
assert_equal 'puzzle info', puzzle.props[:body]
|
345
|
+
assert_equal '123', puzzle.props[:ticket]
|
346
|
+
end
|
230
347
|
end
|
231
348
|
end
|
232
349
|
end
|
data/test/test_source_todo.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2014-
|
1
|
+
# Copyright (c) 2014-2022 Yegor Bugayenko
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -24,16 +24,18 @@ require_relative '../lib/pdd'
|
|
24
24
|
require_relative '../lib/pdd/sources'
|
25
25
|
|
26
26
|
class TestSourceTodo < Minitest::Test
|
27
|
-
def check_valid_puzzle(text, lines, body, ticket)
|
27
|
+
def check_valid_puzzle(text, lines, body, ticket, count = 1)
|
28
28
|
Dir.mktmpdir 'test' do |dir|
|
29
29
|
file = File.join(dir, 'a.txt')
|
30
30
|
File.write(file, text)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
stub_source_find_github_user(file, 'hey') do |source|
|
32
|
+
list = source.puzzles
|
33
|
+
assert_equal count, list.size
|
34
|
+
puzzle = list.first
|
35
|
+
assert_equal lines, puzzle.props[:lines]
|
36
|
+
assert_equal body, puzzle.props[:body]
|
37
|
+
assert_equal ticket, puzzle.props[:ticket]
|
38
|
+
end
|
37
39
|
end
|
38
40
|
end
|
39
41
|
|
@@ -42,7 +44,7 @@ class TestSourceTodo < Minitest::Test
|
|
42
44
|
file = File.join(dir, 'a.txt')
|
43
45
|
File.write(file, text)
|
44
46
|
error = assert_raises PDD::Error do
|
45
|
-
|
47
|
+
stub_source_find_github_user(file, 'hey', &:puzzles)
|
46
48
|
end
|
47
49
|
assert !error.message.index(error_msg).nil?
|
48
50
|
end
|
@@ -51,7 +53,7 @@ class TestSourceTodo < Minitest::Test
|
|
51
53
|
def test_todo_parsing
|
52
54
|
check_valid_puzzle(
|
53
55
|
"
|
54
|
-
//
|
56
|
+
// @todo #45 task description
|
55
57
|
",
|
56
58
|
'2-2',
|
57
59
|
'task description',
|
@@ -62,7 +64,7 @@ class TestSourceTodo < Minitest::Test
|
|
62
64
|
def test_todo_parsing_multi_line
|
63
65
|
check_valid_puzzle(
|
64
66
|
"
|
65
|
-
//
|
67
|
+
// @todo #45 task description
|
66
68
|
// second line
|
67
69
|
",
|
68
70
|
'2-3',
|
@@ -71,44 +73,51 @@ class TestSourceTodo < Minitest::Test
|
|
71
73
|
)
|
72
74
|
end
|
73
75
|
|
74
|
-
def
|
76
|
+
def test_todo_utf8_encoded_body
|
75
77
|
check_valid_puzzle(
|
76
78
|
"
|
77
|
-
// TODO
|
79
|
+
// TODO #45 Привет, мир, мне кофе
|
80
|
+
// вторая линия
|
78
81
|
",
|
79
|
-
'2-
|
80
|
-
'
|
82
|
+
'2-3',
|
83
|
+
'Привет, мир, мне кофе вторая линия',
|
81
84
|
'45'
|
82
85
|
)
|
83
86
|
end
|
84
87
|
|
85
|
-
def
|
88
|
+
def test_todo_colon_parsing
|
86
89
|
check_valid_puzzle(
|
87
90
|
"
|
88
91
|
// TODO: #45 task description
|
89
|
-
// second line
|
90
92
|
",
|
91
|
-
'2-
|
92
|
-
'task description
|
93
|
+
'2-2',
|
94
|
+
'task description',
|
93
95
|
'45'
|
94
96
|
)
|
95
97
|
end
|
96
98
|
|
97
|
-
def
|
98
|
-
|
99
|
+
def test_multiple_todo_colon
|
100
|
+
check_valid_puzzle(
|
99
101
|
"
|
100
|
-
|
101
|
-
|
102
|
-
|
102
|
+
// TODO: #45 task description
|
103
|
+
// TODO: #46 another task description
|
104
|
+
",
|
105
|
+
'2-2',
|
106
|
+
'task description',
|
107
|
+
'45',
|
108
|
+
2
|
103
109
|
)
|
104
110
|
end
|
105
111
|
|
106
|
-
def
|
107
|
-
|
112
|
+
def test_todo_colon_parsing_multi_line
|
113
|
+
check_valid_puzzle(
|
108
114
|
"
|
109
|
-
|
110
|
-
|
111
|
-
|
115
|
+
// TODO: #45 task description
|
116
|
+
// second line
|
117
|
+
",
|
118
|
+
'2-3',
|
119
|
+
'task description second line',
|
120
|
+
'45'
|
112
121
|
)
|
113
122
|
end
|
114
123
|
|
data/test/test_sources.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2014-
|
1
|
+
# Copyright (c) 2014-2022 Yegor Bugayenko
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -26,7 +26,7 @@ require_relative '../lib/pdd/sources'
|
|
26
26
|
|
27
27
|
# Sources test.
|
28
28
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
29
|
-
# Copyright:: Copyright (c) 2014-
|
29
|
+
# Copyright:: Copyright (c) 2014-2022 Yegor Bugayenko
|
30
30
|
# License:: MIT
|
31
31
|
class TestSources < Minitest::Test
|
32
32
|
def test_iterator
|
@@ -37,7 +37,6 @@ class TestSources < Minitest::Test
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def test_ignores_binary_files
|
40
|
-
skip if Gem.win_platform?
|
41
40
|
in_temp([]) do |dir|
|
42
41
|
[
|
43
42
|
'README.md',
|
@@ -89,6 +88,22 @@ class TestSources < Minitest::Test
|
|
89
88
|
end
|
90
89
|
end
|
91
90
|
|
91
|
+
def test_includes_by_pattern
|
92
|
+
in_temp(['a/first.txt', 'b/c/d/second.txt']) do |dir|
|
93
|
+
list = PDD::Sources.new(dir).include('b/c/d/second.txt').fetch
|
94
|
+
assert_equal 2, list.size
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_includes_recursively
|
99
|
+
in_temp(['a/first.txt', 'b/c/second.txt', 'b/c/d/third.txt']) do |dir|
|
100
|
+
sources = PDD::Sources.new(dir).exclude('b/c/**')
|
101
|
+
sources.include('b/c/d/third.txt')
|
102
|
+
list = sources.fetch
|
103
|
+
assert_equal 2, list.size
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
92
107
|
def test_fails_with_verbose_output
|
93
108
|
in_temp do |dir|
|
94
109
|
File.write(File.join(dir, 'z1.txt'), "\x40todobroken\n")
|
data/test/test_text.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (c) 2014-
|
1
|
+
# Copyright (c) 2014-2022 Yegor Bugayenko
|
2
2
|
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
4
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -24,7 +24,7 @@ require_relative '../lib/pdd/rule/text'
|
|
24
24
|
|
25
25
|
# PDD::Rule::Text module tests.
|
26
26
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
27
|
-
# Copyright:: Copyright (c) 2014-
|
27
|
+
# Copyright:: Copyright (c) 2014-2022 Yegor Bugayenko
|
28
28
|
# License:: MIT
|
29
29
|
class TestText < Minitest::Test
|
30
30
|
def test_min_words
|
data/utils/glob.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# Copyright (c) 2014-2022 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
|
+
# Utility glob class
|
22
|
+
class Glob
|
23
|
+
NO_LEADING_DOT = '(?=[^\.])'.freeze
|
24
|
+
|
25
|
+
def initialize(glob_string)
|
26
|
+
@glob_string = glob_string
|
27
|
+
end
|
28
|
+
|
29
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
30
|
+
def to_regexp
|
31
|
+
chars = @glob_string.gsub(%r{(\*\*\/\*)|(\*\*)}, '*').split('')
|
32
|
+
in_curlies = 0, escaping = false
|
33
|
+
chars.map do |char|
|
34
|
+
if escaping
|
35
|
+
escaping = false
|
36
|
+
return char
|
37
|
+
end
|
38
|
+
case char
|
39
|
+
when '*'
|
40
|
+
'.*'
|
41
|
+
when '?'
|
42
|
+
'.'
|
43
|
+
when '.'
|
44
|
+
'\\.'
|
45
|
+
when '{'
|
46
|
+
in_curlies += 1
|
47
|
+
'('
|
48
|
+
when '}'
|
49
|
+
if in_curlies.positive?
|
50
|
+
in_curlies -= 1
|
51
|
+
return ')'
|
52
|
+
end
|
53
|
+
return char
|
54
|
+
when ','
|
55
|
+
in_curlies.positive? ? '|' : char
|
56
|
+
when '\\'
|
57
|
+
escaping = true
|
58
|
+
'\\'
|
59
|
+
else
|
60
|
+
char
|
61
|
+
end
|
62
|
+
end.join
|
63
|
+
end
|
64
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
65
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pdd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.21.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:
|
11
|
+
date: 2022-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: ruby-filemagic
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.7.2
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.7.2
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: slop
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -178,6 +192,20 @@ dependencies:
|
|
178
192
|
- - '='
|
179
193
|
- !ruby/object:Gem::Version
|
180
194
|
version: 1.15.1
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: slop
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - '='
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: 4.9.1
|
202
|
+
type: :development
|
203
|
+
prerelease: false
|
204
|
+
version_requirements: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - '='
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: 4.9.1
|
181
209
|
- !ruby/object:Gem::Dependency
|
182
210
|
name: xcop
|
183
211
|
requirement: !ruby/object:Gem::Requirement
|
@@ -205,17 +233,18 @@ files:
|
|
205
233
|
- ".gitattributes"
|
206
234
|
- ".github/ISSUE_TEMPLATE.md"
|
207
235
|
- ".github/PULL_REQUEST_TEMPLATE.md"
|
236
|
+
- ".github/workflows/codecov.yml"
|
237
|
+
- ".github/workflows/rake.yml"
|
208
238
|
- ".gitignore"
|
239
|
+
- ".overcommit.yml"
|
209
240
|
- ".pdd"
|
210
241
|
- ".rubocop.yml"
|
211
242
|
- ".rultor.yml"
|
212
243
|
- ".simplecov"
|
213
|
-
- ".travis.yml"
|
214
244
|
- Gemfile
|
215
245
|
- LICENSE.txt
|
216
246
|
- README.md
|
217
247
|
- Rakefile
|
218
|
-
- appveyor.yml
|
219
248
|
- assets/puzzles.xsd
|
220
249
|
- assets/puzzles.xsl
|
221
250
|
- bin/pdd
|
@@ -258,7 +287,8 @@ files:
|
|
258
287
|
- test_assets/cambria.woff
|
259
288
|
- test_assets/elegant-objects.png
|
260
289
|
- test_assets/favicon.ico
|
261
|
-
|
290
|
+
- utils/glob.rb
|
291
|
+
homepage: http://github.com/cqfn/pdd
|
262
292
|
licenses:
|
263
293
|
- MIT
|
264
294
|
metadata: {}
|
@@ -269,7 +299,7 @@ require_paths:
|
|
269
299
|
- lib
|
270
300
|
required_ruby_version: !ruby/object:Gem::Requirement
|
271
301
|
requirements:
|
272
|
-
- - "
|
302
|
+
- - "~>"
|
273
303
|
- !ruby/object:Gem::Version
|
274
304
|
version: '2.3'
|
275
305
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -278,7 +308,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
278
308
|
- !ruby/object:Gem::Version
|
279
309
|
version: '0'
|
280
310
|
requirements: []
|
281
|
-
rubygems_version: 3.
|
311
|
+
rubygems_version: 3.1.2
|
282
312
|
signing_key:
|
283
313
|
specification_version: 2
|
284
314
|
summary: Puzzle Driven Development collector
|