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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61cbd66550df0bd17c8916fa490a6e85f8c3991475c609a013b73db2e5891f16
|
4
|
+
data.tar.gz: 015351fbd2e277409faf706ccd1a590d5a962e49f6fdfb4c6318e371f658c96a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbb82db1bbb0d5246caa98cc376a7a2ea32aefc217d567191f03fd3dc346d833d55cca141430b6b6f12dec1e5580faa5b83d28da3156b88ef3a0cdfd70fbbdf5
|
7
|
+
data.tar.gz: 81f23444974fd4d1359d9bbf2bd07adc370d05302369be00ee67c210c12c1c3d83648b9dcfd8e454d161781b06cef9430b72a774fa9ddcc3508493cb52540f45
|
@@ -0,0 +1,20 @@
|
|
1
|
+
---
|
2
|
+
name: codecov
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
jobs:
|
8
|
+
codecov:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
steps:
|
11
|
+
- uses: actions/checkout@v2
|
12
|
+
- uses: actions/setup-ruby@v1
|
13
|
+
with:
|
14
|
+
ruby-version: 2.7
|
15
|
+
- run: bundle update
|
16
|
+
- run: bundle exec rake
|
17
|
+
- uses: codecov/codecov-action@v1
|
18
|
+
with:
|
19
|
+
file: coverage/.resultset.json
|
20
|
+
fail_ci_if_error: true
|
@@ -0,0 +1,24 @@
|
|
1
|
+
---
|
2
|
+
name: rake
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request:
|
8
|
+
branches:
|
9
|
+
- master
|
10
|
+
jobs:
|
11
|
+
test:
|
12
|
+
name: test
|
13
|
+
strategy:
|
14
|
+
matrix:
|
15
|
+
os: [ubuntu-latest]
|
16
|
+
ruby: [2.7]
|
17
|
+
runs-on: ${{ matrix.os }}
|
18
|
+
steps:
|
19
|
+
- uses: actions/checkout@v2
|
20
|
+
- uses: actions/setup-ruby@v1
|
21
|
+
with:
|
22
|
+
ruby-version: ${{ matrix.ruby }}
|
23
|
+
- run: bundle update
|
24
|
+
- run: bundle exec rake
|
data/.gitignore
CHANGED
data/.overcommit.yml
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# Use this file to configure the Overcommit hooks you wish to use. This will
|
2
|
+
# extend the default configuration defined in:
|
3
|
+
# https://github.com/sds/overcommit/blob/master/config/default.yml
|
4
|
+
#
|
5
|
+
# At the topmost level of this YAML file is a key representing type of hook
|
6
|
+
# being run (e.g. pre-commit, commit-msg, etc.). Within each type you can
|
7
|
+
# customize each hook, such as whether to only run it on certain files (via
|
8
|
+
# `include`), whether to only display output if it fails (via `quiet`), etc.
|
9
|
+
#
|
10
|
+
# For a complete list of hooks, see:
|
11
|
+
# https://github.com/sds/overcommit/tree/master/lib/overcommit/hook
|
12
|
+
#
|
13
|
+
# For a complete list of options that you can use to customize hooks, see:
|
14
|
+
# https://github.com/sds/overcommit#configuration
|
15
|
+
|
16
|
+
PreCommit:
|
17
|
+
ALL:
|
18
|
+
problem_on_unmodified_line: report
|
19
|
+
requires_files: true
|
20
|
+
required: false
|
21
|
+
quiet: false
|
22
|
+
|
23
|
+
AuthorEmail:
|
24
|
+
enabled: true
|
25
|
+
description: 'Check author email'
|
26
|
+
requires_files: false
|
27
|
+
required: true
|
28
|
+
quiet: true
|
29
|
+
pattern: '^[^@]+@.*$'
|
30
|
+
|
31
|
+
AuthorName:
|
32
|
+
enabled: true
|
33
|
+
description: 'Check for author name'
|
34
|
+
requires_files: false
|
35
|
+
required: true
|
36
|
+
quiet: true
|
37
|
+
|
38
|
+
BundleCheck:
|
39
|
+
enabled: true
|
40
|
+
description: 'Check Gemfile dependencies'
|
41
|
+
required_executable: 'bundle'
|
42
|
+
flags: ['check']
|
43
|
+
include:
|
44
|
+
- 'Gemfile'
|
45
|
+
- 'Gemfile.lock'
|
46
|
+
- '*.gemspec'
|
47
|
+
|
48
|
+
BundleOutdated:
|
49
|
+
enabled: true
|
50
|
+
description: 'List installed gems with newer versions available'
|
51
|
+
required_executable: 'bundle'
|
52
|
+
flags: ['outdated', '--strict', '--parseable']
|
53
|
+
|
54
|
+
RuboCop:
|
55
|
+
enabled: true
|
56
|
+
description: 'Analyze with RuboCop'
|
57
|
+
required_executable: 'bundle'
|
58
|
+
flags: ['exec', 'rubocop']
|
59
|
+
|
60
|
+
# Hooks that are run against every commit message after a user has written it.
|
61
|
+
# These hooks are useful for enforcing policies on commit messages written for a
|
62
|
+
# project.
|
63
|
+
CommitMsg:
|
64
|
+
ALL:
|
65
|
+
requires_files: false
|
66
|
+
quiet: false
|
67
|
+
|
68
|
+
EmptyMessage:
|
69
|
+
enabled: true
|
70
|
+
description: 'Check for empty commit message'
|
71
|
+
quiet: true
|
72
|
+
|
73
|
+
MessageFormat:
|
74
|
+
enabled: true
|
75
|
+
description: 'Check commit message matches expected pattern'
|
76
|
+
pattern: '(\[#)(.+)(\]\s)(.+)'
|
77
|
+
expected_pattern_message: '[#<Issue Id>] <Commit Message Description>'
|
78
|
+
sample_message: '[#167] Refactored onboarding flow'
|
79
|
+
|
80
|
+
PrePush:
|
81
|
+
ALL:
|
82
|
+
requires_files: false
|
83
|
+
required: false
|
84
|
+
quiet: false
|
85
|
+
|
86
|
+
RakeTarget:
|
87
|
+
enabled: true
|
88
|
+
quite: true
|
89
|
+
description: 'Run rake targets'
|
90
|
+
targets:
|
91
|
+
- 'rubocop'
|
92
|
+
- 'test'
|
93
|
+
- 'xcop'
|
94
|
+
required_executable: 'bundle'
|
95
|
+
flags: ['exec', 'rake']
|
96
|
+
|
data/.pdd
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
--source=.
|
2
2
|
--verbose
|
3
3
|
--exclude .idea/**/*
|
4
|
+
--exclude .bundle/**/*
|
4
5
|
--exclude target/**/*
|
5
6
|
--exclude coverage/**/*
|
7
|
+
--exclude test_assets/**/*
|
6
8
|
--exclude README.md
|
7
9
|
--exclude features/cli.feature
|
8
10
|
--exclude features/parsing.feature
|
@@ -20,3 +22,4 @@
|
|
20
22
|
--rule min-words:20
|
21
23
|
--rule min-estimate:15
|
22
24
|
--rule max-estimate:90
|
25
|
+
|
data/.rubocop.yml
CHANGED
@@ -8,16 +8,15 @@ Layout/EndOfLine:
|
|
8
8
|
EnforcedStyle: lf
|
9
9
|
Metrics/ClassLength:
|
10
10
|
Max: 300
|
11
|
+
Metrics/LineLength:
|
12
|
+
Max: 90
|
11
13
|
Metrics/MethodLength:
|
12
|
-
Max:
|
14
|
+
Max: 35
|
13
15
|
Metrics/AbcSize:
|
14
16
|
Max: 40
|
15
17
|
Style/MultilineBlockChain:
|
16
18
|
Enabled: false
|
17
19
|
Metrics/BlockLength:
|
18
20
|
Max: 50
|
19
|
-
# @todo #123:30m Needs to enable this check and fix all issues.
|
20
|
-
# For now, this is out of the scope of this issue.
|
21
|
-
# This issue appeared after update TargetRubyVersion to 2.3
|
22
21
|
Style/FrozenStringLiteralComment:
|
23
22
|
Enabled: false
|
data/.rultor.yml
CHANGED
@@ -1,32 +1,25 @@
|
|
1
|
+
docker:
|
2
|
+
image: yegor256/rultor-image:1.9.0
|
1
3
|
assets:
|
2
4
|
rubygems.yml: yegor256/home#assets/rubygems.yml
|
3
|
-
s3cfg: yegor256/home#assets/s3cfg
|
4
5
|
install: |
|
5
|
-
|
6
|
-
|
7
|
-
sudo gem install pdd -v 0.20.5
|
8
|
-
sudo gem install xcop -v 0.6
|
9
|
-
bundle install
|
6
|
+
pdd -f /dev/null
|
7
|
+
sudo bundle install --no-color "--gemfile=$(pwd)/Gemfile"
|
10
8
|
release:
|
11
9
|
script: |-
|
12
|
-
|
13
|
-
|
10
|
+
[[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit -1
|
11
|
+
bundle exec rake
|
14
12
|
rm -rf *.gem
|
15
|
-
sed -i "s/
|
13
|
+
sed -i "s/0\.0\.0/${tag}/g" lib/pdd/version.rb
|
16
14
|
git add lib/pdd/version.rb
|
17
15
|
git commit -m "version set to ${tag}"
|
18
16
|
gem build pdd.gemspec
|
19
17
|
chmod 0600 ../rubygems.yml
|
20
18
|
gem push *.gem --config-file ../rubygems.yml
|
21
|
-
pdd --source=$(pwd) --verbose --file=pdd.xml -e=test/** -e=features/** -e=coverage/**/* -e=README.md
|
22
|
-
s3cmd --no-progress put pdd.xml --config=../s3cfg s3://pdd.teamed.io/pdd.xml
|
23
|
-
s3cmd --no-progress put assets/puzzles.xsd --acl-public --config=../s3cfg s3://pdd-xsd.teamed.io/${tag}.xsd
|
24
|
-
s3cmd --no-progress put assets/puzzles.xsl --acl-public --config=../s3cfg s3://pdd-xsl.teamed.io/${tag}.xsl
|
25
19
|
merge:
|
26
20
|
script: |-
|
27
|
-
pdd -f /dev/null
|
28
21
|
LC_ALL=US-ASCII bundle exec rake
|
29
22
|
deploy:
|
30
23
|
script: |-
|
31
|
-
echo
|
24
|
+
echo "There is nothing to deploy"
|
32
25
|
exit -1
|
data/.simplecov
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
|
@@ -18,21 +18,21 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
19
|
# SOFTWARE.
|
20
20
|
|
21
|
-
if Gem.win_platform?
|
21
|
+
if Gem.win_platform?
|
22
22
|
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
23
23
|
SimpleCov::Formatter::HTMLFormatter
|
24
24
|
]
|
25
25
|
SimpleCov.start do
|
26
|
-
add_filter
|
27
|
-
add_filter
|
26
|
+
add_filter '/test/'
|
27
|
+
add_filter '/features/'
|
28
28
|
end
|
29
29
|
else
|
30
30
|
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
|
31
31
|
SimpleCov::Formatter::HTMLFormatter
|
32
32
|
)
|
33
33
|
SimpleCov.start do
|
34
|
-
add_filter
|
35
|
-
add_filter
|
34
|
+
add_filter '/test/'
|
35
|
+
add_filter '/features/'
|
36
36
|
minimum_coverage 90
|
37
37
|
end
|
38
38
|
end
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,22 +1,18 @@
|
|
1
|
-
<img src="https://avatars2.githubusercontent.com/u/24456188" width="64px" height="64px"/>
|
2
|
-
|
3
|
-
[](https://www.0crat.com/contrib/C3T46CUJJ)
|
1
|
+
<img alt="pdd logo" src="https://avatars2.githubusercontent.com/u/24456188" width="64px" height="64px"/>
|
4
2
|
|
5
3
|
[](https://www.elegantobjects.org)
|
6
|
-
[](http://www.rultor.com/p/yegor256/pdd)
|
4
|
+
[](http://www.rultor.com/p/cqfn/pdd)
|
8
5
|
[](https://www.jetbrains.com/ruby/)
|
9
6
|
|
10
|
-
[](https://github.com/yegor256/pdd/blob/master/LICENSE.txt)
|
7
|
+
[](http://www.0pdd.com/p?name=cqfn/pdd)
|
8
|
+
[](https://codecov.io/gh/cqfn/pdd)
|
9
|
+

|
10
|
+
[](https://hitsofcode.com/view/github/cqfn/pdd)
|
11
|
+
[](https://github.com/cqfn/pdd/blob/master/LICENSE.txt)
|
16
12
|
|
17
13
|
[](http://badge.fury.io/rb/pdd)
|
18
|
-
[](https://codeclimate.com/github/
|
19
|
-
[](http://rubydoc.info/github/
|
14
|
+
[](https://codeclimate.com/github/cqfn/pdd/maintainability)
|
15
|
+
[](http://rubydoc.info/github/cqfn/pdd/master/frames)
|
20
16
|
|
21
17
|
Read this article about
|
22
18
|
[_Puzzle Driven Development_](http://www.yegor256.com/2009/03/04/pdd.html).
|
@@ -41,7 +37,12 @@ Run it locally and read its output:
|
|
41
37
|
$ pdd --help
|
42
38
|
```
|
43
39
|
|
44
|
-
You can exclude certain files from the search
|
40
|
+
You can exclude & include certain number of files from the search via these options:
|
41
|
+
|
42
|
+
`` --exclude=glob ``
|
43
|
+
|
44
|
+
You can skip any file(s) with a name suffix that matches the pattern glob, using wildcard matching;
|
45
|
+
a name suffix is either the whole path and name, or reg expr, for example:
|
45
46
|
|
46
47
|
```bash
|
47
48
|
pdd --exclude=src/**/*.java --exclude=target/**/*
|
@@ -49,6 +50,17 @@ pdd --exclude=src/**/*.java # exclude .java files in src/
|
|
49
50
|
pdd --exclude=src/**/* # exclude all files in src/
|
50
51
|
```
|
51
52
|
|
53
|
+
`` --include=glob ``
|
54
|
+
|
55
|
+
Search only files whose name matches glob, using wildcard matching as described under ``--exclude``.
|
56
|
+
If contradictory ``--include`` and ``--exclude`` options are given, the last matching one wins.
|
57
|
+
If no ``--include`` or ``--exclude`` options are given, all files from working directory are included, example:
|
58
|
+
аомтрптм
|
59
|
+
```bash
|
60
|
+
pdd --include=src/**/*.py # include only .py files in src/
|
61
|
+
pdd --include=src/**/* # include all files in src/
|
62
|
+
```
|
63
|
+
|
52
64
|
## How to Format?
|
53
65
|
|
54
66
|
Every puzzle has to be formatted like this (pay attention
|
@@ -60,10 +72,13 @@ to the leading space in every consecutive line):
|
|
60
72
|
*/
|
61
73
|
[related code]
|
62
74
|
```
|
63
|
-
|
64
|
-
|
75
|
+
|
76
|
+
`[]` - Replace with apropriate data (see text enclosed in brackets)
|
77
|
+
|
78
|
+
`<>` - Omitable (enclosed data can be left out)
|
65
79
|
|
66
80
|
Example:
|
81
|
+
|
67
82
|
```java
|
68
83
|
/**
|
69
84
|
* @todo #234:15m/DEV This is something to do later
|
@@ -82,10 +97,16 @@ The specified markers will be included in the issues body
|
|
82
97
|
along with some predefined text. If your comment is longer
|
83
98
|
than 40 characters, it will be truncated in the title.
|
84
99
|
|
85
|
-
|
86
|
-
|
100
|
+
Note: if you create several puzzle duplicates (same text after puzzle keyword),
|
101
|
+
pdd will fail to parse puzzles and produce an error with duplicates list.
|
102
|
+
|
103
|
+
There are 3 supported keywords, one of which must precede the mandatory
|
104
|
+
puzzle marker. They are `@todo`, `TODO` and `TODO:`.
|
105
|
+
|
106
|
+
As an example, it starts with `@todo`, followed by a space and a mandatory
|
107
|
+
puzzle **marker**. Possible formats of puzzle markers (it doesn't matter what the
|
87
108
|
line starts with and where it is located,
|
88
|
-
as long as you have
|
109
|
+
as long as you have one of the 3 supported keywords right in front
|
89
110
|
of the mandatory marker):
|
90
111
|
|
91
112
|
```
|
@@ -94,12 +115,14 @@ of the mandatory marker):
|
|
94
115
|
# @todo #55:45min
|
95
116
|
@todo #67/DES
|
96
117
|
;; @todo #678:40m/DEV
|
118
|
+
// TODO: #1:30min
|
119
|
+
(* TODO #42 *)
|
97
120
|
```
|
98
121
|
|
99
122
|
Here `DES` and `DEV` are the roles of people who must fix that puzzles;
|
100
123
|
`45min` and `40m` is the amount of time the puzzle should take;
|
101
|
-
`224`, `TEST-13`, `55`, `67`, and `
|
102
|
-
puzzles are coming from.
|
124
|
+
`224`, `TEST-13`, `55`, `67`, `678`, `1`, and `42` are the IDs of the tickets
|
125
|
+
these puzzles are coming from.
|
103
126
|
|
104
127
|
Markers are absolutely necessary for all puzzles, because they allow
|
105
128
|
us to build a hierarchical dependency tree of all puzzles, like
|
@@ -122,18 +145,18 @@ parameter specified after a colon.
|
|
122
145
|
|
123
146
|
Here is a list of rules available now:
|
124
147
|
|
125
|
-
|
148
|
+
- `min-estimate:15` blocks all puzzles that don't have an estimate
|
126
149
|
or their estimates are less than 15 minutes.
|
127
150
|
|
128
|
-
|
151
|
+
- `max-estimate:120` blocks all puzzles with estimates over 120 minutes.
|
129
152
|
|
130
|
-
|
153
|
+
- `available-roles:DEV,IMP,DES` specifies a list of roles that
|
131
154
|
are allowed in puzzles. Puzzles without explicitly specified
|
132
155
|
roles will be rejected.
|
133
156
|
|
134
|
-
|
157
|
+
- `min-words:5` blocks puzzles with descriptions shorter than five words.
|
135
158
|
|
136
|
-
|
159
|
+
- `max-duplicates:1` blocks more than one duplicate of any puzzle.
|
137
160
|
This rule is used by default and you can't configure it at the moment,
|
138
161
|
it must always be set to `1`.
|
139
162
|
|
@@ -162,35 +185,42 @@ The XML produced will look approximately like this (here is a
|
|
162
185
|
</puzzle>
|
163
186
|
</puzzles>
|
164
187
|
```
|
188
|
+
NOTE: puzzles are saved with utf-8 encoding
|
165
189
|
|
166
190
|
[XSD Schema](http://pdd-xsd.teamed.io/0.19.4.xsd) is here.
|
167
191
|
The most interesting parts of each puzzle are:
|
168
192
|
|
169
|
-
|
170
|
-
|
193
|
+
- `ticket` is a ticket name puzzle marker starts from, in most
|
194
|
+
cases it will be the number of GitHub issue.
|
171
195
|
|
172
|
-
|
196
|
+
- `estimate` is the amount of minutes the puzzle is supposed to take.
|
173
197
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
198
|
+
- `id` is a unique ID of the puzzle. It is calculated by the
|
199
|
+
internal algorithm that takes into account only the text of the puzzle.
|
200
|
+
Thus, if you move the puzzle from one file to another, the ID won't
|
201
|
+
change. Also, changing the location of a puzzle inside a file
|
202
|
+
won't change its ID.
|
179
203
|
|
180
|
-
|
204
|
+
- `lines` is where the puzzle is found, inside the file.
|
181
205
|
|
182
206
|
## How to contribute
|
183
207
|
|
184
208
|
Read [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
|
185
|
-
Make sure
|
209
|
+
Make sure your build is green before you contribute
|
186
210
|
your pull request. You will need to have [Ruby](https://www.ruby-lang.org/en/) 2.3+ and
|
187
211
|
[Bundler](https://bundler.io/) installed. Then:
|
188
212
|
|
189
213
|
```
|
190
|
-
$ bundle
|
214
|
+
$ bundle install
|
191
215
|
$ bundle exec rake
|
192
216
|
```
|
193
217
|
|
218
|
+
Next, install and run overcommit to install hooks (required once)
|
219
|
+
```
|
220
|
+
$ gem install overcommit -v '=0.58.0'
|
221
|
+
$ overcommit --install
|
222
|
+
```
|
223
|
+
|
194
224
|
If it's clean and you don't see any error messages, submit your pull request.
|
195
225
|
|
196
226
|
This is how you run the tool locally to test how it works:
|
data/Rakefile
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
|
@@ -66,6 +66,12 @@ Xcop::RakeTask.new :xcop do |task|
|
|
66
66
|
task.excludes = ['target/**/*', 'coverage/**/*']
|
67
67
|
end
|
68
68
|
|
69
|
+
require 'pdd/rake_task'
|
70
|
+
desc 'Collecting and parsing all puzzles in project'
|
71
|
+
PDD::RakeTask.new :pdd do |task|
|
72
|
+
task.includes = ['**/*']
|
73
|
+
end
|
74
|
+
|
69
75
|
require 'cucumber/rake/task'
|
70
76
|
Cucumber::Rake::Task.new(:features) do |t|
|
71
77
|
t.cucumber_opts = 'features --format progress'
|
data/assets/puzzles.xsd
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
<!--
|
3
3
|
(The MIT License)
|
4
4
|
|
5
|
-
Copyright (c) 2014-
|
5
|
+
Copyright (c) 2014-2022 Yegor Bugayenko
|
6
6
|
|
7
7
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
of this software and associated documentation files (the 'Software'), to deal
|
data/assets/puzzles.xsl
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
<!--
|
3
3
|
(The MIT License)
|
4
4
|
|
5
|
-
Copyright (c) 2014-
|
5
|
+
Copyright (c) 2014-2022 Yegor Bugayenko
|
6
6
|
|
7
7
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
of this software and associated documentation files (the 'Software'), to deal
|
data/bin/pdd
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# Copyright (c) 2014-
|
2
|
+
# Copyright (c) 2014-2022 Yegor Bugayenko
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
5
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -19,8 +19,11 @@
|
|
19
19
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
20
20
|
# SOFTWARE.
|
21
21
|
|
22
|
-
|
22
|
+
$stdout.sync = true
|
23
23
|
|
24
|
+
require 'shellwords'
|
25
|
+
require 'English'
|
26
|
+
require 'find'
|
24
27
|
require 'slop'
|
25
28
|
require 'nokogiri'
|
26
29
|
require 'rainbow'
|
@@ -28,6 +31,8 @@ require_relative '../lib/pdd'
|
|
28
31
|
require_relative '../lib/pdd/version'
|
29
32
|
require_relative '../lib/pdd/source'
|
30
33
|
|
34
|
+
Rainbow.enabled = ENV['PDD_ENV'] == 'development'
|
35
|
+
|
31
36
|
begin
|
32
37
|
args = []
|
33
38
|
if File.exist?('.pdd')
|
@@ -46,6 +51,8 @@ begin
|
|
46
51
|
o.bool '-v', '--verbose', 'Enable verbose mode (a lot of logging)'
|
47
52
|
o.bool '-q', '--quiet', 'Enable quiet mode (almost no logging)'
|
48
53
|
o.bool '--skip-gitignore', 'Don\'t look into .gitignore for excludes'
|
54
|
+
o.bool '--skip-errors', 'Suppress error as warning and skip badly
|
55
|
+
formatted puzzles'
|
49
56
|
o.bool '-i', '--version', 'Show current version' do
|
50
57
|
puts PDD::VERSION
|
51
58
|
exit
|
@@ -54,20 +61,22 @@ begin
|
|
54
61
|
o.string '-f', '--file', 'File to save XML into'
|
55
62
|
o.array '-e', '--exclude', 'Glob pattern to exclude, e.g. "**/*.jpg"',
|
56
63
|
default: []
|
64
|
+
o.array '-n', '--include', 'Glob pattern to include, e.g. "**/*.jpg"',
|
65
|
+
default: []
|
57
66
|
o.string '-t', '--format', 'Format of the report (xml|html)'
|
58
67
|
o.array(
|
59
68
|
'-r', '--rule', 'Rule to apply (can be used many times)',
|
60
69
|
delimiter: ';'
|
61
70
|
)
|
62
71
|
end
|
63
|
-
rescue Slop::Error =>
|
64
|
-
raise StandardError, "#{
|
72
|
+
rescue Slop::Error => e
|
73
|
+
raise StandardError, "#{e.message}, try --help"
|
65
74
|
end
|
66
75
|
|
67
76
|
if opts.help?
|
68
77
|
puts opts
|
69
78
|
puts "This is our README to learn more: \
|
70
|
-
https://github.com/
|
79
|
+
https://github.com/cqfn/pdd/blob/master/README.md"
|
71
80
|
exit
|
72
81
|
end
|
73
82
|
|
@@ -75,13 +84,17 @@ https://github.com/yegor256/pdd/blob/master/README.md"
|
|
75
84
|
raise '-f is mandatory when using -v, try --help for more information'
|
76
85
|
end
|
77
86
|
|
78
|
-
if opts['skip-gitignore']
|
79
|
-
|
87
|
+
if opts['skip-gitignore'] && File.exist?('.gitignore')
|
88
|
+
cfg = File.new('.gitignore')
|
89
|
+
body = File.read(cfg)
|
90
|
+
extra = body.split(/\s+/).map(&:strip)
|
91
|
+
opts['skip-gitignore'] = extra
|
92
|
+
puts "Found #{body.split(/\n/).length} lines in #{File.absolute_path(cfg)}"
|
80
93
|
end
|
81
94
|
|
82
95
|
Encoding.default_external = Encoding::UTF_8
|
83
96
|
Encoding.default_internal = Encoding::UTF_8
|
84
|
-
file = opts.file? ? File.new(opts[:file], 'w') :
|
97
|
+
file = opts.file? ? File.new(opts[:file], 'w') : $stdout
|
85
98
|
output = PDD::Base.new(opts).xml
|
86
99
|
if opts[:format]
|
87
100
|
if opts[:format] == 'html'
|
@@ -95,21 +108,21 @@ https://github.com/yegor256/pdd/blob/master/README.md"
|
|
95
108
|
end
|
96
109
|
end
|
97
110
|
file << output
|
98
|
-
rescue SystemExit =>
|
99
|
-
puts
|
100
|
-
PDD.log.info "Exit code is #{
|
101
|
-
exit(
|
102
|
-
rescue PDD::Error =>
|
103
|
-
puts "#{Rainbow('ERROR').red}: #{
|
111
|
+
rescue SystemExit => e
|
112
|
+
puts e.message unless e.success?
|
113
|
+
PDD.log.info "Exit code is #{e.status}"
|
114
|
+
exit(e.status)
|
115
|
+
rescue PDD::Error => e
|
116
|
+
puts "#{Rainbow('ERROR').red}: #{e.message}
|
104
117
|
If you can't understand the cause of this issue or you don't know \
|
105
118
|
how to fix it, please submit a GitHub issue, we will try to help you: \
|
106
|
-
https://github.com/
|
119
|
+
https://github.com/cqfn/pdd/issues. This tool is still in its beta \
|
107
120
|
version and we will appreciate your feedback. Here is where you can find \
|
108
|
-
more documentation: https://github.com/
|
121
|
+
more documentation: https://github.com/cqfn/pdd/blob/master/README.md."
|
109
122
|
PDD.log.info 'Exit code is 1'
|
110
123
|
exit(1)
|
111
|
-
rescue StandardError =>
|
112
|
-
puts "#{Rainbow('ERROR').red} (#{
|
124
|
+
rescue StandardError => e
|
125
|
+
puts "#{Rainbow('ERROR').red} (#{e.class.name}): #{e.message}"
|
113
126
|
PDD.log.info 'Exit code is 255'
|
114
127
|
exit(255)
|
115
128
|
end
|