pdd 0.23.2 → 0.24.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b31cfabb478220287ba41490879fa0387cf0d08a1f62872119fefa5c69fc71db
4
- data.tar.gz: 7022a7f4b8a3777a2ff801cc1c054c73159b678d5f7d176db482204923a05268
3
+ metadata.gz: 91fcdc9f020a0b464387833136eb5cd9c55c40c995cce419950587a899d6b1a4
4
+ data.tar.gz: 7638e25104a15816702cc73c797df3fcf6673b85761864d2ae5a1d3749f90b14
5
5
  SHA512:
6
- metadata.gz: 389bb7338dffb8967201649556f6774dc39e8417233ffaf53c8e1c492aaa0dff53f1419ffb40f31f0737621584b91cd841b19726074a58bd781d80b02f82050b
7
- data.tar.gz: cc378cc62f5a3dba820d1c0c10a571ce158ed4b1aff7425756bb596fae9e91784819d8648e69654e4f77a7e8a7ed7f9505e8635aba693f0c577731cfa0906be7
6
+ metadata.gz: 61502311ce40384236b872397b728a15a9633401376c1ec79718b314d96f9a86e3e3a899f7267d93633c3b9842272ad77bfdbe904cd9133ce49a057a1b548dcb
7
+ data.tar.gz: 35e1de4d7b2318bd77c662016fbea96619165f309b512c59897ea5270ad5973c681b835638d8d4bcc2a48e83b25b84bc7597e5ddaeda7b27e51b2dc8c6aee714
@@ -4,17 +4,20 @@ on:
4
4
  push:
5
5
  branches:
6
6
  - master
7
+ pull_request:
8
+ branches:
9
+ - master
7
10
  jobs:
8
11
  codecov:
9
- runs-on: ubuntu-20.04
12
+ runs-on: ubuntu-22.04
10
13
  steps:
11
- - uses: actions/checkout@v2
12
- - uses: actions/setup-ruby@v1
14
+ - uses: actions/checkout@v4
15
+ - uses: ruby/setup-ruby@v1
13
16
  with:
14
- ruby-version: 2.7
17
+ ruby-version: '2.7'
15
18
  - run: bundle update
16
19
  - run: bundle exec rake
17
- - uses: codecov/codecov-action@v1
20
+ - uses: codecov/codecov-action@v4
18
21
  with:
19
- file: coverage/.resultset.json
22
+ token: ${{ secrets.CODECOV_TOKEN }}
20
23
  fail_ci_if_error: true
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: pdd
3
- "on":
3
+ on:
4
4
  push:
5
5
  branches:
6
6
  - master
@@ -9,7 +9,7 @@ name: pdd
9
9
  - master
10
10
  jobs:
11
11
  pdd:
12
- runs-on: ubuntu-20.04
12
+ runs-on: ubuntu-22.04
13
13
  steps:
14
- - uses: actions/checkout@v2
15
- - uses: g4s8/pdd-action@master
14
+ - uses: actions/checkout@v4
15
+ - uses: volodya-lombrozo/pdd-action@master
@@ -8,16 +8,16 @@ on:
8
8
  branches:
9
9
  - master
10
10
  jobs:
11
- test:
12
- name: test
11
+ rake:
12
+ name: rake
13
13
  strategy:
14
14
  matrix:
15
15
  os: [ubuntu-20.04]
16
- ruby: [2.7]
16
+ ruby: ['2.7', '3.0']
17
17
  runs-on: ${{ matrix.os }}
18
18
  steps:
19
- - uses: actions/checkout@v2
20
- - uses: actions/setup-ruby@v1
19
+ - uses: actions/checkout@v4
20
+ - uses: ruby/setup-ruby@v1
21
21
  with:
22
22
  ruby-version: ${{ matrix.ruby }}
23
23
  - run: bundle update
data/.pdd CHANGED
@@ -12,6 +12,7 @@
12
12
  --exclude features/remove.feature
13
13
  --exclude features/uses_config.feature
14
14
  --exclude features/html_output.feature
15
+ --exclude features/json_output.feature
15
16
  --exclude features/avoiding_duplicates.feature
16
17
  --exclude features/applies_rules.feature
17
18
  --exclude features/unicode.feature
