Skip to content

Commit

Permalink
Changes in response to code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Gooch committed May 6, 2017
1 parent 3280c6d commit e6bf3a8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions lib/grim/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,15 @@ def save(path, options={})
# pdf[1].text
# # => "This is text from slide 2.\n\nAnd even more text from slide 2."
#
# pdf[1].text(options={flags: ["-table"]})
# pdf[1].text({flags: ["-table"]})
# Returns a String.
#
def text(options={flags: []})
command = [@pdftotext_path, "-enc", "UTF-8", "-f", @number, "-l", @number, options[:flags].join(", "), Shellwords.escape(@pdf.path), "-"].join(' ')
def text(options={})
flags = options.fetch(:flags, [])
command_parts = [@pdftotext_path, "-enc", "UTF-8", "-f", @number, "-l", @number]
command_parts += flags if flags.length > 0
command_parts += [Shellwords.escape(@pdf.path), "-"]
command = command_parts.join(' ')
Grim.logger.debug { "Running pdftotext command" }
Grim.logger.debug { command }
`#{command}`
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/grim/page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

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

0 comments on commit e6bf3a8

Please sign in to comment.