Initial commit

This commit is contained in:
Senad Uka
2020-05-31 22:38:19 +02:00
commit 858fafc3c5
1280 changed files with 65918 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
module PdfReaderControllerHelper
def content_type
response.headers["Content-Type"]
end
def content_disposition
response.headers["Content-Disposition"]
end
def pdf_filename
content_disposition.scan(/filename="(.*)"/).last.first
end
def pdf_body
temp_pdf = Tempfile.new('pdf')
temp_pdf << response.body.force_encoding('UTF-8')
reader = PDF::Reader.new(temp_pdf)
reader.pages.map(&:text).join(" ").squish
end
end
module PdfReaderFeatureHelper
def content_type
response_headers["Content-Type"]
end
def content_disposition
response_headers["Content-Disposition"]
end
def pdf_filename
content_disposition.scan(/filename="(.*)"/).last.first
end
def pdf_body
temp_pdf = Tempfile.new('pdf')
temp_pdf << page.source.force_encoding('UTF-8')
reader = PDF::Reader.new(temp_pdf)
reader.pages.map(&:text).join(" ").squish
end
end
RSpec.configure do |config|
config.include PdfReaderControllerHelper, type: :controller
config.include PdfReaderFeatureHelper, type: :feature
end