macaw-ruby 0.0.18 → 0.0.19

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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/bin/macaw +22 -13
  4. data/lib/macaw/version.rb +1 -1
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f6b3e2f788757673145ade623bb24d5e7d38b21d
4
- data.tar.gz: b1e51aa42b192db8da4cb0c0b0f2801815317fae
3
+ metadata.gz: c924522b0283dc29571bc610015ed14f39a88024
4
+ data.tar.gz: 4350884eaf96add772061ee3b8f7cecec9c6cbc8
5
5
  SHA512:
6
- metadata.gz: ad71d481842a195f1ab73e57f888696e5d745cf1d93939a40f914d46e11d42ab4b2a72a2b8daecfa9c000d1a7580d0bec9315b4a4c73f37c2f4b9e4196458779
7
- data.tar.gz: 77d4bcb565cfb7626c21f665bcb46b547eee19d81650b761c45d5d74147accd29bc159e99d0495d2e61808ddae4d0e6db1726622e1bd4593c85f47aa02da6029
6
+ metadata.gz: 6a37bdfbaecbe3bf47e4d0f3af81c00de84dd742dd121168908dfa1fd349c4eec3e082361fbbca97f8e97cb80d8e70108b93c9ab8b45178347db4d805e0028ec
7
+ data.tar.gz: 422d2e6cca6dee464f04d2978e64c1fe15b14eb11e7e6b1713a9343f55cb9b9f63c6bc2fbf7eb1b57780b5842427d2984057f0418f27c3ff788682643947cd40
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- macaw-ruby (0.0.18)
4
+ macaw-ruby (0.0.19)
5
5
  i18n
6
6
  json_pure
7
7
  os
data/bin/macaw CHANGED
@@ -11,9 +11,11 @@ require 'shellwords'
11
11
  require 'optparse'
12
12
  require 'timeout'
13
13
  require 'i18n'
14
+ require 'open3'
14
15
 
15
16
  def error(msg)
16
- puts msg
17
+ puts "\n\n#{msg}"
18
+ Macaw.log.close if Macaw.log
17
19
  exit 1
18
20
  end
19
21
 
@@ -160,7 +162,7 @@ class Macaw
160
162
 
161
163
  Macaw.load_rules
162
164
  macaw = Macaw.new(tex)
163
- @@log = File.open(@base + '.log') if @@options[:log]
165
+ @@log = File.open(macaw.base + '.log', 'w') if @@options[:log]
164
166
 
165
167
  IO.readlines(tex).each{|line|
166
168
  next unless line =~ /^% arara: /
@@ -198,25 +200,32 @@ class Macaw
198
200
  }
199
201
  end
200
202
 
203
+ def self.log
204
+ @@log
205
+ end
206
+
201
207
  def self.system(cmd)
202
208
  cmd = cmd.compact.join(' ') if cmd.is_a?(Array)
203
209
  puts cmd
204
210
 
205
211
  output = ''
206
212
  begin
207
- if @@options[:timeout]
208
- Timeout::timeout(@@options[:timeout]) { output = `#{cmd}` }
209
- else
210
- output = `#{cmd}`
211
- end
213
+ Timeout::timeout(@@options[:timeout] || 0) {
214
+ Open3.popen2e(cmd) do |stdin, stdout_err, wait_thr|
215
+ while line = stdout_err.gets
216
+ puts line if @@options[:verbose]
217
+ @@log.write(line) if @@log
218
+ output += line + "\n"
219
+ end
220
+
221
+ exit_status = wait_thr.value
222
+ error "cmd failed: #{cmd}" unless exit_status.success?
223
+ end
224
+ }
212
225
  rescue Timeout::Error
213
- throw "#{cmd}: timed out after #{@@options[:timeout]} seconds"
226
+ error "#{cmd}: timed out after #{@@options[:timeout]} seconds"
214
227
  end
215
-
216
- @@log.write(output) if @@log
217
- print output if @@options[:verbose]
218
- return output if $?.to_i == 0
219
- throw "#{cmd}: #{$?}"
228
+ return output
220
229
  end
221
230
 
222
231
  def self.load_rules
data/lib/macaw/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Macaw
2
- VERSION = "0.0.18"
2
+ VERSION = "0.0.19"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: macaw-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.18
4
+ version: 0.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emiliano Heyns