mnogootex 0.2.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/main.yml +41 -0
  3. data/.gitignore +3 -0
  4. data/.rspec +0 -2
  5. data/.rubocop.yml +13 -0
  6. data/CODE_OF_CONDUCT.md +1 -1
  7. data/Gemfile +4 -3
  8. data/Guardfile +56 -0
  9. data/README.md +163 -17
  10. data/Rakefile +25 -4
  11. data/exe/mnogootex +2 -92
  12. data/lib/mnogootex/cfg.rb +62 -0
  13. data/lib/mnogootex/cli.rb +80 -0
  14. data/lib/mnogootex/core_ext.rb +11 -0
  15. data/lib/mnogootex/defaults.yml +7 -0
  16. data/lib/mnogootex/job/logger.rb +53 -0
  17. data/lib/mnogootex/job/porter.rb +53 -0
  18. data/lib/mnogootex/job/runner.rb +43 -0
  19. data/lib/mnogootex/job/warden.rb +100 -0
  20. data/lib/mnogootex/log/level.rb +17 -0
  21. data/lib/mnogootex/log/levels.yml +29 -0
  22. data/lib/mnogootex/log/line.rb +14 -0
  23. data/lib/mnogootex/log/matcher.rb +17 -0
  24. data/lib/mnogootex/log/matchers.yml +205 -0
  25. data/lib/mnogootex/log/processor.rb +115 -0
  26. data/lib/mnogootex/log.rb +23 -0
  27. data/lib/mnogootex/mnogoo.sh +21 -0
  28. data/lib/mnogootex/utils.rb +27 -0
  29. data/lib/mnogootex/version.rb +3 -1
  30. data/lib/mnogootex.rb +4 -4
  31. data/mnogootex.gemspec +43 -18
  32. data/spec/mnogootex/cfg_spec.rb +54 -0
  33. data/spec/mnogootex/job/porter_spec.rb +140 -0
  34. data/spec/mnogootex/job/runner_spec.rb +74 -0
  35. data/spec/mnogootex/log/processor_spec.rb +203 -0
  36. data/spec/mnogootex/utils_spec.rb +52 -0
  37. data/spec/spec_helper.rb +124 -0
  38. data/tty.gif +0 -0
  39. metadata +148 -29
  40. data/.gitmodules +0 -3
  41. data/.travis.yml +0 -5
  42. data/bin/console +0 -14
  43. data/bin/setup +0 -8
  44. data/lib/mnogootex/configuration.rb +0 -46
  45. data/lib/mnogootex/job.rb +0 -75
