Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WickedPdf integration, wkhtmltopdf-path and gemspec update #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 1 addition & 20 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,20 +1 @@
require 'rubygems'
require 'rake/packagetask'
require 'rake/gempackagetask'

spec = Gem::Specification.new do |s|
s.name = "wkhtmltopdf-binary"
s.version = "0.9.9"
s.author = "Research Information Systems, The University of Iowa"
s.email = "[email protected],[email protected]"
s.platform = Gem::Platform::RUBY
s.summary = "Provides binaries for WKHTMLTOPDF project in an easily accessible package."
s.files = FileList["{bin,libexec,lib}/*"].to_a
s.has_rdoc = false
s.executables << "wkhtmltopdf"
s.require_path = '.'
end

Rake::GemPackageTask.new(spec) do |pkg|
pkg.need_tar = true
end
load File.expand_path('../wkhtmltopdf-binary.gemspec', __FILE__)
15 changes: 3 additions & 12 deletions bin/wkhtmltopdf
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
#!/usr/bin/env ruby

arch = case RUBY_PLATFORM
when /64.*linux/
'linux-amd64'
when /linux/
'linux-x86'
when /darwin/
'darwin-x86'
else
raise "Invalid platform. Must be running linux or intel-based Mac OS."
end
NO_WICKEDPDF_PATH = true
require 'wkhtmltopdf-binary'

args = $*.map { |x| x.include?(' ') ? "'" + x + "'" : x }
cmd = File.expand_path "#{File.dirname(__FILE__)}/../libexec/wkhtmltopdf-#{arch}"

exec "#{cmd} #{args.join(' ')}"
exec "#{WkHtmlToPdfBinary.binary_path} #{args.join(' ')}"
6 changes: 6 additions & 0 deletions bin/wkhtmltopdf-path
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env ruby

NO_WICKEDPDF_PATH = true
require 'wkhtmltopdf-binary'

puts WkHtmlToPdfBinary.binary_path
22 changes: 22 additions & 0 deletions lib/wkhtmltopdf-binary.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module WkHtmlToPdfBinary
def self.binary_path
arch = case RUBY_PLATFORM
when /64.*linux/
'linux-amd64'
when /linux/
'linux-x86'
when /darwin/
'darwin-x86'
else
raise NotImplementedError, "Invalid platform. Must be running linux or intel-based Mac OS."
end

File.expand_path("#{File.dirname(__FILE__)}/../libexec/wkhtmltopdf-#{arch}")
end
end

begin
require 'wicked_pdf'
WickedPdf.config[:exe_path] ||= WkHtmlToPdfBinary.binary_path
rescue LoadError, NotImplementedError
end unless Object.const_defined?(:NO_WICKEDPDF_PATCH)
41 changes: 21 additions & 20 deletions wkhtmltopdf-binary.gemspec
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'wkhtmltopdf-binary'
s.version = '0.9.9'
s.summary = 'Provides binaries for WKHTMLTOPDF project in an easily accessible package.'
s.description = ''

s.required_ruby_version = '>= 1.8.7'
s.required_rubygems_version = ">= 1.3.6"
require 'rubygems'
require 'rubygems/package_task'

s.author = '- Research Information Systems, The University of Iowa'
s.homepage = ''
s.email = '[email protected],[email protected]'

s.bindir = 'bin'
s.executables = %w(wkhtmltopdf)
Gem::Specification.new do |s|
s.name = "wkhtmltopdf-binary"
s.version = "0.10"
s.author = "Research Information Systems, The University of Iowa"
s.email = "[email protected],[email protected]"
s.platform = Gem::Platform::RUBY
s.summary = "Provides binaries for WKHTMLTOPDF project in an easily accessible package."
s.description = <<-EOF
Provides binaries and utilities of WKHTMLTOPDF.
Also patches WickedPdf (if installed) to use provided binary
EOF
s.homepage = 'https://github.com/steerio/wkhtmltopdf-binary'
s.files = FileList["{bin,libexec,lib}/*"].to_a
s.has_rdoc = false
s.rdoc_options += ['-x', 'libexec/.*']
s.executables << "wkhtmltopdf" << 'wkhtmltopdf-path'

s.files = %w(
lib/wkhtmltopdf-binary.rb bin/wkhtmltopdf
libexec/wkhtmltopdf-darwin-x86
libexec/wkhtmltopdf-linux-amd64
libexec/wkhtmltopdf-linux-x86)
Gem::PackageTask.new(s) do |pkg|
pkg.need_tar = true
end
end