macaw 0.0.40 → 0.0.41
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/bin/macaw +13 -4
- data/lib/macaw/rules/texcount.rb +33 -2
- data/lib/macaw/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d5a9f79f978035965ae9ed533cbd5148d927684
|
4
|
+
data.tar.gz: 165d7dcd5d67b483d95ad5b086bd7f4b7e31bb02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b24477694fe597e30eafdbf8539d5f72d5af965b3bea11a98c38fd7e1dbdb5e9f27aa7d39cc51aac77992919b8260fbcb5d5a32835f0cc4ed51a4e65db02ed3
|
7
|
+
data.tar.gz: df4e9accab5048946bf08d1685e99cd28717a5beac9f71bc47dc3083cd31a6d2989b8a12ec4889f09fe5c94e5ba3c83f40d92c787d68ead5975a10e47f5840ae
|
data/Gemfile.lock
CHANGED
data/bin/macaw
CHANGED
@@ -275,19 +275,23 @@ class Macaw
|
|
275
275
|
@@log.write(line) if @@log
|
276
276
|
end
|
277
277
|
|
278
|
-
def self.system(cmd,
|
278
|
+
def self.system(cmd, options={})
|
279
|
+
onfail = options.delete(:onfail) || :exit
|
280
|
+
returntype = options.delete(:return) || :string
|
281
|
+
error "Unhandled system option #{options.inspect}" unless options.size == 0
|
282
|
+
|
279
283
|
throw "errormode can only be #{ERRORMODES.inspect}" unless ERRORMODES.include?(onfail)
|
280
284
|
|
281
285
|
cmd = cmd.compact.join(' ') if cmd.is_a?(Array)
|
282
286
|
log(cmd)
|
283
287
|
|
284
|
-
output =
|
288
|
+
output = []
|
285
289
|
begin
|
286
290
|
Timeout::timeout(@@options.timeout || 0) {
|
287
291
|
Open3.popen2e(cmd) do |stdin, stdout_err, wait_thr|
|
288
292
|
while line = stdout_err.gets
|
289
293
|
self.log(line)
|
290
|
-
output
|
294
|
+
output << line
|
291
295
|
end
|
292
296
|
|
293
297
|
exit_status = wait_thr.value
|
@@ -297,7 +301,12 @@ class Macaw
|
|
297
301
|
rescue Timeout::Error
|
298
302
|
error "#{cmd}: timed out after #{@@options.timeout} seconds" if failonerror
|
299
303
|
end
|
300
|
-
|
304
|
+
|
305
|
+
return case returntype
|
306
|
+
when :string then output.join("\n")
|
307
|
+
when :array then output
|
308
|
+
else error "Unexpected return type #{returntype} from system"
|
309
|
+
end
|
301
310
|
end
|
302
311
|
|
303
312
|
def self.load_rules
|
data/lib/macaw/rules/texcount.rb
CHANGED
@@ -1,9 +1,40 @@
|
|
1
|
+
require 'i18n'
|
2
|
+
|
1
3
|
# texcount rule for arara
|
2
4
|
# author: Francesco Endrici
|
3
5
|
# requires arara 3.0
|
4
6
|
class Macaw
|
5
7
|
# this probably needs to be a lot fancier, but I can't be arsed about it right now.
|
6
|
-
def texcount(
|
7
|
-
|
8
|
+
def texcount(includes=nil)
|
9
|
+
|
10
|
+
count = {}
|
11
|
+
Macaw.system(['texcount', ~@file], return: :array).each{|line|
|
12
|
+
Macaw.log(line)
|
13
|
+
|
14
|
+
case line
|
15
|
+
when /^Words in text:\s*([0-9]+)/
|
16
|
+
count[:all] = Integer($1)
|
17
|
+
when /\s([0-9]+)\+[0-9]+\+[0-9]\s+\([0-9]+\/[0-9]+\/[0-9]+\/[0-9]+\)\s+Section:\s*([^}]+)/
|
18
|
+
count[$2.strip] = Integer($1)
|
19
|
+
end
|
20
|
+
}
|
21
|
+
|
22
|
+
cleanfile = lambda{|f|
|
23
|
+
dir = File.dirname(f)
|
24
|
+
file = File.basename(f)
|
25
|
+
|
26
|
+
file = I18n.transliterate(file) # fold diacritics where possible
|
27
|
+
file.gsub!(/[^!-~]/, '') # remove non-ascii characters
|
28
|
+
file.gsub!(/#<\$\+%>!`&\*'\|{\?"=}\/:\\@/, '') # remove problematic characters
|
29
|
+
File.join(dir, file)
|
30
|
+
}
|
31
|
+
|
32
|
+
if includes
|
33
|
+
Dir["#{@base}*.count.txt"].each{|f| File.unlink(f) }
|
34
|
+
count.each_pair{|k, v|
|
35
|
+
f = cleanfile.call(@base + (k == :all ? '' : ".#{k}") + ".count.txt")
|
36
|
+
File.open(f, 'w') {|f| f.write(v)}
|
37
|
+
}
|
38
|
+
end
|
8
39
|
end
|
9
40
|
end
|
data/lib/macaw/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: macaw
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.41
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emiliano Heyns
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|