sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Yosemite filter code...

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 2 Posters 322 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D Offline
      driven
      last edited by driven

      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...

      learn from the mistakes of others, you may not live long enough to make them all yourself...

      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        For Windows:
        v = %x[ver].split.last.to_f

        5.1 = XP
        6.0 = Vista
        6.1 = Win7
        6.2 = Win8

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • D Offline
          driven
          last edited by

          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
          

          Link Preview Image
          Use ditto to Copy Files & Directories Intelligently from the Mac Terminal

          Use ditto to Copy Files & Directories Intelligently from the Mac Terminal

          favicon

          OS X Daily (osxdaily.com)

          learn from the mistakes of others, you may not live long enough to make them all yourself...

          1 Reply Last reply Reply Quote 0
          • D Offline
            driven
            last edited by

            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?

            learn from the mistakes of others, you may not live long enough to make them all yourself...

            1 Reply Last reply Reply Quote 0
            • Dan RathbunD Offline
              Dan Rathbun
              last edited by

              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_r

              
              require("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 page

              EDIT: The snippets above should really be wrapped in begin .. rescue blocks since they do File IO. Notify user of progress, errors, etc.

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • Dan RathbunD Offline
                Dan Rathbun
                last edited by

                @driven said:

                can I PM you it, to have a look?

                Sure, John.

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                Buy SketchPlus
                Buy SUbD
                Buy WrapR
                Buy eBook
                Buy Modelur
                Buy Vertex Tools
                Buy SketchCuisine
                Buy FormFonts

                Advertisement