@@ -13,7 +13,7 @@ require 'open3' # ruby standard library class to handle stderr and stdout
13
13
require 'optparse' # ruby standard option parser
14
14
require 'fileutils' # ruby standard library to deal with files
15
15
require 'shellwords' # escapes strings to run in the shell
16
- # require 'debug/open_nonstop'
16
+ require 'debug/open_nonstop' # debugger, use binding.break to stop
17
17
18
18
##
19
19
# main scrivomatic class
@@ -48,6 +48,11 @@ class Scrivomatic
48
48
postBuild # run latexmk if we are building
49
49
end
50
50
51
+ #--------------------------------checks if a file is less than 3 minutes old
52
+ def isRecent ( infile )
53
+ File . exist? ( infile ) && ( Time . now - File . mtime ( infile ) ) <= 180
54
+ end
55
+
51
56
#--------------------------------if we will run latexmk, remove old tex file before running pandoc
52
57
def preBuild
53
58
return unless options . build && !( options . dry_run )
@@ -120,7 +125,6 @@ class Scrivomatic
120
125
121
126
#-------------------------------run the command
122
127
def runCommand
123
- `open scrivomatic.log` if @options [ :open_log ] && File . exist? ( 'scrivomatic.log' )
124
128
puts '===------ COMMAND OUTPUT: ------===' if @options [ :verbose ] == true
125
129
if File . exist? ( @toolPath ) && !options . dry_run
126
130
puts ":: Running: #{ @cmd } \n " if @options [ :verbose ] == true
@@ -136,6 +140,8 @@ class Scrivomatic
136
140
puts "\n !!!---scrivomatic::runCommand() RETURN non-zero value: #{ cmd } !!!"
137
141
end
138
142
end
143
+ `open scrivomatic.log` if @options [ :open_log ] && isRecent ( 'scrivomatic.log' )
144
+ `open pandocomatic.log` if @options [ :open_log ] && isRecent ( 'pandocomatic.log' )
139
145
elsif !options . dry_run
140
146
puts "Tool doesn't exist!!!" if @options [ :verbose ] == true
141
147
puts "\n !!!---scrivomatic::runCommand() Couldn't find #{ @toolPath } to run, please supply a proper path!"
@@ -225,7 +231,7 @@ class Scrivomatic
225
231
texPath = options . input . gsub ( /#{ @fileext } $/ , '.tex' )
226
232
texFile = texPath . gsub ( /\\ +/ , '' )
227
233
pdfFile = texPath . gsub ( /\. tex/ , '.pdf' )
228
- if File . exist? ( texFile )
234
+ if isRecent ( texFile )
229
235
if File . exist? ( pdfFile )
230
236
puts "\n ===------ Remove old #{ pdfFile } ------===" if @options [ :verbose ] == true
231
237
File . delete ( pdfFile )
@@ -261,7 +267,8 @@ class Scrivomatic
261
267
end
262
268
end
263
269
end #--------------- end Scrivomatic class
264
- #binding.break
270
+
271
+ binding . break
265
272
scriv = Scrivomatic . new
266
273
scriv . parseInputs ( ARGV )
267
274
scriv . run
0 commit comments