Yosemite filter code...
-
in case it's of use to anyone else, this is the simplest filter I found...
if %x(sw_vers -productVersion).split('.')[1].to_i > 9 puts 'we have Yosemite, good to go' else UI.messagebox( "This code works only for Yosemite " ) end
EDIT: added a needed split...
-
For Windows:
v = %x[ver].split.last.to_f
5.1 = XP
6.0 = Vista
6.1 = Win7
6.2 = Win8 -
hi dan,
what's the windows cmd for merging two folders?
on the mac I'm using
def ditto(source, target) %x(ditto "#{source}" "#{target}") end
http://osxdaily.com/2014/06/11/use-ditto-copy-files-directories-mac-command-line/
-
cheers dan,
I've got a migration plugin I keep updating on each release, and with Ruby 2 it's became so simple I just wondered if PC's could use it as well...
I only bother with bring the last version forward to the 'approved' folders...
can I PM you it, to have a look?
-
xcopy - but on windows a blank cmd window flashes (annoyingly) up on the screen.
I had nothing but issues trying to use xcopy from Ruby., so I gave up.I prefer to use
WIN32OLE
and Windows Scripting Host's FileSystemObject.CopyFolder()
[MSDN: FileSystemObject.CopyFolder()](http://msdn.microsoft.com/en-us/library/xbfwysex(v)require("win32ole") fso = WIN32OLE.new("Scripting.FileSystemObject") fso.CopyFolder( "#{source}/*", "#{target}" )
.. because for older Ruby 1.8 on Win there is only 1 binary ("win32ole.so") to pack along with your plugin.
Or for Ruby 2.0+ and more Unix-like, cross-platform, use the Ruby Standard library:
Ruby Doc: FileUtils::cp_rrequire("etc") # binary require("FileUtils") # rb FileUtils;;cp_r( "#{source}/.", "#{target}" )
which probably calls something like this on OSX:
out = %x(cp -R -P -p "#{source}/","#{target}/")
Apple Dev: cp man pageEDIT: The snippets above should really be wrapped in
begin
..rescue
blocks since they do File IO. Notify user of progress, errors, etc. -
Advertisement