macaw-ruby 0.0.21 → 0.0.22
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +39 -7
- data/bin/macaw +10 -10
- data/lib/macaw/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acb0b0f4729eaad142f96daf4678d5bf73bd70ea
|
4
|
+
data.tar.gz: 82fcc20619fb567856368d2a109ad7fd4163d47c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c9f95e64d65299aecb840ff8159fdaedf3dadc42aecd55763b3d6c50c97c446d0230a5acc0740dc62fbe126a50a85ec1009ce1c657f982a098623b216d3fab7
|
7
|
+
data.tar.gz: cb756f8a318b3942e94d2e179de1c2e560f909517456be76c06dfb4d1847b52577d5e7644f535c3bb61edc594415316f6d6c6d11fef1e0e97e11f77f7786bf8e
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -13,7 +13,15 @@ To install, make sure you have Ruby 1.9 or later installed, and then (on a comma
|
|
13
13
|
|
14
14
|
In day-to-day use it will (should) behave exactly like arara. It accepts the same command line parameters and reads the
|
15
15
|
same *standard* rules that are bundled with arara; if you use only those, there's no need to change anything in your
|
16
|
-
LaTeX documents.
|
16
|
+
LaTeX documents. Instead of
|
17
|
+
|
18
|
+
arara
|
19
|
+
|
20
|
+
you call
|
21
|
+
|
22
|
+
macaw
|
23
|
+
|
24
|
+
(or macaw.bat if you want to run it from a Windows IDE)
|
17
25
|
|
18
26
|
## Custom rules
|
19
27
|
|
@@ -21,10 +29,15 @@ Macaw doesn't use yaml for its rules; rules are Ruby scripts. Macaw will read yo
|
|
21
29
|
your custom rules; in that location, you can drop files that end in '.rb', which are structured like this:
|
22
30
|
|
23
31
|
class Macaw # this line is mandatory
|
24
|
-
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
32
|
+
|
33
|
+
# define your macaw rule here. The name after 'def' is the name of your rule,
|
34
|
+
# the options between parenthesis are the parameters your rule will accept.
|
35
|
+
# Optional parameters are marked using '=nil'.
|
36
|
+
#
|
37
|
+
# For those of you who know ruby, this looks familiar but behaves oddly;
|
38
|
+
# using anything else than 'nil' will likewise make the parameter optional,
|
39
|
+
# but you will *always* be passed 'nil' if the arara rule in the tex file
|
40
|
+
# did not pass the parameters).
|
28
41
|
def zoterobib(collection, format=nil, port=nil, exportCharset=nil, exportNotes=nil, useJournalAbbreviation=nil)
|
29
42
|
# ||= assigns a value if it wasn't set; set your default values here
|
30
43
|
format ||= 'biblatex'
|
@@ -36,8 +49,9 @@ your custom rules; in that location, you can drop files that end in '.rb', which
|
|
36
49
|
params << "&exportNotes=#{exportNotes}" if exportNotes
|
37
50
|
params << "&useJournalAbbreviation=#{useJournalAbbreviation}" if useJournalAbbreviation
|
38
51
|
|
39
|
-
# the ~ is a Macaw feature -- it will escape the path of the string after it to be
|
40
|
-
# line. It will do the right thing depending on
|
52
|
+
# the ~ is a Macaw feature -- it will escape the path of the string after it to be
|
53
|
+
# safe to be passed on the command line. It will do the right thing depending on
|
54
|
+
# the platform it's being run on.
|
41
55
|
bib = ~"#{@base}.bib"
|
42
56
|
url = ~"http://localhost:#{port}/better-bibtex/collection?#{collection}.#{format}#{params}"
|
43
57
|
|
@@ -45,3 +59,21 @@ your custom rules; in that location, you can drop files that end in '.rb', which
|
|
45
59
|
Macaw.system "curl --connect-timeout 5 -z #{bib} -o #{bib} #{url}"
|
46
60
|
end
|
47
61
|
end
|
62
|
+
|
63
|
+
You are not required to use Macaw.system BTW; arara is mainly focused on running shell programs, but since Macaw rules
|
64
|
+
are ruby scripts, they can do some things natively:
|
65
|
+
|
66
|
+
# Clean rule for arara
|
67
|
+
# author: Paulo Cereda
|
68
|
+
# requires arara 3.0+
|
69
|
+
class Macaw
|
70
|
+
def clean(files)
|
71
|
+
files.reject{|f| f.downcase == @file.downcase}.each{|f|
|
72
|
+
Macaw.log "removing #{f}"
|
73
|
+
File.unlink(f)
|
74
|
+
}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
If you don't use Macaw.system, you can use *Macaw.log* to pass output to the logging system (which will be subject to
|
79
|
+
choices the user makes on the command line, or *Macaw.error* to show a fatal error message and halt the build.
|
data/bin/macaw
CHANGED
@@ -13,12 +13,6 @@ require 'timeout'
|
|
13
13
|
require 'i18n'
|
14
14
|
require 'open3'
|
15
15
|
|
16
|
-
def error(msg)
|
17
|
-
puts "\n\n#{msg}"
|
18
|
-
Macaw.log.close if Macaw.log
|
19
|
-
exit 1
|
20
|
-
end
|
21
|
-
|
22
16
|
puts [
|
23
17
|
' __ __ ',
|
24
18
|
'| \/ | __ _ ___ __ ___ __',
|
@@ -148,6 +142,12 @@ class Macaw
|
|
148
142
|
end
|
149
143
|
attr_reader :file, :base
|
150
144
|
|
145
|
+
def self.error(msg)
|
146
|
+
puts "\n\n#{msg}"
|
147
|
+
Macaw.log.close if Macaw.log
|
148
|
+
exit 1
|
149
|
+
end
|
150
|
+
|
151
151
|
def self.options
|
152
152
|
@@options ||= options!
|
153
153
|
end
|
@@ -200,8 +200,9 @@ class Macaw
|
|
200
200
|
}
|
201
201
|
end
|
202
202
|
|
203
|
-
def self.log
|
204
|
-
@@
|
203
|
+
def self.log(line)
|
204
|
+
puts line if @@options[:verbose]
|
205
|
+
@@log.write(line) if @@log
|
205
206
|
end
|
206
207
|
|
207
208
|
def self.system(cmd, failonerror=true)
|
@@ -213,8 +214,7 @@ class Macaw
|
|
213
214
|
Timeout::timeout(@@options[:timeout] || 0) {
|
214
215
|
Open3.popen2e(cmd) do |stdin, stdout_err, wait_thr|
|
215
216
|
while line = stdout_err.gets
|
216
|
-
|
217
|
-
@@log.write(line) if @@log
|
217
|
+
self.log(line)
|
218
218
|
output += line + "\n"
|
219
219
|
end
|
220
220
|
|
data/lib/macaw/version.rb
CHANGED