@@ -0,0 +1,124 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'timeout'
4
+
5
+ if ENV['COVERAGE'] == 'true'
6
+ require 'simplecov'
7
+
8
+ SimpleCov.configure do
9
+ track_files 'lib/**/*.rb'
10
+ add_filter '/spec/'
11
+ end
12
+
13
+ # SimpleCov.at_exit do
14
+ # SimpleCov.result.format!
15
+ # puts "#{SimpleCov.result.covered_percent.floor}%"
16
+ # end
17
+
18
+ SimpleCov.start
19
+ end
20
+
21
+ # This file was generated by the `rspec --init` command. Conventionally, all
22
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
23
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
24
+ # this file to always be loaded, without a need to explicitly require it in any
25
+ # files.
26
+ #
27
+ # Given that it is always loaded, you are encouraged to keep this file as
28
+ # light-weight as possible. Requiring heavyweight dependencies from this file
29
+ # will add to the boot time of your test suite on EVERY test run, even for an
30
+ # individual file that may not need all of that loaded. Instead, consider making
31
+ # a separate helper file that requires the additional dependencies and performs
32
+ # the additional setup, and require it from the spec files that actually need
33
+ # it.
34
+ #
35
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
36
+ RSpec.configure do |config|
37
+ config.fail_fast = true
38
+ # rspec-expectations config goes here. You can use an alternate
39
+ # assertion/expectation library such as wrong or the stdlib/minitest
40
+ # assertions if you prefer.
41
+ config.expect_with :rspec do |expectations|
42
+ # This option will default to `true` in RSpec 4. It makes the `description`
43
+ # and `failure_message` of custom matchers include text for helper methods
44
+ # defined using `chain`, e.g.:
45
+ # be_bigger_than(2).and_smaller_than(4).description
46
+ # # => "be bigger than 2 and smaller than 4"
47
+ # ...rather than:
48
+ # # => "be bigger than 2"
49
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
50
+ end
51
+
52
+ # rspec-mocks config goes here. You can use an alternate test double
53
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
54
+ config.mock_with :rspec do |mocks|
55
+ # Prevents you from mocking or stubbing a method that does not exist on
56
+ # a real object. This is generally recommended, and will default to
57
+ # `true` in RSpec 4.
58
+ mocks.verify_partial_doubles = true
59
+ end
60
+
61
+ # This option will default to `:apply_to_host_groups` in RSpec 4 (and will
62
+ # have no way to turn it off -- the option exists only for backwards
63
+ # compatibility in RSpec 3). It causes shared context metadata to be
64
+ # inherited by the metadata hash of host groups and examples, rather than
65
+ # triggering implicit auto-inclusion in groups with matching metadata.
66
+ config.shared_context_metadata_behavior = :apply_to_host_groups
67
+
68
+ # The settings below are suggested to provide a good initial experience
69
+ # with RSpec, but feel free to customize to your heart's content.
70
+ # # This allows you to limit a spec run to individual examples or groups
71
+ # # you care about by tagging them with `:focus` metadata. When nothing
72
+ # # is tagged with `:focus`, all examples get run. RSpec also provides
73
+ # # aliases for `it`, `describe`, and `context` that include `:focus`
74
+ # # metadata: `fit`, `fdescribe` and `fcontext`, respectively.
75
+ config.filter_run_when_matching :focus
76
+ #
77
+ # # Allows RSpec to persist some state between runs in order to support
78
+ # # the `--only-failures` and `--next-failure` CLI options. We recommend
79
+ # # you configure your source control system to ignore this file.
80
+ # config.example_status_persistence_file_path = "spec/examples.txt"
81
+ #
82
+ # # Limits the available syntax to the non-monkey patched syntax that is
83
+ # # recommended. For more details, see:
84
+ # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
85
+ # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
86
+ # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
87
+ # config.disable_monkey_patching!
88
+ #
89
+ # # This setting enables warnings. It's recommended, but in some cases may
90
+ # # be too noisy due to issues in dependencies.
91
+ # config.warnings = true
92
+ #
93
+ # # Many RSpec users commonly either run the entire suite or an individual
94
+ # # file, and it's useful to allow more verbose output when running an
95
+ # # individual spec file.
96
+ if config.files_to_run.one?
97
+ # Use the documentation formatter for detailed output,
98
+ # unless a formatter has already been configured
99
+ # (e.g. via a command-line flag).
100
+ config.default_formatter = 'doc'
101
+ end
102
+ #
103
+ # # Print the 10 slowest examples and example groups at the
104
+ # # end of the spec run, to help surface which specs are running
105
+ # # particularly slow.
106
+ # config.profile_examples = 10
107
+ #
108
+ # # Run specs in random order to surface order dependencies. If you find an
109
+ # # order dependency and want to debug it, you can fix the order by providing
110
+ # # the seed, which is printed after each run.
111
+ # # --seed 1234
112
+ config.order = :random
113
+ #
114
+ # # Seed global randomization in this process using the `--seed` CLI option.
115
+ # # Setting this allows you to use `--seed` to deterministically reproduce
116
+ # # test failures related to randomization by passing the same `--seed` value
117
+ # # as the one that triggered the failure.
118
+ # Kernel.srand config.seed
119
+
120
+ # # Timeout to help mutant
121
+ # config.around(:each) do |example|
122
+ # Timeout.timeout(0.1, &example)
123
+ # end
124
+ end
data/tty.gif ADDED
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mnogootex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paolo Brasolin
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-06 00:00:00.000000000 Z
11
+ date: 2021-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,59 +16,158 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.16'
19
+ version: 2.2.30
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.16'
26
+ version: 2.2.30
27
+ - !ruby/object:Gem::Dependency
28
+ name: byebug
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 11.1.3
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 11.1.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: guard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 2.18.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 2.18.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 4.7.3
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 4.7.3
27
69
  - !ruby/object:Gem::Dependency
28
70
  name: rake
29
71
  requirement: !ruby/object:Gem::Requirement
30
72
  requirements:
31
73
  - - "~>"
32
74
  - !ruby/object:Gem::Version
33
- version: '10.0'
75
+ version: 13.0.6
34
76
  type: :development
35
77
  prerelease: false
36
78
  version_requirements: !ruby/object:Gem::Requirement
37
79
  requirements:
38
80
  - - "~>"
39
81
  - !ruby/object:Gem::Version
40
- version: '10.0'
82
+ version: 13.0.6
41
83
  - !ruby/object:Gem::Dependency
42
84
  name: rspec
43
85
  requirement: !ruby/object:Gem::Requirement
44
86
  requirements:
45
87
  - - "~>"
46
88
  - !ruby/object:Gem::Version