data/.rultor.yml CHANGED
@@ -1,11 +1,12 @@
1
1
  docker:
2
- image: yegor256/rultor-image:1.20.0
2
+ image: yegor256/rultor-image:1.22.0
3
3
  assets:
4
4
  rubygems.yml: yegor256/home#assets/rubygems.yml
5
5
  install: |
6
6
  pdd -f /dev/null
7
- sudo bundle install --no-color "--gemfile=$(pwd)/Gemfile"
7
+ bundle install --no-color
8
8
  release:
9
+ pre: false
9
10
  script: |-
10
11
  [[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit -1
11
12
  bundle exec rake
data/.simplecov CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2014-2023 Yegor Bugayenko
1
+ # Copyright (c) 2014-2024 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,18 @@
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?
22
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
23
- SimpleCov::Formatter::HTMLFormatter
24
- ]
25
- SimpleCov.start do
26
- add_filter '/test/'
27
- add_filter '/features/'
28
- end
29
- else
30
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
31
- SimpleCov::Formatter::HTMLFormatter
32
- )
33
- SimpleCov.start do
34
- add_filter '/test/'
35
- add_filter '/features/'
36
- minimum_coverage 90
37
- end
21
+ SimpleCov.formatter = if Gem.win_platform?
22
+ SimpleCov::Formatter::MultiFormatter[
23
+ SimpleCov::Formatter::HTMLFormatter
24
+ ]
25
+ else
26
+ SimpleCov::Formatter::MultiFormatter.new(
27
+ SimpleCov::Formatter::HTMLFormatter
28
+ )
29
+ end
30
+
31
+ SimpleCov.start do
32
+ add_filter '/test/'
33
+ add_filter '/features/'
34
+ minimum_coverage 90
38
35
  end
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2014-2023 Yegor Bugayenko
1
+ # Copyright (c) 2014-2024 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
@@ -27,8 +27,9 @@ gem 'minitest', '5.16.2', require: false
27
27
  gem 'rake', '13.0.6', require: false
28
28
  gem 'rdoc', '6.4.0', require: false
29
29
  gem 'rspec-rails', '5.1.2', require: false
30
- gem 'rubocop', '1.53.1', require: false
30
+ gem 'rubocop', '1.60.2', require: false
31
31
  gem 'rubocop-rspec', '2.22.0', require: false
32
32
  gem 'simplecov', '0.22.0', require: false
33
+ gem 'simplecov-cobertura', '~> 2.1'
33
34
  gem 'slop', '4.9.2', require: false
34
35
  gem 'xcop', '0.7.1', require: false
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  (The MIT License)
2
2
 
3
- Copyright (c) 2014-2023 Yegor Bugayenko
3
+ Copyright (c) 2014-2024 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
@@ -6,8 +6,7 @@
6
6
 
