pdd 0.20.7 → 0.21.1

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8220e74b7aca6e6feddfe8ccad195c1156386ad766ae1dd31311122242c1292c
4
- data.tar.gz: 97816bbe7fdfdb29d595683dd98b6eb41d6bc1880e269c4dc11eee4a2b02f582
3
+ metadata.gz: ef027790e2aa528548fcb97f52632e7740f2a28a9ed7180677bf189ba86b504f
4
+ data.tar.gz: 2432ac79d70ebb056a6b1338ca52b170e2c7134d14b32d0e8454e34ff86f57ad
5
5
  SHA512:
6
- metadata.gz: c4128efeb2b302351595bbe99978845e8d8d546f11e341c0d0308821e673f6f2aa2730c4d2170751d711892d17942563275641b8dbec04916d9bb7bac8715f2a
7
- data.tar.gz: 501ddaf76735e9ce50ae3a233c45331d568075979ef3875395e7d361139e008954de9767e14856af7d247adf2a597254b3e89104cc96e5832baa03a278f89a3c
6
+ metadata.gz: 8c91ee447d2b8aefde998e6516fdd1679c845b3a2360f8325a944e0833fe5818f23c7dfb465b0242dabc9828742849220951cbd8e91fc014e9603c78c83e4be8
7
+ data.tar.gz: 2910617b72caa5ad9b083fd6e1471fd6dcf8bb9e3ccea0ecf3577c5eaa060e4468f0278798cca1e77ce5ad9b77117486d55e5e3d536308c27931dce9dec0c60d
@@ -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
@@ -1,8 +1,8 @@
1
- coverage/
1
+ coverage/**/*
2
2
  Gemfile.lock
3
- .idea/
3
+ .idea/**/*
4
4
  *.gem
5
- .bundle/
5
+ .bundle/**/*
6
6
  .DS_Store
7
- rdoc/
8
- tmp/
7
+ rdoc/**/*
8
+ tmp/**/*
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,9 +1,10 @@
1
1
  --source=.
2
2
  --verbose
3
- --skip-errors
4
3
  --exclude .idea/**/*
4
+ --exclude .bundle/**/*
5
5
  --exclude target/**/*
6
6
  --exclude coverage/**/*
7
+ --exclude test_assets/**/*
7
8
  --exclude README.md
8
9
  --exclude features/cli.feature
9
10
  --exclude features/parsing.feature
@@ -21,3 +22,4 @@
21
22
  --rule min-words:20
22
23
  --rule min-estimate:15
23
24
  --rule max-estimate:90
25
+
data/.rubocop.yml CHANGED
@@ -1,23 +1,22 @@
1
1
  AllCops:
2
2
  Exclude:
3
- - 'assets/**/*'
3
+ - "assets/**/*"
4
4
  DisplayCopNames: true
5
5
  TargetRubyVersion: 2.3
6
6
 
7
7
  Layout/EndOfLine:
8
8
  EnforcedStyle: lf
9
9
  Metrics/ClassLength:
10
- Max: 300
10
+ Max: 360
11
+ Metrics/LineLength:
12
+ Max: 90
11
13
  Metrics/MethodLength:
12
- Max: 30
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
- export GEM_HOME=~/.ruby
6
- export GEM_PATH=$GEM_HOME:$GEM_PATH
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
- pdd -f /dev/null
13
- LC_ALL=US-ASCII bundle exec rake
10
+ [[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit -1
11
+ bundle exec rake
14
12
  rm -rf *.gem
15
- sed -i "s/1\.0\.snapshot/${tag}/g" lib/pdd/version.rb
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 'Nothing to deploy'
24
+ echo "There is nothing to deploy"
32
25
  exit -1
data/.simplecov 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,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? then
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 "/test/"
27
- add_filter "/features/"
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 "/test/"
35
- add_filter "/features/"
34
+ add_filter '/test/'
35
+ add_filter '/features/'
36
36
  minimum_coverage 90
37
37
  end
38
38
  end
data/CITATION.cff ADDED
@@ -0,0 +1,25 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use this software, please cite it as below."
3
+ authors:
4
+ - family-names: "Bugayenko"
5
+ given-names: "Yegor"
6
+ orcid: "https://orcid.org/0000-0001-6370-0678"
7
+ - family-names: "Bakare"
8
+ given-names: "Ayomide"
9
+ - family-names: "Cheverda"
10
+ given-names: "Arina"
11
+ - family-names: "Farina"
12
+ given-names: "Mirko"
13
+ - family-names: "Kruglov"
14
+ given-names: "Artem"
15
+ - family-names: "Plaksin"
16
+ given-names: "Yaroslav"
17
+ - family-names: "Succi"
18
+ given-names: "Giancarlo"
19
+ - family-names: "Pedrycz"
20
+ given-names: "Witold"
21
+ title: "Automatically Prioritizing and Assigning Tasks from Code Repositories in Puzzle Driven Development"
22
+ version: 0.21.0
23
+ doi: 10.1145/3524842.3528512
24
+ date-released: 2022-05-09
25
+ url: "https://github.com/cqfn/pdd"
data/Gemfile 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
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2014-2021 Yegor Bugayenko
3
+ Copyright (c) 2014-2022 Yegor Bugayenko
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the 'Software'), to deal
data/README.md CHANGED
@@ -1,16 +1,12 @@
1
- <img src="https://avatars2.githubusercontent.com/u/24456188" width="64px" height="64px"/>
2
-
3
- [![Donate via Zerocracy](https://www.0crat.com/contrib-badge/C3T46CUJJ.svg)](https://www.0crat.com/contrib/C3T46CUJJ)
1
+ <img alt="pdd logo" src="https://avatars2.githubusercontent.com/u/24456188" width="92px" height="92px"/>
4
2
 
5
3
  [![EO principles respected here](https://www.elegantobjects.org/badge.svg)](https://www.elegantobjects.org)
6
- [![Managed by Zerocracy](https://www.0crat.com/badge/C3T46CUJJ.svg)](https://www.0crat.com/p/C3T46CUJJ)
7
4
  [![DevOps By Rultor.com](http://www.rultor.com/b/cqfn/pdd)](http://www.rultor.com/p/cqfn/pdd)
8
5
  [![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)
9
6
 
10
- [![Build Status](https://travis-ci.org/cqfn/pdd.svg)](https://travis-ci.org/cqfn/pdd)
11
- [![Build status](https://ci.appveyor.com/api/projects/status/b59sdhuu0gcku15b?svg=true)](https://ci.appveyor.com/project/cqfn/pdd)
12
7
  [![PDD status](http://www.0pdd.com/svg?name=cqfn/pdd)](http://www.0pdd.com/p?name=cqfn/pdd)
13
- [![Test Coverage](https://img.shields.io/codecov/c/github/cqfn/pdd.svg)](https://codecov.io/github/cqfn/pdd?branch=master)
8
+ [![codecov](https://codecov.io/gh/cqfn/pdd/branch/master/graph/badge.svg)](https://codecov.io/gh/cqfn/pdd)
9
+ ![Lines of code](https://img.shields.io/tokei/lines/github/cqfn/pdd)
14
10
  [![Hits-of-Code](https://hitsofcode.com/github/cqfn/pdd)](https://hitsofcode.com/view/github/cqfn/pdd)
15
11
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/cqfn/pdd/blob/master/LICENSE.txt)
16
12
 
@@ -29,7 +25,8 @@ Read
29
25
  [_PDD in Action_](http://www.yegor256.com/2017/04/05/pdd-in-action.html)
30
26
  and watch [this webinar](https://www.youtube.com/watch?v=nsYGC2aUwfQ).
31
27
 
32
- Install it first:
28
+ You should have [Ruby installed](https://www.ruby-lang.org/en/documentation/installation/).
29
+ Then, install our gem:
33
30
 
34
31
  ```bash
35
32
  $ gem install pdd
@@ -41,12 +38,34 @@ Run it locally and read its output:
41
38
  $ pdd --help
42
39
  ```
43
40
 
44
- You can exclude certain files from the search, for example:
41
+ You can exclude & include certain number of files from the search via these options:
42
+
43
+ ```
44
+ $ pdd --exclude=glob
45
+ ```
46
+
47
+ You can skip any file(s) with a name suffix that matches the pattern glob, using wildcard matching;
48
+ a name suffix is either the whole path and name, or reg expr, for example:
49
+
50
+ ```bash
51
+ $ pdd --exclude=src/**/*.java --exclude=target/**/*
52
+ $ pdd --exclude=src/**/*.java # exclude .java files in src/
53
+ $ pdd --exclude=src/**/* # exclude all files in src/
54
+ ```
55
+
56
+ You can include too:
57
+
58
+ ```
59
+ $ pdd --include=glob
60
+ ```
61
+
62
+ Search only files whose name matches glob, using wildcard matching as described under ``--exclude``.
63
+ If contradictory ``--include`` and ``--exclude`` options are given, the last matching one wins.
64
+ If no ``--include`` or ``--exclude`` options are given, all files from working directory are included, example:
45
65
 
46
66
  ```bash
47
- pdd --exclude=src/**/*.java --exclude=target/**/*
48
- pdd --exclude=src/**/*.java # exclude .java files in src/
49
- pdd --exclude=src/**/* # exclude all files in src/
67
+ $ pdd --include=src/**/*.py # include only .py files in src/
68
+ $ pdd --include=src/**/* # include all files in src/
50
69
  ```
51
70
 
52
71
  ## How to Format?
@@ -61,8 +80,9 @@ to the leading space in every consecutive line):
61
80
  [related code]
62
81
  ```
63
82
 
64
- \[\] - Replace with apropriate data (see text enclosed in brackets)
65
- <> - Omitable (enclosed data can be left out)
83
+ `[]` - Replace with apropriate data (see text enclosed in brackets)
84
+
85
+ `<>` - Omitable (enclosed data can be left out)
66
86
 
67
87
  Example:
68
88
 
@@ -84,6 +104,9 @@ The specified markers will be included in the issues body
84
104
  along with some predefined text. If your comment is longer
85
105
  than 40 characters, it will be truncated in the title.
86
106
 
107
+ Note: if you create several puzzle duplicates (same text after puzzle keyword),
108
+ pdd will fail to parse puzzles and produce an error with duplicates list.
109
+
87
110
  There are 3 supported keywords, one of which must precede the mandatory
88
111
  puzzle marker. They are `@todo`, `TODO` and `TODO:`.
89
112
 
@@ -169,6 +192,7 @@ The XML produced will look approximately like this (here is a
169
192
  </puzzle>
170
193
  </puzzles>
171
194
  ```
195
+ NOTE: puzzles are saved with utf-8 encoding
172
196
 
173
197
  [XSD Schema](http://pdd-xsd.teamed.io/0.19.4.xsd) is here.
174
198
  The most interesting parts of each puzzle are:
@@ -189,15 +213,21 @@ The most interesting parts of each puzzle are:
189
213
  ## How to contribute
190
214
 
191
215
  Read [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
192
- Make sure you build is green before you contribute
216
+ Make sure your build is green before you contribute
193
217
  your pull request. You will need to have [Ruby](https://www.ruby-lang.org/en/) 2.3+ and
194
218
  [Bundler](https://bundler.io/) installed. Then:
195
219
 
196
220
  ```
197
- $ bundle update
221
+ $ bundle install
198
222
  $ bundle exec rake
199
223
  ```
200
224
 
225
+ Next, install and run overcommit to install hooks (required once)
226
+ ```
227
+ $ gem install overcommit -v '=0.58.0'
228
+ $ overcommit --install
229
+ ```
230
+
201
231
  If it's clean and you don't see any error messages, submit your pull request.
202
232
 
203
233
  This is how you run the tool locally to test how it works:
data/Rakefile 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
@@ -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-2021 Yegor Bugayenko
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-2021 Yegor Bugayenko
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-2021 Yegor Bugayenko
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,7 +19,7 @@
19
19
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
20
  # SOFTWARE.
21
21
 
22
- STDOUT.sync = true
22
+ $stdout.sync = true
23
23
 
24
24
  require 'shellwords'
25
25
  require 'English'
@@ -31,6 +31,8 @@ require_relative '../lib/pdd'
31
31
  require_relative '../lib/pdd/version'
32
32
  require_relative '../lib/pdd/source'
33
33
 
34
+ Rainbow.enabled = ENV['PDD_ENV'] == 'development'
35
+
34
36
  begin
35
37
  args = []
36
38
  if File.exist?('.pdd')
@@ -42,11 +44,6 @@ begin
42
44
  end
43
45
  args += ARGV
44
46
 
45
- dir = Dir.pwd
46
- @dir = File.absolute_path(dir)
47
- files = Dir.glob(
48
- File.join(@dir, '**/*'), File::FNM_DOTMATCH
49
- ).reject { |f| File.directory?(f) }
50
47
  begin
51
48
  opts = Slop.parse(args, strict: true, help: true) do |o|
52
49
  o.banner = "Usage (#{PDD::VERSION}): pdd [options]"
@@ -65,15 +62,15 @@ begin
65
62
  o.array '-e', '--exclude', 'Glob pattern to exclude, e.g. "**/*.jpg"',
66
63
  default: []
67
64
  o.array '-n', '--include', 'Glob pattern to include, e.g. "**/*.jpg"',
68
- default: [files]
65
+ default: []
69
66
  o.string '-t', '--format', 'Format of the report (xml|html)'
70
67
  o.array(
71
68
  '-r', '--rule', 'Rule to apply (can be used many times)',
72
69
  delimiter: ';'
73
70
  )
74
71
  end
75
- rescue Slop::Error => ex
76
- raise StandardError, "#{ex.message}, try --help"
72
+ rescue Slop::Error => e
73
+ raise StandardError, "#{e.message}, try --help"
77
74
  end
78
75
 
79
76
  if opts.help?
@@ -87,13 +84,17 @@ https://github.com/cqfn/pdd/blob/master/README.md"
87
84
  raise '-f is mandatory when using -v, try --help for more information'
88
85
  end
89
86
 
90
- if opts['skip-gitignore']
91
- raise 'For --skip-gitignore see https://github.com/cqfn/pdd/issues/80'
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)}"
92
93
  end
93
94
 
94
95
  Encoding.default_external = Encoding::UTF_8
95
96
  Encoding.default_internal = Encoding::UTF_8
96
- file = opts.file? ? File.new(opts[:file], 'w') : STDOUT
97
+ file = opts.file? ? File.new(opts[:file], 'w') : $stdout
97
98
  output = PDD::Base.new(opts).xml
98
99
  if opts[:format]
99
100
  if opts[:format] == 'html'
@@ -107,12 +108,12 @@ https://github.com/cqfn/pdd/blob/master/README.md"
107
108
  end
108
109
  end
109
110
  file << output
110
- rescue SystemExit => ex
111
- puts ex.message unless ex.success?
112
- PDD.log.info "Exit code is #{ex.status}"
113
- exit(ex.status)
114
- rescue PDD::Error => ex
115
- puts "#{Rainbow('ERROR').red}: #{ex.message}
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}
116
117
  If you can't understand the cause of this issue or you don't know \
117
118
  how to fix it, please submit a GitHub issue, we will try to help you: \
118
119
  https://github.com/cqfn/pdd/issues. This tool is still in its beta \
@@ -120,8 +121,8 @@ version and we will appreciate your feedback. Here is where you can find \
120
121
  more documentation: https://github.com/cqfn/pdd/blob/master/README.md."
121
122
  PDD.log.info 'Exit code is 1'
122
123
  exit(1)
123
- rescue StandardError => ex
124
- puts "#{Rainbow('ERROR').red} (#{ex.class.name}): #{ex.message}"
124
+ rescue StandardError => e
125
+ puts "#{Rainbow('ERROR').red} (#{e.class.name}): #{e.message}"
125
126
  PDD.log.info 'Exit code is 255'
126
127
  exit(255)
127
128
  end
@@ -11,30 +11,12 @@ Feature: Catches Broken Puzzles
11
11
  * Some other documentation
12
12
  * text that is not relevant to
13
13
  * the puzzle below.
14
- * @todo #13 This puzzle has an incorrect format
15
- * because it doesn't start with a space on
16
- * the second and the third lines
14
+ * @todo This puzzle has an incorrect format
15
+ * because it doesn't have a ticket number
17
16
  */
18
17
  public void main(String[] args) {
19
18
  // later
20
19
  }
21
20
  }
22
21
  """
23
- When I run pdd it fails with "Space expected"
24
22
  When I run pdd it fails with "Sample.java:6"
25
-
26
- Scenario: Throwing exception on yet another broken puzzle
27
- Given I have a "Sample.java" file with content:
28
- """
29
- public class Main {
30
- //
31
- // @todo #13 This puzzle has an incorrect format
32
- // because there is no space character in the
33
- // second and third lines
34
- //
35
- public void main(String[] args) {
36
- // later
37
- }
38
- }
39
- """
40
- When I run pdd it fails with "Space expected"
data/features/cli.feature CHANGED
@@ -26,7 +26,7 @@ Feature: Command Line Processing
26
26
  """
27
27
  When I run bin/pdd with "-v -s . -f out.xml"
28
28
  Then Exit code is zero
29
- And Stdout contains "Reading ."
29
+ And Stdout contains "Reading from root dir ."
30
30
  And XML file "out.xml" matches "/puzzles[count(puzzle)=1]"
31
31
  And XML file "out.xml" matches "//puzzle[starts-with(body,'Привет, Let')]"
32
32
 
@@ -18,5 +18,5 @@ Feature: HTML output
18
18
  """
19
19
  When I run bin/pdd with "-v -s . -f out.html --format=html"
20
20
  Then Exit code is zero
21
- And Stdout contains "Reading ."
21
+ And Stdout contains "Reading from root dir ."
22
22
  And XML file "out.html" matches "/html/body"