pdd 0.20.7 → 0.21.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 (50) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/codecov.yml +20 -0
  3. data/.github/workflows/rake.yml +24 -0
  4. data/.gitignore +5 -5
  5. data/.overcommit.yml +96 -0
  6. data/.pdd +3 -1
  7. data/.rubocop.yml +5 -6
  8. data/.rultor.yml +8 -15
  9. data/.simplecov +6 -6
  10. data/CITATION.cff +25 -0
  11. data/Gemfile +1 -1
  12. data/LICENSE.txt +1 -1
  13. data/README.md +46 -16
  14. data/Rakefile +7 -1
  15. data/assets/puzzles.xsd +1 -1
  16. data/assets/puzzles.xsl +1 -1
  17. data/bin/pdd +22 -21
  18. data/features/catches_broken_puzzles.feature +2 -20
  19. data/features/cli.feature +1 -1
  20. data/features/html_output.feature +1 -1
  21. data/features/parsing.feature +31 -1
  22. data/features/rake.feature +14 -12
  23. data/features/step_definitions/steps.rb +7 -10
  24. data/features/support/env.rb +1 -1
  25. data/features/uses_config.feature +1 -1
  26. data/lib/pdd/puzzle.rb +1 -1
  27. data/lib/pdd/rake_task.rb +11 -12
  28. data/lib/pdd/rule/duplicates.rb +2 -1
  29. data/lib/pdd/rule/estimates.rb +1 -1
  30. data/lib/pdd/rule/roles.rb +2 -1
  31. data/lib/pdd/rule/text.rb +2 -1
  32. data/lib/pdd/source.rb +58 -54
  33. data/lib/pdd/sources.rb +40 -32
  34. data/lib/pdd/version.rb +3 -3
  35. data/lib/pdd.rb +16 -16
  36. data/pdd.gemspec +7 -4
  37. data/test/test__helper.rb +2 -2
  38. data/test/test_duplicates.rb +2 -2
  39. data/test/test_estimates.rb +2 -2
  40. data/test/test_pdd.rb +3 -2
  41. data/test/test_rake_task.rb +7 -4
  42. data/test/test_roles.rb +2 -2
  43. data/test/test_source.rb +74 -17
  44. data/test/test_source_todo.rb +15 -21
  45. data/test/test_sources.rb +7 -6
  46. data/test/test_text.rb +2 -2
  47. data/utils/glob.rb +65 -0
  48. metadata +36 -5
  49. data/.travis.yml +0 -13
  50. data/appveyor.yml +0 -21
data/pdd.gemspec CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2014-2021 Yegor Bugayenko
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
@@ -20,17 +20,18 @@
20
20
 
21
21
  require 'English'
22
22
 
23
- lib = File.expand_path('../lib', __FILE__)
23
+ lib = File.expand_path('lib', __dir__)
24
24
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
25
25
  require_relative 'lib/pdd/version'
26
26
 
27
27
  Gem::Specification.new do |s|
28
28
  s.specification_version = 2 if s.respond_to? :specification_version=
29
29
  if s.respond_to? :required_rubygems_version=
30
- s.required_rubygems_version = Gem::Requirement.new('>= 0')
30
+ s.required_rubygems_version =
31
+ Gem::Requirement.new('>= 0')
31
32
  end
32
33
  s.rubygems_version = '2.3'
33
- s.required_ruby_version = '>= 2.3'
34
+ s.required_ruby_version = '~> 2.3'
34
35
  s.name = 'pdd'
35
36
  s.version = PDD::VERSION
36
37
  s.license = 'MIT'
@@ -46,6 +47,7 @@ Gem::Specification.new do |s|
46
47
  s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
47
48
  s.add_runtime_dependency 'nokogiri', '~> 1.10'
48
49
  s.add_runtime_dependency 'rainbow', '~> 3.0'
50
+ s.add_runtime_dependency 'ruby-filemagic', '~> 0.7.2'
49
51
  s.add_runtime_dependency 'slop', '~> 4.6'
50
52
  s.add_development_dependency 'aruba', '~> 0.14.1'
51
53
  s.add_development_dependency 'codecov', '0.2.12'
