Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updating to use a bin/wkhtmltoimage-amd64

  • Loading branch information...
commit d8460a0726a077b703fb52e5507a6a218192bfbc 1 parent c178418
@willywos willywos authored
View
26 bin/wkhtml_image_executable.rb
@@ -0,0 +1,26 @@
+class WkhtmlImageExecutable
+ attr_reader :system_platform
+
+ def initialize(args={})
+ @system_platform = args[:system_platform] || default_platform
+ end
+
+ def default_platform
+ RUBY_PLATFORM
+ end
+
+ def binary_wkhtmltoimage
+ case @system_platform
+ when /x86_64-linux/
+ 'wkhtmltoimage-amd64'
+ when /linux/
+ 'wkhtmltoimage-linux-i386-0.10.0'
+ when /darwin/
+ 'wkhtmltoimage-osx-i386-0.10.0'
+ else
+ raise "No bundled binaries found for your system. Please install wkhtmltopdf."
+ end
+ end
+end
+
+
View
BIN  bin/wkhtmltoimage-amd64
Binary file not shown
View
16 bin/wkhtmltoimage-proxy
@@ -1,21 +1,13 @@
#!/usr/bin/env ruby
+require File.expand_path(File.dirname(__FILE__) + '/wkhtml_image_executable')
+
executable = `which wkhtmltoimage`.chomp
if executable.empty?
-
- binary = case RUBY_PLATFORM
- when /linux/
- 'wkhtmltoimage-linux-i386-0.10.0'
- when /darwin/
- 'wkhtmltoimage-osx-i386-0.10.0'
- else
- raise "No bundled binaries found for your system. Please install wkhtmltopdf."
- end
- executable = File.join(File.dirname(__FILE__), binary)
-
+ executable = File.join(File.dirname(__FILE__), WkhtmlImageExecutable.new.binary_wkhtmltoimage)
end
arguments = $*.map { |arg| arg.include?(' ') ? %Q("#{arg}") : arg }
-system(executable + " " + arguments.join(" "))
+system(executable + " " + arguments.join(" "))
View
22 spec/wkhtml_image_executable_spec.rb
@@ -0,0 +1,22 @@
+require 'spec_helper'
+require_relative '../bin/wkhtml_image_executable'
+
+describe WkhtmlImageExecutable do
+
+ it "should return wkhtmltoimage-amd64 when platform contains 64-linux" do
+ WkhtmlImageExecutable.new({system_platform: "x86_64-linux"}).binary_wkhtmltoimage.should eq "wkhtmltoimage-amd64"
+ end
+
+ it "should return wkhtmltoimage-linux-i386-0.10.0 when platform contains linux" do
+ WkhtmlImageExecutable.new({system_platform: "linux"}).binary_wkhtmltoimage.should eq "wkhtmltoimage-linux-i386-0.10.0"
+ end
+
+ it "should return wkhtmltoimage-osx-i386-0.10.0 when platform contains darwin" do
+ WkhtmlImageExecutable.new({system_platform: "darwin"}).binary_wkhtmltoimage.should eq "wkhtmltoimage-osx-i386-0.10.0"
+ end
+
+ it "should raise execption when platform is not found with a matching " do
+ expect {WkhtmlImageExecutable.new({system_platform: "magical_unicorns"}).binary_wkhtmltoimage}.to raise_error
+ end
+end
+
Please sign in to comment.
Something went wrong with that request. Please try again.