7
7
  [![rake](https://github.com/cqfn/pdd/actions/workflows/rake.yml/badge.svg)](https://github.com/cqfn/pdd/actions/workflows/rake.yml)
8
8
  [![PDD status](http://www.0pdd.com/svg?name=cqfn/pdd)](http://www.0pdd.com/p?name=cqfn/pdd)
9
- [![codecov](https://codecov.io/gh/cqfn/pdd/branch/master/graph/badge.svg)](https://codecov.io/gh/cqfn/pdd)
10
- ![Lines of code](https://img.shields.io/tokei/lines/github/cqfn/pdd)
9
+ [![codecov](https://codecov.io/gh/yegor256/pdd/branch/master/graph/badge.svg)](https://codecov.io/gh/yegor/pdd)
11
10
  [![Hits-of-Code](https://hitsofcode.com/github/cqfn/pdd)](https://hitsofcode.com/view/github/cqfn/pdd)
12
11
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/cqfn/pdd/blob/master/LICENSE.txt)
13
12
  [![Gem Version](https://badge.fury.io/rb/pdd.svg)](http://badge.fury.io/rb/pdd)
@@ -26,8 +25,7 @@ Read
26
25
  [_PDD in Action_](http://www.yegor256.com/2017/04/05/pdd-in-action.html)
27
26
  and watch [this webinar](https://www.youtube.com/watch?v=nsYGC2aUwfQ).
28
27
 
29
- You should have [Ruby installed](https://www.ruby-lang.org/en/documentation/installation/).
30
- Then, install our gem:
28
+ First, make sure Ruby 2.6+ and [`libmagic`](#how-to-install-libmagic) are installed. Then, install our gem:
31
29
 
32
30
  ```bash
33
31
  $ gem install pdd
@@ -39,25 +37,27 @@ Run it locally and read its output:
39
37
  $ pdd --help
40
38
  ```
41
39
 
40
+ ## Usage
41
+
42
42
  You can exclude & include certain number of files from the search via these options:
43
43
 
44
- ```
45
- $ pdd --exclude=glob
44
+ ```bash
45
+ $ pdd --exclude glob
46
46
  ```
47
47
 
48
48
  You can skip any file(s) with a name suffix that matches the pattern glob, using wildcard matching;
49
49
  a name suffix is either the whole path and name, or reg expr, for example:
50
50
 
51
51
  ```bash
52
- $ pdd --exclude=src/**/*.java --exclude=target/**/*
53
- $ pdd --exclude=src/**/*.java # exclude .java files in src/
54
- $ pdd --exclude=src/**/* # exclude all files in src/
52
+ $ pdd --exclude src/**/*.java --exclude target/**/*
53
+ $ pdd --exclude src/**/*.java # exclude .java files in src/
54
+ $ pdd --exclude src/**/* # exclude all files in src/
55
55
  ```
56
56
 
57
57
  You can include too:
58
58
 
59
- ```
60
- $ pdd --include=glob
59
+ ```bash
60
+ $ pdd --include glob
61
61
  ```
62
62
 
63
63
  Search only files whose name matches glob, using wildcard matching as described under ``--exclude``.
@@ -65,10 +65,34 @@ If contradictory ``--include`` and ``--exclude`` options are given, the last mat
65
65
  If no ``--include`` or ``--exclude`` options are given, all files from working directory are included, example:
66
66
 
67
67
  ```bash
68
- $ pdd --include=src/**/*.py # include only .py files in src/
69
- $ pdd --include=src/**/* # include all files in src/
68
+ $ pdd --include src/**/*.py # include only .py files in src/
69
+ $ pdd --include src/**/* # include all files in src/
70
70
  ```
71
71
 
72
+ Full command format is (all parameters are optional):
73
+ ```bash
74
+ $ pdd [--verbose] [--quiet] [--remove] [--skip-gitignore] [--skip-errors] \
75
+ [--source <project_dir_path>] [--file puzzles_file.xml] [--include src/**/*.py] \
76
+ [--format xml|html] [--rule min-words:5] [--exclude src/**/*.java]
77
+ ```
78
+
79
+ | Parameter | Description |
80
+ |-------------------------|---------------------------------------------------------------------------------------|
81
+ | --verbose | Enable verbose (debug) mode. --file must be used in case of using this option |
82
+ | --quiet | Disable logs |
83
+ | --remove | Remove all found puzzles from the source code |
84
+ | --skip-gitignore | Don't look into .gitignore for excludes |
85
+ | --skip-errors | Suppress error as warning and skip badly formatted puzzles (do not skip broken rules) |
86
+ | --source <project-path> | Source directory to parse ("." by default) |
87
+ | --file puzzles.xml | File to save report into (xml of html) (displayed in console by default) |
88
+ | --include *.py | Glob pattern to include (can be used several times) |
89
+ | --exclude *.java | Glob pattern to exclude (can be used several times) |
90
+ | --format xml | Format of the report xml or html (xml is default) |
91
+ | --rule min-words:5 | Rule to apply (can be used several times), described later |
92
+
93
+ :bulb: There is an option to create a .pdd file in your project and save all required parameters in it.
94
+ File example you can see in this project.
95
+
72
96
  ## How to Format?
73
97
 
74
98
  Every puzzle has to be formatted like this (pay attention
@@ -81,9 +105,9 @@ to the leading space in every consecutive line):
81
105
  [related code]
82
106
  ```
83
107
 
84
- `[]` - Replace with apropriate data (see text enclosed in brackets)
108
+ `[]` - Replace with appropriate data (see text enclosed in brackets)
85
109
 
86
- `<>` - Omitable (enclosed data can be left out)
110
+ `<>` - Optional (enclosed data can be left out)
87
111
 
88
112
  Example:
89
113
 
@@ -92,6 +116,10 @@ Example:
92
116
  * @todo #234:15m/DEV This is something to do later
93
117
  * in one of the next releases. I can't figure out
94
118
  * how to implement it now, that's why the puzzle.
119
+ * The text can be so long, as needed, just use
120
+ * the same anount of spaces, as the second line.
121
+ * This text will be not a part of the puzzle, as
122
+ * it has less spaces.
95
123
  */
96
124
  void sendEmail() {
97
125
  throw new UnsupportedOperationException();
@@ -118,18 +146,16 @@ as long as you have one of the 3 supported keywords right in front
118
146
  of the mandatory marker):
119
147
 
120
148
  ```
121
- // @todo #224
122
- /* @todo #TEST-13 */
123
- # @todo #55:45min
124
- @todo #67/DES
125
- ;; @todo #678:40m/DEV
126
- // TODO: #1:30min
127
- (* TODO #42 *)
149
+ // @todo #224 Puzzle description
150
+ # @todo #55:45min Puzzle description
151
+ @todo #67/DES Puzzle description
152
+ ;; @todo #678:40m/DEV Puzzle description
153
+ // TODO: #TEST-21:30min Puzzle description
128
154
  ```
129
155
 
130
156
  Here `DES` and `DEV` are the roles of people who must fix that puzzles;
131
157
  `45min` and `40m` is the amount of time the puzzle should take;
132
- `224`, `TEST-13`, `55`, `67`, `678`, `1`, and `42` are the IDs of the tickets
158
+ `224`, `55`, `67`, `678` and `TEST-21` are the IDs of the tickets
133
159
  these puzzles are coming from.
134
160
 
135
161
  Markers are absolutely necessary for all puzzles, because they allow
@@ -138,13 +164,50 @@ us to build a hierarchical dependency tree of all puzzles, like
138
164
  for example. Technically, of course, you can abuse the system
139
165
  and put a dummy `#1` marker everywhere.
140
166
 
167
+ ### Multiline examples
168
+
169
+ For multiline puzzles there are two important things:
170
+ - **prefix** - any optional text followed by space before puzzle keyword (todo).
171
+ It should be the same for all lines of puzzle description.
172
+ - \ symbol can be used to logically divide puzzle description.
173
+ prefix should be presented with it.
174
+
175
+ Examples:
176
+
177
+ ```xml
178
+ <!--
179
+ ~ if comment should be started and closed by special symbols, then place them in
180
+ ~ a separate lines
181
+ ~ Any symbol can be used as a prefix, it will be excluded from the text.
182
+ ~ But do not forget about the space before puzzle keyword.
183
+ ~
184
+ ~ @todo #34 Description can be as long as needed.
185
+ ~ Just use at least the same amount of the spaces, as on the first line.
186
+ ~ It will be added to description.
187
+ -->
188
+ ```
189
+
190
+ ```java
191
+ /**
192
+ * @todo #36 Multiline text can use the same prefix in all lines or the same
193
+ * amount of spaces.
194
+ * So this will be added to the puzzle description. If you want to divide the
195
+ * puzzle logically by empty line, just add a backspace to that line
196
+ * \
197
+ * and continue the text after.
198
+ *
199
+ * This line is not part of the puzzle, because the line before does not contain
200
+ * prefix.
201
+ */
202
+ ```
203
+
141
204
  ## How to Configure Rules?
142
205
 
143
206
  You can specify post-parsing rules for your puzzles, in command line,
144
207
  for example:
145
208
 
146
- ```
147
- $ pdd --rule=min-estimate:60 --rule=max-estimate:120
209
+ ```bash
210
+ $ pdd --rule min-estimate:60 --rule max-estimate:120
148
211
  ```
149
212
 
150
213
  These two parameters will add two post-parsing rules `min-estimate`
@@ -168,7 +231,7 @@ Here is a list of rules available now:
168
231
  This rule is used by default and you can't configure it at the moment,
169
232
  it must always be set to `1`.
170
233
 
171
- You can put all command line options into `.pdd` file. The options from the
234
+ :bulb: You can put all command line options into `.pdd` file. The options from the
172
235
  file will be used first. Command line options may be added on top of them.
173
236
  See, how it is done in [yegor256/0pdd](https://github.com/yegor256/0pdd/blob/master/.pdd).
174
237
 
@@ -211,20 +274,38 @@ The most interesting parts of each puzzle are:
211
274
 
212
275
  - `lines` is where the puzzle is found, inside the file.
213
276
 
277
+ ## How to install libmagic
278
+
279
+ For Debian/Ubuntu:
280
+
281
+ ```bash
282
+ $ apt install libmagic-dev
283
+ ```
284
+
285
+ For Mac:
286
+
287
+ ```bash
288
+ $ brew install libmagic
289
+ ```
290
+
291
+ Unfortunately, there is no easy way to install on Windows, try to use
292
+ [WSL](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux) or
293
+ [Docker](https://www.docker.com/).
294
+
214
295
  ## How to contribute
215
296
 
216
297
  Read [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
217
298
  Make sure your build is green before you contribute
218
- your pull request. You will need to have [Ruby](https://www.ruby-lang.org/en/) 2.3+ and
299
+ your pull request. You will need to have [Ruby](https://www.ruby-lang.org/en/) 2.7+ and
219
300
  [Bundler](https://bundler.io/) installed. Then:
220
301
 
221
- ```
302
+ ```bash
222
303
  $ bundle install
223
304
  $ bundle exec rake
224
305
  ```
225
306
 
226
307
  Next, install and run overcommit to install hooks (required once)
227
- ```
308
+ ```bash
228
309
  $ gem install overcommit -v '=0.58.0'
229
310
  $ overcommit --install
230
311
  ```
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2014-2023 Yegor Bugayenko
1
+ # Copyright (c) 2014-2024 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
@@ -74,12 +74,15 @@ end
74
74
 
75
75
  require 'cucumber/rake/task'
76
76
  Cucumber::Rake::Task.new(:features) do |t|
77
- t.cucumber_opts = 'features'
77
+ t.cucumber_opts = %w[features --strict-undefined]
78
78
  Rake::Cleaner.cleanup_files(['coverage'])
79
79
  end
80
80
  Cucumber::Rake::Task.new(:'features:html') do |t|
81
81
  t.profile = 'html_report'
82
82
  end
83
+ Cucumber::Rake::Task.new(:'features:json') do |t|
84
+ t.profile = 'json_report'
85
+ end
83
86
 
84
87
  task :copyright do
85
88
  sh "grep -q -r '2014-#{Date.today.strftime('%Y')}' \
data/assets/puzzles.xsd CHANGED
@@ -2,7 +2,7 @@
2
2
  <!--
3
3
  (The MIT License)
4
4
 
5
- Copyright (c) 2014-2023 Yegor Bugayenko
5
+ Copyright (c) 2014-2024 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-2023 Yegor Bugayenko
5
+ Copyright (c) 2014-2024 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
@@ -0,0 +1,79 @@
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ (The MIT License)
4
+
5
+ Copyright (c) 2014-2024 Yegor Bugayenko
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ of this software and associated documentation files (the 'Software'), to deal
9
+ in the Software without restriction, including without limitation the rights
10
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the Software is
12
+ furnished to do so, subject to the following conditions:
13
+
14
+ The above copyright notice and this permission notice shall be included in all
15
+ copies or substantial portions of the Software.
16
+
17
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
+ SOFTWARE.
24
+ -->
25
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
26
+ <xsl:output method="text" omit-xml-declaration="yes"/>
27
+ <xsl:template match="/"><xsl:text disable-output-escaping="yes">{</xsl:text><xsl:apply-templates select="puzzles"/>
28
+ "puzzles": [
29
+ <xsl:apply-templates select="puzzles/puzzle"/>
30
+ <xsl:text disable-output-escaping="yes">
31
+ ]
32
+ }</xsl:text>
33
+ </xsl:template>
34
+ <xsl:template match="puzzles">
35
+ <xsl:text>
36
+ "version": "</xsl:text>
37
+ <xsl:value-of select="@version"/>
38
+ <xsl:text>",</xsl:text>
39
+ <xsl:text>
40
+ "date": "</xsl:text>
41
+ <xsl:value-of select="@date"/>
42
+ <xsl:text>", </xsl:text>
43
+ </xsl:template>
44
+ <xsl:template match="puzzle">
45
+ <xsl:text disable-output-escaping="no">{</xsl:text>
46
+ <xsl:text>
47
+ "id": "</xsl:text>
48
+ <xsl:value-of select="id"/>
49
+ <xsl:text>", </xsl:text>
50
+ <xsl:text>
51
+ "ticket": "</xsl:text>
52
+ <xsl:value-of select="ticket"/>
53
+ <xsl:text>", </xsl:text>
54
+ <xsl:text>
55
+ "file": "</xsl:text>
56
+ <xsl:value-of select="file"/>
57
+ <xsl:text>", </xsl:text>
58
+ <xsl:text>
59
+ "lines": "</xsl:text>
60
+ <xsl:value-of select="lines"/>
61
+ <xsl:text>", </xsl:text>
62
+ <xsl:text>
63
+ "body": "</xsl:text>
64
+ <xsl:value-of select="translate(body, '&quot;', '&#x201C;')"/>
65
+ <xsl:text>", </xsl:text>
66
+ <xsl:text>
67
+ "estimate": "</xsl:text>
68
+ <xsl:value-of select="estimate"/>
69
+ <xsl:text>", </xsl:text>
70
+ <xsl:text>
71
+ "role": "</xsl:text>
72
+ <xsl:value-of select="role"/>
73
+ <xsl:text>"</xsl:text>
74
+ <xsl:text disable-output-escaping="yes">
75
+ }</xsl:text>
76
+ <xsl:if test="position() != last()">,
77
+ </xsl:if>
78
+ </xsl:template>
79
+ </xsl:stylesheet>
data/bin/pdd CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # Copyright (c) 2014-2023 Yegor Bugayenko
2
+ # Copyright (c) 2014-2024 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
@@ -59,12 +59,12 @@ begin
59
59
  exit
60
60
  end
61
61
  o.string '-s', '--source', 'Source directory to parse ("." by default)'
62
- o.string '-f', '--file', 'File to save XML into'
62
+ o.string '-f', '--file', 'File to save report into'
63
63
  o.array '-e', '--exclude', 'Glob pattern to exclude, e.g. "**/*.jpg"',
64
64
  default: []
65
65
  o.array '-n', '--include', 'Glob pattern to include, e.g. "**/*.jpg"',
66
66
  default: []
67
- o.string '-t', '--format', 'Format of the report (xml|html)'
67
+ o.string '-t', '--format', 'Format of the report (xml|html|json)'
68
68
  o.array(
69
69
  '-r', '--rule', 'Rule to apply (can be used many times)',
70
70
  delimiter: ';'
@@ -87,7 +87,8 @@ https://github.com/cqfn/pdd/blob/master/README.md"
87
87
 
88
88
  if opts['skip-gitignore'] && File.exist?('.gitignore')
89
89
  cfg = File.new('.gitignore')
90
- body = File.read(cfg)
90
+ body = ''
91
+ File.foreach(cfg) { |line| body << line unless line.start_with?('#') }
91
92
  extra = body.split(/\s+/).map(&:strip)
92
93
  opts['skip-gitignore'] = extra
93
94
  PDD.log.info "Found #{body.split("\n").length} lines in #{File.absolute_path(cfg)}"
@@ -105,8 +106,15 @@ https://github.com/cqfn/pdd/blob/master/README.md"
105
106
  'assets', 'puzzles.xsl'
106
107
  )
107
108
  output = Nokogiri::XSLT(File.read(xslt)).transform(Nokogiri::XML(xml))
109
+ elsif opts[:format] == 'json'
110
+ xslt = File.join(
111
+ File.dirname(File.dirname(__FILE__)),
112
+ 'assets', 'puzzles_json.xsl'
113
+ )
114
+ # result is not xml, so use apply
115
+ output = Nokogiri::XSLT(File.read(xslt)).apply_to(Nokogiri::XML(xml))
108
116
  elsif opts[:format] != 'xml'
109
- raise 'Invalid format, use html or xml'
117
+ raise 'Invalid format, use html or xml or json'
110
118
  end
111
119
  end
112
120
  file << output
data/cucumber.yml CHANGED
@@ -1,3 +1,4 @@
1
1
  default: --format pretty
2
2
  travis: --format progress
3
3
  html_report: --format progress --format html --out=features_report.html
4
+ json_report: --format progress --format json --out=features_report.json