syntax_tree 3.0.0 → 3.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 28783cde4387bbc7d38d9de500564804cd885733abe59e017be73ce04981a854
4
- data.tar.gz: 6a54750102b8978df75e7f8a7d611e596067bb69863f91d5a8daa9aec8509c31
3
+ metadata.gz: 499aba04c732c3101f3e3ebb7d487a19842781a0a97b67fad047c2cf9bbe2bcb
4
+ data.tar.gz: dc9e28898951ae74f3a053b261b8d1e752567917bbb8eb34a4aa22af6b49b716
5
5
  SHA512:
6
- metadata.gz: c2f61f01bfa53604686798c96a53d8c98abd30145038db3b7f73f92c5c6b282447f3fe355382f6b3325b3ee98ce60ddcc5c102234b78e9c8d1fe9cbf006cb38d
7
- data.tar.gz: e5a63e7fdc4f7e70e354a5861e42b8c0dffbbd2ffde38754c0a1fca8a6033be2deecd52ea3ec5fb7a2aa05e0d07ab93d3b4d69762ca3c911f36a6e898ef2ffaf
6
+ metadata.gz: 3a8cdd3933efaaa8898cfa25bebd3e52d3b6632081319d8ddded59dacb996ebd11232d1060e408eb93bdb4211aa4d2775bfce970ba868264f7846dcb63873e5e
7
+ data.tar.gz: 673c601ce6a25cc4875b2041710b4a85f5114a24deb1cb5e3bf69a464e072f72f24f2e13cb3aa89d95076a5d7643beb6469ccd669018e75d9ac998aeb0a10ddf
data/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [3.0.1] - 2022-07-15
10
+
11
+ ### Changed
12
+
13
+ - [#112](https://github.com/ruby-syntax-tree/syntax_tree/pull/112) - Fix parallel CLI execution by not short-circuiting with the `||` operator.
14
+
9
15
  ## [3.0.0] - 2022-07-04
10
16
 
11
17
  ### Changed
@@ -288,7 +294,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
288
294
 
289
295
  - 🎉 Initial release! 🎉
290
296
 
291
- [unreleased]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v2.9.0...HEAD
297
+ [unreleased]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v3.0.1...HEAD
298
+ [3.0.1]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v3.0.0...v3.0.1
299
+ [3.0.0]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v2.9.0...v3.0.0
292
300
  [2.9.0]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v2.8.0...v2.9.0
293
301
  [2.8.0]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v2.7.1...v2.8.0
294
302
  [2.7.1]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v2.7.0...v2.7.1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- syntax_tree (3.0.0)
4
+ syntax_tree (3.0.1)
5
5
  prettier_print
6
6
 
7
7
  GEM
@@ -19,7 +19,7 @@ GEM
19
19
  rake (13.0.6)
20
20
  regexp_parser (2.5.0)
21
21
  rexml (3.2.5)
22
- rubocop (1.31.1)
22
+ rubocop (1.31.2)
23
23
  json (~> 2.3)
24
24
  parallel (~> 1.10)
25
25
  parser (>= 3.1.0.0)
@@ -315,23 +315,7 @@ module SyntaxTree
315
315
 
316
316
  # At the end, we're going to return whether or not this worker ever
317
317
  # encountered an error.
318
- errored =
319
- with_workers(queue) do |item|
320
- action.run(item)
321
- false
322
- rescue Parser::ParseError => error
323
- warn("Error: #{error.message}")
324
- highlight_error(error, item.source)
325
- true
326
- rescue Check::UnformattedError, Debug::NonIdempotentFormatError
327
- true
328
- rescue StandardError => error
329
- warn(error.message)
330
- warn(error.backtrace)
331
- true
332
- end
333
-
334
- if errored
318
+ if process_queue(queue, action)
335
319
  action.failure
336
320
  1
337
321
  else
@@ -342,13 +326,11 @@ module SyntaxTree
342
326
 
343
327
  private
344
328
 
345
- def with_workers(queue)
346
- # If the queue is just 1 item, then we're not going to bother going
347
- # through the whole ceremony of parallelizing the work.
348
- return yield queue.shift if queue.size == 1
349
-
329
+ # Processes each item in the queue with the given action. Returns whether
330
+ # or not any errors were encountered.
331
+ def process_queue(queue, action)
350
332
  workers =
351
- Etc.nprocessors.times.map do
333
+ [Etc.nprocessors, queue.size].min.times.map do
352
334
  Thread.new do
353
335
  # Propagate errors in the worker threads up to the parent thread.
354
336
  Thread.current.abort_on_exception = true
@@ -360,7 +342,25 @@ module SyntaxTree
360
342
 
361
343
  # While there is still work left to do, shift off the queue and
362
344
  # process the item.
363
- (errored ||= yield queue.shift) until queue.empty?
345
+ until queue.empty?
346
+ item = queue.shift
347
+ errored |=
348
+ begin
349
+ action.run(item)
350
+ false
351
+ rescue Parser::ParseError => error
352
+ warn("Error: #{error.message}")
353
+ highlight_error(error, item.source)
354
+ true
355
+ rescue Check::UnformattedError,
356
+ Debug::NonIdempotentFormatError
357
+ true
358
+ rescue StandardError => error
359
+ warn(error.message)
360
+ warn(error.backtrace)
361
+ true
362
+ end
363
+ end
364
364
 
365
365
  # At the end, we're going to return whether or not this worker
366
366
  # ever encountered an error.
@@ -368,7 +368,7 @@ module SyntaxTree
368
368
  end
369
369
  end
370
370
 
371
- workers.inject(false) { |accum, thread| accum || thread.value }
371
+ workers.map(&:value).inject(:|)
372
372
  end
373
373
 
374
374
  # Highlights a snippet from a source and parse error.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SyntaxTree
4
- VERSION = "3.0.0"
4
+ VERSION = "3.0.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syntax_tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Newton
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-05 00:00:00.000000000 Z
11
+ date: 2022-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prettier_print