Skip to content

Commit e6bf3a8

Browse files
author
Phil Gooch
committed
Changes in response to code review
1 parent 3280c6d commit e6bf3a8

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/grim/page.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,15 @@ def save(path, options={})
4747
# pdf[1].text
4848
# # => "This is text from slide 2.\n\nAnd even more text from slide 2."
4949
#
50-
# pdf[1].text(options={flags: ["-table"]})
50+
# pdf[1].text({flags: ["-table"]})
5151
# Returns a String.
5252
#
53-
def text(options={flags: []})
54-
command = [@pdftotext_path, "-enc", "UTF-8", "-f", @number, "-l", @number, options[:flags].join(", "), Shellwords.escape(@pdf.path), "-"].join(' ')
53+
def text(options={})
54+
flags = options.fetch(:flags, [])
55+
command_parts = [@pdftotext_path, "-enc", "UTF-8", "-f", @number, "-l", @number]
56+
command_parts += flags if flags.length > 0
57+
command_parts += [Shellwords.escape(@pdf.path), "-"]
58+
command = command_parts.join(' ')
5559
Grim.logger.debug { "Running pdftotext command" }
5660
Grim.logger.debug { command }
5761
`#{command}`

spec/lib/grim/page_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353

5454
it "should extract tabular data with the -table option" do
5555
pdf = Grim::Pdf.new(fixture_path("table.pdf"))
56-
expect(pdf[0].text(options={flags: ["-table"]})).to \
56+
expect(pdf[0].text({flags: ["-table"]})).to \
5757
include(
5858
" Male 979 (85) 968 (85)\n\n" +
5959
" Female 169 (15) 169 (15)\n")

0 commit comments

Comments
 (0)