expressir 2.4.49-x86_64-linux → 2.4.51-x86_64-linux

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: 617bee062356d46fe984799b820bf54723a54d2c083402fbb87aff31a8cc2a94
4
- data.tar.gz: cce93172ddd05c894322b2c5b431f3955f1bc33e3156379d8562024f6ceffb44
3
+ metadata.gz: f5b38ad89a25a72a6f8d07f578bc0ac380a4ab428a663c07a0b578bcc82365f5
4
+ data.tar.gz: e2eb4c1fc45741fc5077b8118a1236e8de820a4aceddb8064a093fe0f65166f4
5
5
  SHA512:
6
- metadata.gz: 98dacca7f2042a7f3e1f51db083f41f97fede1a8a0f22956ca2ebf6f7e03336f20d1d4438af62c5a35d9d21d3c9ac2d810136c00462c3bcd9a7fddf11662fe53
7
- data.tar.gz: ac33350581d741515ddaa393052d60c76aca53bf70ecbe745cf0d44162c4632bf7f95b8e2efe42e50fd43a79ea906aea48959a067c5bfac77b2279561dc88374
6
+ metadata.gz: 95543a97135a89b036836644a11e13bf8e493691ebfc3d44c0f3d7aa09940ada86452c54f71f33ce7770eb9b2ea7f980bd075d5c0c21bcc98120c68d7929d6ef
7
+ data.tar.gz: 6cf60b5b2532bcc1219cc53ce025be7f4de9f805e4f4caa1c1e26d7f53148d85ddc71b1ee82df9ff905f0790d09781a2b20334bcd0409802d06913618724898c
data/expressir.gemspec CHANGED
@@ -50,7 +50,7 @@ Gem::Specification.new do |spec|
50
50
  # 0.8.151 is the first lutaml-model whose moxml constraint (>= 0.5.139,
51
51
  # < 0.7) admits the moxml 0.6 line; earlier releases pin moxml
52
52
  # ~> 0.5.139 and cannot co-resolve with the moxml floor below.
53
- spec.add_dependency "lutaml-model", "~> 0.8.156"
53
+ spec.add_dependency "lutaml-model", "~> 0.8.159"
54
54
  spec.add_dependency "moxml", "~> 0.6.0"
55
55
  spec.add_dependency "paint"
56
56
  spec.add_dependency "parsanol", "~> 1.3.123"
@@ -1,3 +1,5 @@
1
+ require "etc"
2
+
1
3
  module Expressir
2
4
  module Commands
3
5
  class Base
@@ -7,6 +9,17 @@ module Expressir
7
9
  @options = options
8
10
  end
9
11
 
12
+ # The parallel-parse worker count for the validate family: the
13
+ # explicit --jobs value, or every core (issue #584). The
14
+ # ParallelFiles facility degrades to sequential where fork is
15
+ # unavailable (e.g. Windows).
16
+ def jobs_count
17
+ jobs = options[:jobs]
18
+ return jobs if jobs.is_a?(Integer) && jobs >= 1
19
+
20
+ Etc.nprocessors
21
+ end
22
+
10
23
  # Common utilities that all commands might need
11
24
  def say(message)
12
25
  # Use instance variable for testability - if output is set, use it
@@ -29,6 +29,9 @@ module Expressir
29
29
  DESC
30
30
  method_option :verbose, type: :boolean, default: false,
31
31
  desc: "Show verbose output"
32
+ method_option :jobs, type: :numeric,
33
+ desc: "Parallel parse workers (issue #584; " \
34
+ "default: every core, 1 = sequential)"
32
35
  def load(*paths)
33
36
  ValidateLoad.new(options).run(paths)
34
37
  end
@@ -83,6 +86,9 @@ module Expressir
83
86
  desc "remarks PATH_OR_MANIFEST",
84
87
  "Validate remark blocks: a block anchor ([[name]]) must be " \
85
88
  "defined in a single remark scope per schema"
89
+ method_option :jobs, type: :numeric,
90
+ desc: "Parallel parse workers (issue #584; " \
91
+ "default: every core, 1 = sequential)"
86
92
  def remarks(*paths)
