Skip to content

Instantly share code, notes, and snippets.

@bmatsuo
Created September 8, 2011 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmatsuo/1205104 to your computer and use it in GitHub Desktop.
Save bmatsuo/1205104 to your computer and use it in GitHub Desktop.
Windows capable PopenRunner subclass for the handbrake ruby gem.
require "rubygems"
require "handbrake"
require 'rbconfig'
$on_mswin = Config::CONFIG['target_os'].match(/^mingw/)
require 'win32/open3' if $on_mswin
class MyRunner < HandBrake::CLI::PopenRunner
def command(args)
return super if !$on_mswin
"\"#{args.unshift(@cli.bin_path).collect { |a| a.gsub(%r(")) { %('""') } }.join('" "')}\""
end
end
hb_path = "HandBrakeCLI.exe"
raise Exception, "No HandBrakeCLI executable" if !File.exists?(hb_path)
hb = HandBrake::CLI.new(
:bin_path => hb_path,
:runner => lambda { |cli| MyRunner.new(cli) },
:trace => false
)
puts "HandBrakeCLI is #{hb.update ? "not " : ""}up to date."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment