mnogootex 0.2.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +3 -0
- data/.rspec +0 -2
- data/.rubocop.yml +12 -0
- data/.travis.yml +20 -3
- data/CODE_OF_CONDUCT.md +1 -1
- data/Gemfile +4 -3
- data/Guardfile +56 -0
- data/README.md +154 -16
- data/Rakefile +25 -4
- data/exe/mnogootex +2 -92
- data/lib/mnogootex/cfg.rb +62 -0
- data/lib/mnogootex/cli.rb +79 -0
- data/lib/mnogootex/core_ext.rb +11 -0
- data/lib/mnogootex/defaults.yml +6 -0
- data/lib/mnogootex/job/logger.rb +53 -0
- data/lib/mnogootex/job/porter.rb +45 -0
- data/lib/mnogootex/job/runner.rb +42 -0
- data/lib/mnogootex/job/warden.rb +99 -0
- data/lib/mnogootex/log/level.rb +17 -0
- data/lib/mnogootex/log/levels.yml +29 -0
- data/lib/mnogootex/log/line.rb +14 -0
- data/lib/mnogootex/log/matcher.rb +17 -0
- data/lib/mnogootex/log/matchers.yml +205 -0
- data/lib/mnogootex/log/processor.rb +115 -0
- data/lib/mnogootex/log.rb +23 -0
- data/lib/mnogootex/mnogoo.sh +21 -0
- data/lib/mnogootex/utils.rb +26 -0
- data/lib/mnogootex/version.rb +3 -1
- data/lib/mnogootex.rb +4 -4
- data/mnogootex.gemspec +41 -18
- data/spec/mnogootex/cfg_spec.rb +54 -0
- data/spec/mnogootex/job/porter_spec.rb +140 -0
- data/spec/mnogootex/job/runner_spec.rb +74 -0
- data/spec/mnogootex/log/processor_spec.rb +203 -0
- data/spec/mnogootex/utils_spec.rb +52 -0
- data/spec/spec_helper.rb +124 -0
- data/tty.gif +0 -0
- metadata +182 -20
- data/.gitmodules +0 -3
- data/bin/console +0 -14
- data/bin/setup +0 -8
- data/lib/mnogootex/configuration.rb +0 -46
- data/lib/mnogootex/job.rb +0 -75
data/spec/spec_helper.rb
ADDED
@@ -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.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paolo Brasolin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -25,7 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.16'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: byebug
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
@@ -38,37 +38,178 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: dry-inflector
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.1.1
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.1.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: guard
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.14'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.14'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: guard-rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '4.7'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '4.7'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: mutant
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.8.14
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.8.14
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: mutant-rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.8.14
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.8.14
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rake
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '10.4'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '10.4'
|
41
125
|
- !ruby/object:Gem::Dependency
|
42
126
|
name: rspec
|
43
127
|
requirement: !ruby/object:Gem::Requirement
|
44
128
|
requirements:
|
45
129
|
- - "~>"
|
46
130
|
- !ruby/object:Gem::Version
|
47
|
-
version: '3.
|
131
|
+
version: '3.6'
|
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.
|
138
|
+
version: '3.6'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rubocop
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 0.52.1
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 0.52.1
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: simplecov
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 0.15.1
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 0.15.1
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: yard
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 0.9.12
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 0.9.12
|
55
181
|
- !ruby/object:Gem::Dependency
|
56
182
|
name: colorize
|
57
183
|
requirement: !ruby/object:Gem::Requirement
|
58
184
|
requirements:
|
59
|
-
- - "
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: 0.8.1
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: 0.8.1
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: thor
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - "~>"
|
60
200
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
201
|
+
version: 0.20.0
|
62
202
|
type: :runtime
|
63
203
|
prerelease: false
|
64
204
|
version_requirements: !ruby/object:Gem::Requirement
|
65
205
|
requirements:
|
66
|
-
- - "
|
206
|
+
- - "~>"
|
67
207
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
69
|
-
description:
|
70
|
-
|
71
|
-
|
208
|
+
version: 0.20.0
|
209
|
+
description: Многоꙮтех (mnogootex) is a utility that parallelizes compilation of a
|
210
|
+
LaTeX document using different classes and offers a meaningfully filtered output.
|
211
|
+
The motivating use case is maintaining a single preamble while submitting a paper
|
212
|
+
to many journals using their outdated or crummy document classes.
|
72
213
|
email:
|
73
214
|
- paolo.brasolin@gmail.com
|
74
215
|
executables:
|
@@ -77,22 +218,43 @@ extensions: []
|
|
77
218
|
extra_rdoc_files: []
|
78
219
|
files:
|
79
220
|
- ".gitignore"
|
80
|
-
- ".gitmodules"
|
81
221
|
- ".rspec"
|
222
|
+
- ".rubocop.yml"
|
82
223
|
- ".travis.yml"
|
83
224
|
- CODE_OF_CONDUCT.md
|
84
225
|
- Gemfile
|
226
|
+
- Guardfile
|
85
227
|
- LICENSE.txt
|
86
228
|
- README.md
|
87
229
|
- Rakefile
|
88
|
-
- bin/console
|
89
|
-
- bin/setup
|
90
230
|
- exe/mnogootex
|
91
231
|
- lib/mnogootex.rb
|
92
|
-
- lib/mnogootex/
|
93
|
-
- lib/mnogootex/
|
232
|
+
- lib/mnogootex/cfg.rb
|
233
|
+
- lib/mnogootex/cli.rb
|
234
|
+
- lib/mnogootex/core_ext.rb
|
235
|
+
- lib/mnogootex/defaults.yml
|
236
|
+
- lib/mnogootex/job/logger.rb
|
237
|
+
- lib/mnogootex/job/porter.rb
|
238
|
+
- lib/mnogootex/job/runner.rb
|
239
|
+
- lib/mnogootex/job/warden.rb
|
240
|
+
- lib/mnogootex/log.rb
|
241
|
+
- lib/mnogootex/log/level.rb
|
242
|
+
- lib/mnogootex/log/levels.yml
|
243
|
+
- lib/mnogootex/log/line.rb
|
244
|
+
- lib/mnogootex/log/matcher.rb
|
245
|
+
- lib/mnogootex/log/matchers.yml
|
246
|
+
- lib/mnogootex/log/processor.rb
|
247
|
+
- lib/mnogootex/mnogoo.sh
|
248
|
+
- lib/mnogootex/utils.rb
|
94
249
|
- lib/mnogootex/version.rb
|
95
250
|
- mnogootex.gemspec
|
251
|
+
- spec/mnogootex/cfg_spec.rb
|
252
|
+
- spec/mnogootex/job/porter_spec.rb
|
253
|
+
- spec/mnogootex/job/runner_spec.rb
|
254
|
+
- spec/mnogootex/log/processor_spec.rb
|
255
|
+
- spec/mnogootex/utils_spec.rb
|
256
|
+
- spec/spec_helper.rb
|
257
|
+
- tty.gif
|
96
258
|
homepage: https://github.com/tetrapharmakon/mnogootex
|
97
259
|
licenses:
|
98
260
|
- MIT
|
@@ -113,9 +275,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
275
|
version: '0'
|
114
276
|
requirements: []
|
115
277
|
rubyforge_project:
|
116
|
-
rubygems_version: 2.6
|
278
|
+
rubygems_version: 2.7.6
|
117
279
|
signing_key:
|
118
280
|
specification_version: 4
|
119
|
-
summary:
|
120
|
-
|
281
|
+
summary: Многоꙮтех (mnogootex) is a utility that parallelizes compilation of a LaTeX
|
282
|
+
document using different classes and offers a meaningfully filtered output.
|
121
283
|
test_files: []
|
data/.gitmodules
DELETED
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,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
|