@@ -56,5 +58,6 @@ Gem::Specification.new do |s|
56
58
  s.add_development_dependency 'rspec-rails', '3.1.0'
57
59
  s.add_development_dependency 'rubocop', '0.52.1'
58
60
  s.add_development_dependency 'rubocop-rspec', '1.15.1'
61
+ s.add_development_dependency 'slop', '4.9.1'
59
62
  s.add_development_dependency 'xcop', '0.5.8'
60
63
  end
data/test/test__helper.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2014-2021 Yegor Bugayenko
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
@@ -18,7 +18,7 @@
18
18
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
19
  # SOFTWARE.
20
20
 
21
- STDOUT.sync = true
21
+ $stdout.sync = true
22
22
 
23
23
  require 'simplecov'
24
24
  SimpleCov.start
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2014-2021 Yegor Bugayenko
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/duplicates'
24
24
 
25
25
  # PDD::Rule::MaxDuplicates class test.
26
26
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
27
- # Copyright:: Copyright (c) 2014-2021 Yegor Bugayenko
27
+ # Copyright:: Copyright (c) 2014-2022 Yegor Bugayenko
28
28
  # License:: MIT
29
29
  class TestMaxDuplicates < Minitest::Test
30
30
  def test_max_duplicates
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2014-2021 Yegor Bugayenko
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/estimates'
24
24
 
25
25
  # PDD::Rule::Estimate module tests.
26
26
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
27
- # Copyright:: Copyright (c) 2014-2021 Yegor Bugayenko
27
+ # Copyright:: Copyright (c) 2014-2022 Yegor Bugayenko
28
28
  # License:: MIT
29
29
  class TestEstimates < Minitest::Test
30
30
  def test_min
data/test/test_pdd.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2014-2021 Yegor Bugayenko
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'
26
26
 
27
27
  # PDD main module test.
28
28
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
29
- # Copyright:: Copyright (c) 2014-2021 Yegor Bugayenko
29
+ # Copyright:: Copyright (c) 2014-2022 Yegor Bugayenko
30
30
  # License:: MIT
31
31
  class TestPDD < Minitest::Test
32
32
  def test_basic
@@ -75,6 +75,7 @@ class TestPDD < Minitest::Test
75
75
  git add -f .
76
76
  git commit --quiet -am 'first version'
77
77
  ")
