macaw-ruby 0.0.22 → 0.0.23
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 +4 -5
- data/bin/macaw +20 -7
- 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: 641515431f8af01e69b01e2071dc82b3fd734e57
|
4
|
+
data.tar.gz: a5244b87b62d510c1a6bcff5929095d4f6110db0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ffd958af42839c0a4de5d325a22e6aa895db2d2edc412bf6db241ae4d933136665630278f0382ccd01992c4b2c5244039a25c9ca3aa952ec280e7df628708b2
|
7
|
+
data.tar.gz: 7a874af507f5f6cb52e3172749574411821ce06a23cb77954672ae8269a45293417996db9b0d5d1de7187f31f41d0eed0697bf9217767830b7beb909856c5cdb
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -11,8 +11,8 @@ To install, make sure you have Ruby 1.9 or later installed, and then (on a comma
|
|
11
11
|
|
12
12
|
## Usage
|
13
13
|
|
14
|
-
In day-to-day use it will (should) behave exactly like
|
15
|
-
same *standard* rules that are bundled with
|
14
|
+
In day-to-day use it will (should) behave exactly like Arara. It accepts the same command line parameters and reads the
|
15
|
+
same *standard* rules that are bundled with Arara; if you use only those, there's no need to change anything in your
|
16
16
|
LaTeX documents. Instead of
|
17
17
|
|
18
18
|
arara
|
@@ -29,14 +29,13 @@ Macaw doesn't use yaml for its rules; rules are Ruby scripts. Macaw will read yo
|
|
29
29
|
your custom rules; in that location, you can drop files that end in '.rb', which are structured like this:
|
30
30
|
|
31
31
|
class Macaw # this line is mandatory
|
32
|
-
|
33
32
|
# define your macaw rule here. The name after 'def' is the name of your rule,
|
34
33
|
# the options between parenthesis are the parameters your rule will accept.
|
35
34
|
# Optional parameters are marked using '=nil'.
|
36
35
|
#
|
37
36
|
# For those of you who know ruby, this looks familiar but behaves oddly;
|
38
37
|
# using anything else than 'nil' will likewise make the parameter optional,
|
39
|
-
# but you will *always* be passed 'nil' if the
|
38
|
+
# but you will *always* be passed 'nil' if the Arara rule in the tex file
|
40
39
|
# did not pass the parameters).
|
41
40
|
def zoterobib(collection, format=nil, port=nil, exportCharset=nil, exportNotes=nil, useJournalAbbreviation=nil)
|
42
41
|
# ||= assigns a value if it wasn't set; set your default values here
|
@@ -60,7 +59,7 @@ your custom rules; in that location, you can drop files that end in '.rb', which
|
|
60
59
|
end
|
61
60
|
end
|
62
61
|
|
63
|
-
You are not required to use Macaw.system BTW;
|
62
|
+
You are not required to use Macaw.system BTW; Arara is mainly focused on running shell programs, but since Macaw rules
|
64
63
|
are ruby scripts, they can do some things natively:
|
65
64
|
|
66
65
|
# Clean rule for arara
|
data/bin/macaw
CHANGED
@@ -134,18 +134,29 @@ class JSON::Pure::Parser
|
|
134
134
|
end
|
135
135
|
|
136
136
|
class Macaw
|
137
|
+
class CommandlineError < StandardError; end
|
138
|
+
|
137
139
|
@@log = nil
|
138
140
|
|
139
141
|
def initialize(tex)
|
140
142
|
@file = tex
|
141
|
-
@base = File.basename(@file, File.extname(@file))
|
143
|
+
@base = File.join(File.dirname(@file), File.basename(@file, File.extname(@file)))
|
142
144
|
end
|
143
145
|
attr_reader :file, :base
|
144
146
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
147
|
+
ERRORMODES=%i{exit throw ignore}
|
148
|
+
def self.error(msg, onfail=:exit)
|
149
|
+
throw "errormode can only be #{ERRORMODES.inspect}" unless ERRORMODES.include?(onfail)
|
150
|
+
case onfail
|
151
|
+
when :exit
|
152
|
+
@@log.close if @@log
|
153
|
+
puts "\n\n#{msg}"
|
154
|
+
exit 1
|
155
|
+
when :throw
|
156
|
+
throw msg
|
157
|
+
else
|
158
|
+
puts msg
|
159
|
+
end
|
149
160
|
end
|
150
161
|
|
151
162
|
def self.options
|
@@ -205,7 +216,9 @@ class Macaw
|
|
205
216
|
@@log.write(line) if @@log
|
206
217
|
end
|
207
218
|
|
208
|
-
def self.system(cmd,
|
219
|
+
def self.system(cmd, onfail=:exit)
|
220
|
+
throw "errormode can only be #{ERRORMODES.inspect}" unless ERRORMODES.include?(onfail)
|
221
|
+
|
209
222
|
cmd = cmd.compact.join(' ') if cmd.is_a?(Array)
|
210
223
|
puts cmd
|
211
224
|
|
@@ -219,7 +232,7 @@ class Macaw
|
|
219
232
|
end
|
220
233
|
|
221
234
|
exit_status = wait_thr.value
|
222
|
-
error "cmd failed: #{cmd}" unless exit_status.success?
|
235
|
+
error "cmd failed: #{cmd}", onfail unless exit_status.success?
|
223
236
|
end
|
224
237
|
}
|
225
238
|
rescue Timeout::Error
|
data/lib/macaw/version.rb
CHANGED