Skip to content

Commit e8fda58

Browse files
committed
Iterate based on feedback from @jnunemaker
1 parent 13c3f10 commit e8fda58

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

lib/grim/image_magick_processor.rb

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,18 +48,15 @@ def save(pdf, index, path, options)
4848
command_env['PATH'] = "#{File.dirname(@ghostscript_path)}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
4949
end
5050

51-
log(command_env, command)
51+
Grim.logger.debug { "Running imagemagick command" }
52+
if command_env.any?
53+
Grim.logger.debug { command_env.map {|k,v| "#{k}=#{v}" }.join(" ") }
54+
end
55+
Grim.logger.debug { command.join(" ") }
56+
5257
result, status = Open3.capture2e(command_env, command.join(" "))
5358

5459
status.success? || raise(UnprocessablePage, result)
5560
end
56-
57-
def log(command_env, command)
58-
Grim.logger.debug "Running imagemagick command"
59-
if command_env.any?
60-
Grim.logger.debug command_env.map {|k,v| "#{k}=#{v}" }.join(" ")
61-
end
62-
Grim.logger.debug command.join(" ")
63-
end
6461
end
6562
end

lib/grim/null_logger.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
require "logger"
22

33
module Grim
4-
class NullLogger < ::Logger
5-
def initialize(*args)
6-
end
7-
8-
def add(*args, &block)
9-
end
4+
class NullLogger
5+
def initialize(*args); end
6+
def debug(*args); end
7+
def info(*args); end
108
end
119
end

lib/grim/page.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ def save(path, options={})
5151
#
5252
def text
5353
command = [@pdftotext_path, "-enc", "UTF-8", "-f", @number, "-l", @number, Shellwords.escape(@pdf.path), "-"].join(' ')
54-
Grim.logger.debug "Running pdftotext command"
55-
Grim.logger.debug command
54+
Grim.logger.debug { "Running pdftotext command" }
55+
Grim.logger.debug { command }
5656
`#{command}`
5757
end
5858
end

0 commit comments

Comments
 (0)