78
+
78
79
  matches(
79
80
  Nokogiri::XML(PDD::Base.new(opts).xml),
80
81
  [
@@ -5,11 +5,14 @@ require_relative '../lib/pdd/rake_task'
5
5
 
6
6
  # Test for RakeTask
7
7
  class TestRakeTask < Minitest::Test
8
- def test_base
9
- PDD::RakeTask.new(:pdd1)
10
- error = assert_raises SystemExit do
8
+ def test_basic
9
+ Dir.mktmpdir 'test' do |dir|
10
+ file = File.join(dir, 'a.txt')
11
+ File.write(file, "\x40todo #55 hello!")
12
+ PDD::RakeTask.new(:pdd1) do |task|
13
+ task.quiet = true
14
+ end
11
15
  Rake::Task['pdd1'].invoke
12
16
  end
13
- assert_equal('NOT IMPLEMENTED', error.message)
14
17
  end
15
18
  end
data/test/test_roles.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2014-2021 Yegor Bugayenko
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/roles'
24
24
 
25
25
  # PDD::Rule::Role module tests.
26
26
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
27
- # Copyright:: Copyright (c) 2014-2021 Yegor Bugayenko
27
+ # Copyright:: Copyright (c) 2014-2022 Yegor Bugayenko
28
28
  # License:: MIT
29
29
  class TestRoles < Minitest::Test
30
30
  def test_incorrect_role
data/test/test_source.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2014-2021 Yegor Bugayenko
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-2021 Yegor Bugayenko
28
+ # Copyright:: Copyright (c) 2014-2022 Yegor Bugayenko
29
29
  # License:: MIT
30
30
  class TestSource < Minitest::Test
31
31
  def test_parsing
@@ -46,8 +46,9 @@ class TestSource < Minitest::Test
46
46
  list = source.puzzles
47
47
  assert_equal 2, list.size
48
48
  puzzle = list.first
49
- assert_equal '2-3', puzzle.props[:lines]
50
- assert_equal 'привет, how are you doing?', puzzle.props[:body]
49
+ assert_equal '2-4', puzzle.props[:lines]
50
+ assert_equal 'привет, how are you doing? -something else', \
51
+ puzzle.props[:body]
51
52
  assert_equal '44', puzzle.props[:ticket]
52
53
  assert puzzle.props[:author].nil?
53
54
  assert puzzle.props[:email].nil?
@@ -78,20 +79,52 @@ class TestSource < Minitest::Test
78
79
  end
79
80
  end
80
81
 
81
- def test_failing_on_invalid_puzzle
82
+ def test_no_prefix_multiline_puzzle_block
82
83
  Dir.mktmpdir 'test' do |dir|
83
84
  file = File.join(dir, 'a.txt')
84
85
  File.write(
85
86
  file,
86
87
  "
87
- * \x40todo #44 this is an incorrectly formatted puzzle,
88
- * with a second line without a leading space
88
+ <!--
89
+ \x40todo #01:30min correctly formatted multi-line puzzle, with no
90
+ comment prefix before todo marker
91
+ -->
89
92
  "
90
93
  )
91
- error = assert_raises PDD::Error do
92
- stub_source_find_github_user(file, 'hey', &:puzzles)
94
+ stub_source_find_github_user(file, 'hey') do |source|
95
+ PDD.opts = nil
96
+ assert_equal 1, source.puzzles.size
97
+ puzzle = source.puzzles.last
98
+ assert_equal '3-4', puzzle.props[:lines]
99
+ assert_equal 'correctly formatted multi-line puzzle, with no ' \
100
+ 'comment prefix before todo marker', puzzle.props[:body]
101
+ assert_equal '01', puzzle.props[:ticket]
102
+ end
103
+ end
104
+ end
105
+
106
+ def test_multiple_puzzles_single_comment_block
107
+ Dir.mktmpdir 'test' do |dir|
108
+ file = File.join(dir, 'a.txt')
109
+ File.write(
110
+ file,
111
+ "
112
+ /*
113
+ * \x40todo #1 First one with
114
+ * a few lines
115
+ * \x40todo #1 Second one also
116
+ * with a few lines
117
+ */
118
+ "
119
+ )
120
+ stub_source_find_github_user(file, 'hey') do |source|
121
+ PDD.opts = nil
122
+ assert_equal 2, source.puzzles.size
123
+ puzzle = source.puzzles.last
124
+ assert_equal '5-6', puzzle.props[:lines]
125
+ assert_equal 'Second one also with a few lines', puzzle.props[:body]
126
+ assert_equal '1', puzzle.props[:ticket]
93
127
  end
94
- assert !error.message.index('Space expected').nil?
95
128
  end
96
129
  end
97
130
 
@@ -101,10 +134,10 @@ class TestSource < Minitest::Test
101
134
  File.write(
102
135
  file,
103
136
  "
104
- * \x40todo #44 this is an incorrectly formatted puzzle,
137
+ * \x40todo #44 this is a correctly formatted puzzle,
105
138
  * with a second line without a leading space
106
139
  Another badly formatted puzzle
107
- * \x40todo this puzzle misses ticket name/number
140
+ * \x40todo this bad puzzle misses ticket name/number
108
141
  Something else
109
142
  * \x40todo #123 This puzzle is correctly formatted
110
143
  "
@@ -113,15 +146,35 @@ class TestSource < Minitest::Test
113
146
  stub_source_find_github_user(file, 'hey') do |source|
114
147
  list = source.puzzles
115
148
  PDD.opts = nil
116
- assert_equal 1, list.size
149
+ assert_equal 2, list.size
117
150
  puzzle = list.first
118
- assert_equal '7-7', puzzle.props[:lines]
119
- assert_equal 'This puzzle is correctly formatted', puzzle.props[:body]
120
- assert_equal '123', puzzle.props[:ticket]
151
+ assert_equal '2-3', puzzle.props[:lines]
152
+ assert_equal 'this is a correctly formatted puzzle, with a second ' \
153
+ 'line without a leading space', puzzle.props[:body]
154
+ assert_equal '44', puzzle.props[:ticket]
121
155
  end
122
156
  end
123
157
  end
124
158
 
159
+ def test_succeed_utf8_encoded_body
160
+ Dir.mktmpdir 'test' do |dir|
161
+ file = File.join(dir, 'a.txt')
162
+ File.write(
163
+ file,
164
+ "
165
+ * \x40todo #44 Привет, мир, мне кофе
166
+ * вторая линия
167
+ "
168
+ )
169
+ list = PDD::VerboseSource.new(file, PDD::Source.new(file, 'hey')).puzzles
170
+ assert_equal 1, list.size
171
+ puzzle = list.first
172
+ assert_equal '2-3', puzzle.props[:lines]
173
+ assert_equal 'Привет, мир, мне кофе вторая линия', puzzle.props[:body]
174
+ assert_equal '44', puzzle.props[:ticket]
175
+ end
176
+ end
177
+
125
178
  def test_failing_on_incomplete_puzzle
126
179
  Dir.mktmpdir 't5' do |dir|
127
180
  file = File.join(dir, 'ff.txt')
@@ -141,7 +194,7 @@ class TestSource < Minitest::Test
141
194
  def test_failing_on_broken_unicode
142
195
  Dir.mktmpdir 'test' do |dir|
143
196
  file = File.join(dir, 'xx.txt')
144
- File.write(file, ' * \x40todo #44 this is a broken unicode: ' + 0x92.chr)
197
+ File.write(file, " * \\x40todo #44 this is a broken unicode: #{0x92.chr}")
145
198
  assert_raises PDD::Error do
146
199
  stub_source_find_github_user(file, 'xx', &:puzzles)
147
200
  end
@@ -209,6 +262,7 @@ class TestSource < Minitest::Test
209
262
  git add a.txt
210
263
  git commit --quiet -am 'first version'
211
264
  ")
265
+
212
266
  stub_source_find_github_user(File.join(dir, 'a.txt')) do |source|
213
267
  list = source.puzzles
214
268
  assert_equal 1, list.size
@@ -237,6 +291,7 @@ class TestSource < Minitest::Test
237
291
  git add a.txt
238
292
  git commit --quiet -am 'first version'
239
293
  ")
294
+
240
295
  stub_source_find_github_user(File.join(dir, 'a.txt')) do |source|
241
296
  list = source.puzzles
242
297
  assert_equal 1, list.size
@@ -264,6 +319,7 @@ class TestSource < Minitest::Test
264
319
  git add a.txt
265
320
  git commit --quiet -am 'first version'
266
321
  ")
322
+
267
323
  stub_source_find_github_user(File.join(dir, 'a.txt')) do |source|
268
324
  list = source.puzzles
269
325
  assert_equal 1, list.size
@@ -286,6 +342,7 @@ class TestSource < Minitest::Test
286
342
  git commit --quiet -am 'first version'
287
343
  echo '\x40todo #1 this is a puzzle uncommitted' > a.txt
288
344
  ")
345
+
289
346
  stub_source_find_github_user(File.join(dir, 'a.txt')) do |source|
290
347
  list = source.puzzles
291
348
  assert_equal 1, list.size
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2014-2021 Yegor Bugayenko
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
@@ -53,7 +53,7 @@ class TestSourceTodo < Minitest::Test
53
53
  def test_todo_parsing
54
54
  check_valid_puzzle(
55
55
  "
56
- // TODO #45 task description
56
+ // @todo #45 task description
57
57
  ",
58
58
  '2-2',
59
59
  'task description',
@@ -64,7 +64,7 @@ class TestSourceTodo < Minitest::Test
64
64
  def test_todo_parsing_multi_line
65
65
  check_valid_puzzle(
66
66
  "
67
- // TODO #45 task description
67
+ // @todo #45 task description
68
68
  // second line
69
69
  ",
70
70
  '2-3',
@@ -73,6 +73,18 @@ class TestSourceTodo < Minitest::Test
73
73
  )
74
74
  end
75
75
 
76
+ def test_todo_utf8_encoded_body
77
+ check_valid_puzzle(
78
+ "
79
+ // TODO #45 Привет, мир, мне кофе
80
+ // вторая линия
81
+ ",
82
+ '2-3',
83
+ 'Привет, мир, мне кофе вторая линия',
84
+ '45'
85
+ )
86
+ end
87
+
76
88
  def test_todo_colon_parsing
77
89
  check_valid_puzzle(
78
90
  "
@@ -109,24 +121,6 @@ class TestSourceTodo < Minitest::Test
109
121
  )
110
122
  end
111
123
 
112
- def test_todo_failing_no_space_on_second_line
113
- check_invalid_puzzle(
114
- "
115
- * TODO #45 this puzzle
116
- * has not space on second line",
117
- 'Space expected'
118
- )
119
- end
120
-
121
- def test_todo_colon_failing_no_space_on_second_line
122
- check_invalid_puzzle(
123
- "
124
- * TODO: #45 this puzzle
125
- * has not space on second line",
126
- 'Space expected'
127
- )
128
- end
129
-
130
124
  def test_todo_failing_no_ticket
131
125
  check_invalid_puzzle(
132
126
  "
data/test/test_sources.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2014-2021 Yegor Bugayenko
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-2021 Yegor Bugayenko
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',
@@ -92,14 +91,16 @@ class TestSources < Minitest::Test
92
91
  def test_includes_by_pattern
93
92
  in_temp(['a/first.txt', 'b/c/d/second.txt']) do |dir|
94
93
  list = PDD::Sources.new(dir).include('b/c/d/second.txt').fetch
95
- assert_equal 1, list.size
94
+ assert_equal 2, list.size
96
95
  end
97
96
  end
98
97
 
99
98
  def test_includes_recursively
100
99
  in_temp(['a/first.txt', 'b/c/second.txt', 'b/c/d/third.txt']) do |dir|
101
- list = PDD::Sources.new(dir).include('**/*').fetch
102
- assert_equal 0, list.size
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
103
104
  end
104
105
  end
105
106
 
data/test/test_text.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2014-2021 Yegor Bugayenko
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-2021 Yegor Bugayenko
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.20.7
4
+ version: 0.21.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-24 00:00:00.000000000 Z
11
+ date: 2022-07-11 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,19 @@ 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"
244
+ - CITATION.cff
214
245
  - Gemfile
215
246
  - LICENSE.txt
216
247
  - README.md
217
248
  - Rakefile
218
- - appveyor.yml
219
249
  - assets/puzzles.xsd
220
250
  - assets/puzzles.xsl
221
251
  - bin/pdd
@@ -258,6 +288,7 @@ files:
258
288
  - test_assets/cambria.woff
259
289
  - test_assets/elegant-objects.png
260
290
  - test_assets/favicon.ico
291
+ - utils/glob.rb
261
292
  homepage: http://github.com/cqfn/pdd
262
293
  licenses:
263
294
  - MIT
@@ -269,7 +300,7 @@ require_paths:
269
300
  - lib
270
301
  required_ruby_version: !ruby/object:Gem::Requirement
271
302
  requirements:
272
- - - ">="
303
+ - - "~>"
273
304
  - !ruby/object:Gem::Version
274
305
  version: '2.3'
275
306
  required_rubygems_version: !ruby/object:Gem::Requirement
data/.travis.yml DELETED
@@ -1,13 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.3.0
4
- cache: bundler
5
- branches:
6
- only:
7
- - master
8
- install:
9
- - travis_retry bundle update
10
- script:
11
- - bundle exec rake
12
- after_success:
13
- - "bash <(curl -s https://codecov.io/bash)"
data/appveyor.yml DELETED
@@ -1,21 +0,0 @@
1
- version: '{build}'
2
- skip_tags: true
3
- clone_depth: 10
4
- branches:
5
- only:
6
- - master
7
- except:
8
- - gh-pages
9
- os: Windows Server 2012
10
- install:
11
- - cmd: SET PATH=C:\Ruby23-x64\bin;%PATH%
12
- - cmd: ruby --version
13
- - cmd: git --version
14
- build_script:
15
- - bundle update
16
- - bundle install
17
- test_script:
18
- - rake
19
- cache:
20
- - C:\Ruby200\bin -> pdd.gemspec
21
- - C:\Ruby200\lib\ruby\gems\2.0.0 -> pdd.gemspec