47
- version: '3.0'
89
+ version: 3.10.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 3.10.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.22.3
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 1.22.3
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.21.2
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.21.2
125
+ - !ruby/object:Gem::Dependency
126
+ name: yard
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 0.9.26
48
132
  type: :development
49
133
  prerelease: false
50
134
  version_requirements: !ruby/object:Gem::Requirement
51
135
  requirements:
52
136
  - - "~>"
53
137
  - !ruby/object:Gem::Version
54
- version: '3.0'
138
+ version: 0.9.26
55
139
  - !ruby/object:Gem::Dependency
56
140
  name: colorize
57
141
  requirement: !ruby/object:Gem::Requirement
58
142
  requirements:
59
- - - ">="
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 0.8.1
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 0.8.1
153
+ - !ruby/object:Gem::Dependency
154
+ name: thor
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
60
158
  - !ruby/object:Gem::Version
61
- version: '0'
159
+ version: 0.20.0
62
160
  type: :runtime
63
161
  prerelease: false
64
162
  version_requirements: !ruby/object:Gem::Requirement
65
163
  requirements:
66
- - - ">="
164
+ - - "~>"
67
165
  - !ruby/object:Gem::Version
68
- version: '0'
69
- description: Mnogootex (многоꙮтех) is a device to handle the compilation of TeX sources
70
- with different preambles at one time. This avoids wasting time when you have to
71
- submit a paper to journals using outdated or crummy document classes.
166
+ version: 0.20.0
167
+ description: Многоꙮтех (mnogootex) is a utility that parallelizes compilation of a
168
+ LaTeX document using different classes and offers a meaningfully filtered output.
169
+ The motivating use case is maintaining a single preamble while submitting a paper
170
+ to many journals using their outdated or crummy document classes.
72
171
  email:
73
172
  - paolo.brasolin@gmail.com
74
173
  executables:
@@ -76,28 +175,49 @@ executables:
76
175
  extensions: []
77
176
  extra_rdoc_files: []
78
177
  files:
178
+ - ".github/workflows/main.yml"
79
179
  - ".gitignore"
80
- - ".gitmodules"
81
180
  - ".rspec"
82
- - ".travis.yml"
181
+ - ".rubocop.yml"
83
182
  - CODE_OF_CONDUCT.md
84
183
  - Gemfile
184
+ - Guardfile
85
185
  - LICENSE.txt
86
186
  - README.md
87
187
  - Rakefile
88
- - bin/console
89
- - bin/setup
90
188
  - exe/mnogootex
91
189
  - lib/mnogootex.rb
92
- - lib/mnogootex/configuration.rb
93
- - lib/mnogootex/job.rb
190
+ - lib/mnogootex/cfg.rb
191
+ - lib/mnogootex/cli.rb
192
+ - lib/mnogootex/core_ext.rb
193
+ - lib/mnogootex/defaults.yml
194
+ - lib/mnogootex/job/logger.rb
195
+ - lib/mnogootex/job/porter.rb
196
+ - lib/mnogootex/job/runner.rb
197
+ - lib/mnogootex/job/warden.rb
198
+ - lib/mnogootex/log.rb
199
+ - lib/mnogootex/log/level.rb
200
+ - lib/mnogootex/log/levels.yml
201
+ - lib/mnogootex/log/line.rb
202
+ - lib/mnogootex/log/matcher.rb
203
+ - lib/mnogootex/log/matchers.yml
204
+ - lib/mnogootex/log/processor.rb
205
+ - lib/mnogootex/mnogoo.sh
206
+ - lib/mnogootex/utils.rb
94
207
  - lib/mnogootex/version.rb
95
208
  - mnogootex.gemspec
209
+ - spec/mnogootex/cfg_spec.rb
210
+ - spec/mnogootex/job/porter_spec.rb
211
+ - spec/mnogootex/job/runner_spec.rb
212
+ - spec/mnogootex/log/processor_spec.rb
213
+ - spec/mnogootex/utils_spec.rb
214
+ - spec/spec_helper.rb
215
+ - tty.gif
96
216
  homepage: https://github.com/tetrapharmakon/mnogootex
97
217
  licenses:
98
218
  - MIT
99
219
  metadata: {}
100
- post_install_message:
220
+ post_install_message:
101
221
  rdoc_options: []
102
222
  require_paths:
103
223
  - lib
@@ -105,17 +225,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
105
225
  requirements:
106
226
  - - ">="
107
227
  - !ruby/object:Gem::Version
108
- version: '0'
228
+ version: '2.6'
109
229
  required_rubygems_version: !ruby/object:Gem::Requirement
110
230
  requirements:
111
231
  - - ">="
