Module: PaperclipHelpers::TestHelpers

Extended by:
ActiveSupport::Concern
Defined in:
lib/paperclip_helpers/test_helpers.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#count_pages(pdf_file_path) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/paperclip_helpers/test_helpers.rb', line 23

def count_pages(pdf_file_path)
  return nil unless pdf_file_path.last(4) == ".pdf"
  
  output = `identify \"#{pdf_file_path}\"`
  raise "Error counting pages in #{pdf_file_path}" unless $?.exitstatus == 0
  
  output.split("\n").count
end

#get_image_size(image_file_path) ⇒ Object



32
33
34
35
36
37
# File 'lib/paperclip_helpers/test_helpers.rb', line 32

def get_image_size(image_file_path)
  output = `identify \"#{image_file_path}\"`
  raise "Error getting size of #{image_file_path}" unless $?.exitstatus == 0
  
  output.split(" ")[2]
end