87
93
  ValidateRemarks.new(options).run(paths)
88
94
  end
@@ -40,18 +40,36 @@ module Expressir
40
40
  no_version = []
41
41
  no_valid = []
42
42
 
43
- paths.each do |path|
43
+ # The parses fan out across forked workers (issue #584); the
44
+ # reporting stays on the main thread, in input order. Small
45
+ # sets stay sequential (the facility's own threshold).
46
+ parse = ->(path) do
47
+ Expressir::Express::Parser.from_file(path)
48
+ rescue StandardError
49
+ nil
50
+ end
51
+ results =
52
+ if Expressir::Express::ParallelFiles.sequential?(paths, jobs_count)
53
+ paths.map { |path| parse.call(path) }
54
+ else
55
+ Expressir::Express::ParallelFiles.run(
56
+ paths, parse: parse, max_processes: jobs_count
57
+ )
58
+ end
59
+
60
+ paths.zip(results).each do |path, repository|
44
61
  x = Pathname.new(path).realpath.relative_path_from(Dir.pwd)
45
62
  say "Validating #{x}"
46
- ret = validate_schema(path)
47
63
 
48
- if ret.nil?
64
+ if repository.nil?
49
65
  no_valid << "Failed to parse: #{x}"
50
66
  next
51
67
  end
52
68
 
53
- ret.each do |schema_id|
54
- no_version << "Missing version string: schema `#{schema_id}` | #{x}"
69
+ repository.schemas.each do |schema|
70
+ unless schema.version&.value
71
+ no_version << "Missing version string: schema `#{schema.id}` | #{x}"
72
+ end
55
73
  end
56
74
  end
57
75
 
@@ -68,16 +86,6 @@ module Expressir
68
86
  say "Validation passed for all EXPRESS schemas."
69
87
  end
70
88
 
71
- def validate_schema(path)
72
- repository = Expressir::Express::Parser.from_file(path)
73
- repository.schemas.inject([]) do |acc, schema|
74
- acc << schema.id unless schema.version&.value
75
- acc
76
- end
77
- rescue StandardError
78
- nil
79
- end
80
-
81
89
  def print_validation_errors(type, array)
82
90
  return if array.empty?
83
91
 
@@ -52,10 +52,22 @@ module Expressir
52
52
  end
53
53
 
54
54
  def validate_from_paths(paths)
55
- parsed = schema_paths(paths).map do |path|
56
- repository = Expressir::Express::Parser.from_file(path)
57
- [path, repository.schemas]
58
- end
55
+ files = schema_paths(paths)
56
+ # The parses fan out across forked workers (issue #584); a
57
+ # parse failure raises in input order, exactly like the
58
+ # sequential pass did. Small sets stay sequential (the
59
+ # facility's own threshold).
60
+ parse = ->(path) { Expressir::Express::Parser.from_file(path) }
61
+ results =
62
+ if Expressir::Express::ParallelFiles.sequential?(files, jobs_count)
63
+ files.map { |path| parse.call(path) }
64
+ else
65
+ Expressir::Express::ParallelFiles.run(
66
+ files, parse: parse, max_processes: jobs_count, strict: true
67
+ )
68
+ end
69
+ parsed = files.zip(results)
70
+ .filter_map { |path, repository| repository && [path, repository.schemas] }
59
71
  schema_ids = parsed.flat_map { |_, schemas| schemas.map(&:id) }
60
72
  .map { |id| id.to_s.downcase }
61
73
 
@@ -3,6 +3,6 @@ module Expressir
3
3
  # autoload it (Ruby autoload only works for module/class constants, not
4
4
  # for string constants like `Expressir::VERSION`).
5
5
  module Version
6
- VERSION = "2.4.49".freeze
6
+ VERSION = "2.4.51".freeze
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expressir
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.49
4
+ version: 2.4.51
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Ribose Inc.
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.8.156
89
+ version: 0.8.159
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.8.156
96
+ version: 0.8.159
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: moxml
99
99
  requirement: !ruby/object:Gem::Requirement