112
232
  - !ruby/object:Gem::Version
113
233
  version: '0'
114
234
  requirements: []
115
- rubyforge_project:
116
- rubygems_version: 2.6.13
117
- signing_key:
235
+ rubygems_version: 3.1.4
236
+ signing_key:
118
237
  specification_version: 4
119
- summary: Mnogootex (многоꙮтех) is a device to handle the compilation of TeX sources
120
- with different preambles at one time.
238
+ summary: Многоꙮтех (mnogootex) is a utility that parallelizes compilation of a LaTeX
239
+ document using different classes and offers a meaningfully filtered output.
121
240
  test_files: []
data/.gitmodules DELETED
@@ -1,3 +0,0 @@
1
- [submodule "mnogootex_classes"]
2
- path = mnogootex_classes
3
- url = https://paolobrasolin@bitbucket.org/paolobrasolin/mnogootex_classes.git
data/.travis.yml DELETED
@@ -1,5 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.3.5
5
- before_install: gem install bundler -v 1.16.1
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "mnogootex"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1,46 +0,0 @@
1
- # coding: utf-8
2
-
3
- require 'yaml'
4
-
5
- module Mnogootex
6
- class Configuration < Hash
7
- DEFAULT = {
8
- 'animation' => '⣾⣽⣻⢿⡿⣟⣯⣷'
9
- }
10
-
11
- CFG_FILENAME = '.mnogootex.yml'.freeze
12
-
13
- def initialize
14
- @paths = []
15
- merge! DEFAULT
16
- end
17
-
18
- def load(pathname = Dir.pwd)
19
- scan_cfg Pathname(pathname)
20
- filter_cfg
21
- merge! load_cfg
22
- self
23
- end
24
-
25
- private
26
-
27
- def scan_cfg(pathname)
28
- @paths << pathname.join(CFG_FILENAME)
29
- return if pathname.root?
30
- scan_cfg pathname.parent
31
- end
32
-
33
- def filter_cfg
34
- @paths.
35
- select!(&:readable?).
36
- reject!(&:zero?)
37
- end
38
-
39
- def load_cfg
40
- @paths.
41
- reverse.
42
- map { |pathname| YAML.load_file pathname }.
43
- inject(&:merge!) # TODO: deep merge
44
- end
45
- end
46
- end
data/lib/mnogootex/job.rb DELETED
@@ -1,75 +0,0 @@
1
- require 'digest'
2
- require 'tmpdir'
3
- require 'pathname'
4
-
5
- module Mnogootex
6
- class Job
7
- attr_reader :thread, :stdout_stderr, :log, :ticks, :cls
8
-
9
- def initialize(cls:, target:)
10
- @main_path = File.expand_path target
11
- @main_basename = File.basename @main_path
12
- @main_dirname = File.dirname @main_path
13
- raise "File non esiste." unless File.exist? @main_path
14
-
15
- @cls = cls
16
- @log = []
17
- @ticks = 0
18
-
19
- @id = Digest::MD5.hexdigest(@cls + @main_path)
20
- end
21
-
22
- def success?
23
- @thread.value.exitstatus == 0
24
- end
25
-
26
- def tmp_dirname
27
- @tmp_dirname ||= Pathname(Dir.tmpdir).join("mnogootex-#{@id}")
28
- end
29
-
30
- def setup
31
- FileUtils.cp_r File.join(@main_dirname, '.'), tmp_dirname
32
-
33
- @path = File.join tmp_dirname, @main_basename
34
-
35
- code = File.read @path
36
- replace = code.sub /\\documentclass(\[.*?\])?{.*?}/,
37
- "\\documentclass{#{@cls}}"
38
-
39
- File.open @path, "w" do |file|
40
- file.puts replace
41
- end
42
- end
43
-
44
- def run
45
- _, @stdout_stderr, @thread = Open3.popen2e(
46
- "texfot",
47
- "pdflatex",
48
- # "latexmk",
49
- # "-pdf",
50
- "--shell-escape", # TODO: remove me!
51
- "--interaction=nonstopmode",
52
- @main_basename,
53
- chdir: tmp_dirname
54
- )
55
- end
56
-
57
- def tick_thread
58
- Thread.new do
59
- # 50ms polling cycle
60
- until (line = @stdout_stderr.gets).nil? do
61
- sleep 0.05
62
- @log << line
63
- @ticks += 1
64
- draw_status
65
- break unless @thread.alive?
66
- end
67
- # end of life treatment
68
- lines = @stdout_stderr.read.lines
69
- @log.concat lines
70
- @ticks += lines.length
71
- draw_status
72
- end
73
- end
74
- end
75
- end