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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: acb0b0f4729eaad142f96daf4678d5bf73bd70ea
4
- data.tar.gz: 82fcc20619fb567856368d2a109ad7fd4163d47c
3
+ metadata.gz: 641515431f8af01e69b01e2071dc82b3fd734e57
4
+ data.tar.gz: a5244b87b62d510c1a6bcff5929095d4f6110db0
5
5
  SHA512:
6
- metadata.gz: 1c9f95e64d65299aecb840ff8159fdaedf3dadc42aecd55763b3d6c50c97c446d0230a5acc0740dc62fbe126a50a85ec1009ce1c657f982a098623b216d3fab7
7
- data.tar.gz: cb756f8a318b3942e94d2e179de1c2e560f909517456be76c06dfb4d1847b52577d5e7644f535c3bb61edc594415316f6d6c6d11fef1e0e97e11f77f7786bf8e
6
+ metadata.gz: 8ffd958af42839c0a4de5d325a22e6aa895db2d2edc412bf6db241ae4d933136665630278f0382ccd01992c4b2c5244039a25c9ca3aa952ec280e7df628708b2
7
+ data.tar.gz: 7a874af507f5f6cb52e3172749574411821ce06a23cb77954672ae8269a45293417996db9b0d5d1de7187f31f41d0eed0697bf9217767830b7beb909856c5cdb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- macaw-ruby (0.0.22)
4
+ macaw-ruby (0.0.23)
5
5
  i18n
6
6
  json_pure
7
7
  os
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 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
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 arara rule in the tex file
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; arara is mainly focused on running shell programs, but since Macaw rules
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
- def self.error(msg)
146
- puts "\n\n#{msg}"
147
- Macaw.log.close if Macaw.log
148
- exit 1
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, failonerror=true)
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? && failonerror
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
@@ -1,3 +1,3 @@
1
1
  class Macaw
2
- VERSION = "0.0.22"
2
+ VERSION = "0.0.23"
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.22
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emiliano Heyns