lib/phantomjs/platform.rb in phantomjs-1.9.2.0 vs lib/phantomjs/platform.rb in phantomjs-1.9.2.1
- old
+ new
@@ -7,10 +7,14 @@
def architecture
RbConfig::CONFIG['host_cpu']
end
+ def temp_path
+ ENV['TMPDIR'] || ENV['TEMP'] || '/tmp'
+ end
+
def phantomjs_path
if system_phantomjs_installed?
system_phantomjs_path
else
File.expand_path File.join(Phantomjs.base_dir, platform, 'bin/phantomjs')
@@ -40,11 +44,11 @@
STDERR.puts "Phantomjs does not appear to be installed in #{phantomjs_path}, installing!"
FileUtils.mkdir_p Phantomjs.base_dir
# Purge temporary directory if it is still hanging around from previous installs,
# then re-create it.
- temp_dir = File.join('/tmp', 'phantomjs_install')
+ temp_dir = File.join(temp_path, 'phantomjs_install')
FileUtils.rm_rf temp_dir
FileUtils.mkdir_p temp_dir
Dir.chdir temp_dir do
unless system "curl -O #{package_url}" or system "wget #{package_url}"
@@ -125,9 +129,33 @@
'darwin'
end
def package_url
'http://phantomjs.googlecode.com/files/phantomjs-1.9.2-macosx.zip'
+ end
+ end
+ end
+
+ class Win32 < Platform
+ class << self
+ def useable?
+ host_os.include?('mingw32') and architecture.include?('i686')
+ end
+
+ def platform
+ 'win32'
+ end
+
+ def phantomjs_path
+ if system_phantomjs_installed?
+ system_phantomjs_path
+ else
+ File.expand_path File.join(Phantomjs.base_dir, platform, 'phantomjs.exe')
+ end
+ end
+
+ def package_url
+ 'https://phantomjs.googlecode.com/files/phantomjs-1.9.2-windows.zip'
end
end
end
end
end