• Login
sketchucation logo sketchucation
  • Login
๐Ÿค‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Unzipping archive from Ruby (Mac and Windows)

Scheduled Pinned Locked Moved Developers' Forum
55 Posts 11 Posters 9.4k Views 11 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.
  • T Offline
    thomthom
    last edited by 8 Nov 2010, 20:47

    @dan rathbun said:

    What URL do you see if you hover over the SCF Login link.
    (I have autologin set in my SCF cookie so I never go thru the login.)

    HTML forms' submit buttons doesn't display the target URL info. One has to look at the source code.

    Thomas Thomassen โ€” SketchUp Monkey & Coding addict
    List of my plugins and link to the CookieWare fund

    1 Reply Last reply Reply Quote 0
    • D Offline
      Dan Rathbun
      last edited by 8 Nov 2010, 20:49

      @thomthom said:

      One has to look at the source code.

      I know (and I did,) it was a hint. But you cut and pasted the code before I could.

      I'm not here much anymore.

      1 Reply Last reply Reply Quote 0
      • T Offline
        tbd
        last edited by 8 Nov 2010, 21:41

        Fredo6: what do you want to do with SCF download ? maybe we can create a backend that suits your needs better thank going through forum software

        SketchUp Ruby Consultant | Podium 1.x developer
        http://plugins.ro

        1 Reply Last reply Reply Quote 0
        • F Offline
          fredo6
          last edited by 8 Nov 2010, 21:57

          @unknownuser said:

          Fredo6: what do you want to do with SCF download ? maybe we can create a backend that suits your needs better thank going through forum software

          I am investiogating 2 things:

          1) Scan the SCF page where a plugin is.
          That's sorted out with WebDialog and this will allow to check the current version and date of the plugin. This of course requires some strict syntax convention, for instance in the title, so that it is easy and discriminant to parse the info.
          At least, this will tell whether the plugin is up to date or not

          2) Download the file (zip or rb) to the local disk in the right place.
          I assume that with some syntax convention, it will be possible to locate the URL address of the file.
          For this however, this requires that the user is logged in to SCF (as ThomThom judiciously noticed).
          Then, if the file URL is obtained, I can:

          • either invoke the download dialog box via WebDialog
          • or find out another way to download it
            Not sure there is an easy way

          Fred

          1 Reply Last reply Reply Quote 0
          • F Offline
            fredo6
            last edited by 8 Nov 2010, 22:01

            I was WRONG about the Mac unzipping as folder.

            But I found out that there is an embedded unzip command, which can be invoked via the Ruby system call system.
            see main post for details

            I have no clue if this is present on all Macs.

            Fredo

            PS: just taking the opportunity that I have a Mac at hand to make a few tests about this question of plugin installation, as I usually prefer to release scripts for both environments and users.

            1 Reply Last reply Reply Quote 0
            • J Offline
              jeff hammond
              last edited by 8 Nov 2010, 23:42

              @unknownuser said:

              I was WRONG about the Mac unzipping as folder.

              But I found out that there is an embedded unzip command, which can be invoked via the Ruby system call system.
              see main post for details

              I have no clue if this is present on all Macs.

              yeah, osx has it's own compressor/expander called Archive Utility.app (located at HD/System/Library/Core Services) which is on all macs (unless for some odd reason, someone decides to delete it).. osx also comes with ruby.

              i'd assume that if you can get it working on one mac then it will work on all..

              one thing that may cause problems is if the user has changed the default expander to something other than Archive Utility (say Stuffit Expander for instance).. i don't think it would matter but then again, i don't really know.

              dotdotdot

              1 Reply Last reply Reply Quote 0
              • T Offline
                thomthom
                last edited by 9 Nov 2010, 08:04

                @unknownuser said:

                Fredo6: what do you want to do with SCF download ? maybe we can create a backend that suits your needs better thank going through forum software

                I wonder - is there many out there at the moment looking at some download/update management system? I've been sketching down ideas for something like this.
                Maybe we could brainstorm something together instead of working in solitude on this?

                Thomas Thomassen โ€” SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

                1 Reply Last reply Reply Quote 0
                • T Offline
                  tbd
                  last edited by 9 Nov 2010, 10:31

                  @thomthom said:

                  Maybe we could brainstorm something together instead of working in solitude on this?

                  sure. some public read/invite write access mindmap would be nice. do you know something that we can use for the brainstorm part ?

                  SketchUp Ruby Consultant | Podium 1.x developer
                  http://plugins.ro

                  1 Reply Last reply Reply Quote 0
                  • T Offline
                    thomthom
                    last edited by 9 Nov 2010, 11:46

                    No - I've never used such tools. Would be good to find one.
                    All I have at the moment are some text document and yellow stickers-notes.

                    Thomas Thomassen โ€” SketchUp Monkey & Coding addict
                    List of my plugins and link to the CookieWare fund

                    1 Reply Last reply Reply Quote 0
                    • D Offline
                      Dan Rathbun
                      last edited by 9 Nov 2010, 19:43

                      What about anonymous FTP download ?

                      Would the user need to manually specify the save path ?

                      I'm not here much anymore.

                      1 Reply Last reply Reply Quote 0
                      • eneroth3E Offline
                        eneroth3
                        last edited by 3 Dec 2014, 20:36

                        What sort of license applies to unzip.exe? I cannot find it anywhere and I'd like to use it for my next plugin.

                        My website: http://julia-christina-eneroth.se/

                        1 Reply Last reply Reply Quote 0
                        • D Offline
                          driven
                          last edited by 3 Dec 2014, 20:42

                          you can use rubyzip gem...
                          dan did an autoloader outline a couple of posts back...
                          [anchor= goto=http://sketchucation.com/forums/viewtopic.php?f=180&t=59990&start=30#p548017:3q0rxtjb]should be here[/anchor:3q0rxtjb]
                          john

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

                          1 Reply Last reply Reply Quote 0
                          • tt_suT Offline
                            tt_su
                            last edited by 4 Dec 2014, 11:38

                            @eneroth3 said:

                            What sort of license applies to unzip.exe? I cannot find it anywhere and I'd like to use it for my next plugin.

                            Unless you need support for SketchUp older than SU2014 I'd go with the zip gem that john mentions.

                            1 Reply Last reply Reply Quote 0
                            • eneroth3E Offline
                              eneroth3
                              last edited by 4 Dec 2014, 15:22

                              Thanks! The gem rubyzip gem does exactly what I wanted ๐Ÿ˜„ .

                              However I don't know what's the best practice to use a gem. Should I ask the user to install it or should I check if it exists when the plugin loads and otherwise install it? Should I in that case use statusbar texts to tell the user the gem is being installed and that it may take some time?

                              My website: http://julia-christina-eneroth.se/

                              1 Reply Last reply Reply Quote 0
                              • D Offline
                                driven
                                last edited by 4 Dec 2014, 15:52

                                It only instals into Sketchup gems, so if they want your plugin they will need it...

                                If it not already installed:
                                I guess you could ask if they want the download or to use 'your' supplied copy, but you would need to keep 'yours' up to date as other plugins use it already...

                                it's very fast to load, did you try?

                                Definitely mention it in your documentation...

                                john

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

                                1 Reply Last reply Reply Quote 0
                                • TIGT Offline
                                  TIG Moderator
                                  last edited by 4 Dec 2014, 16:14

                                  There are 'built-in' zip and unzip methods in Ruby2 - using 'zlib', with no gems.
                                  See my ZipUp Plugin which uses its own shipped rubies to make things easier [Rubyzip].
                                  https://github.com/rubyzip/rubyzip
                                  Mine also uses some js and system zipping [MAC is easy, but on WIN is convoluted] when it's older SketchUp versions, < Ruby2...
                                  It's in an RBS, but suffice it to say that it uses the additional zip.rb loaded commands to make the Ruby2 'zlib' code much less cumbersome to use...

                                  TIG

                                  1 Reply Last reply Reply Quote 0
                                  • eneroth3E Offline
                                    eneroth3
                                    last edited by 4 Dec 2014, 16:16

                                    It took me 69,12 seconds to install the gem :S . I think I have a quite good Internet connection, at least a decent one, but it might be my dying hard drive.

                                    I still suppose it's better to download the most current version than rely on something I pack with the plugin. If I pack it with my files I suppose it has to be in my own namespace to avoid collisions if another plugin requires a newer version.

                                    Perhaps there should be a web dialog telling the user the gem is being installed so they know Sketchup hasn't just frozen.

                                    My website: http://julia-christina-eneroth.se/

                                    1 Reply Last reply Reply Quote 0
                                    • D Offline
                                      driven
                                      last edited by 4 Dec 2014, 16:30

                                      it really depends on what your zipping/unzipping...
                                      for mac the system zip and unzip are the cleanest and fastest...
                                      I use it on .skm's and .layout's mainly.
                                      for .rbz I use Sketchup.install_from_archive and let SU move the files...

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

                                      1 Reply Last reply Reply Quote 0
                                      • eneroth3E Offline
                                        eneroth3
                                        last edited by 4 Dec 2014, 16:32

                                        TIG: I experimented a little with Zlib before but I couldn't find a way to save multiple files in the same archive which I need for my plugin, it doesn't seem to be supported.

                                        My website: http://julia-christina-eneroth.se/

                                        1 Reply Last reply Reply Quote 0
                                        • TIGT Offline
                                          TIG Moderator
                                          last edited by 4 Dec 2014, 16:36

                                          Mine only loads zlib.so and requires the ruby zip.rb stuff if it's not already been installed.
                                          So if another plugin already installed it it uses that.
                                          You can of course so it entirely in vbs/mac-shell for all versions....
                                          These are all inside begin/rescue/ensure sections...
                                          ` require('zlib') unless defined?(Zlib)

                                          in case it is already loaded, and in case it fails it's in a 'rescue'`

                                          To allow my require('zip') to work I briefly add the path to the plugins own subfolder into $: thus:
                                          ` ...
                                          rubyzip=File.join(DATA, 'Rubyzip')

                                          where DATA is a constant referring to that plugin's subfolder named 'Rubyzip'

                                          $: << rubyzip
                                          ...
                                          require('zip') unless defined?(Zip)

                                          in case not already installed by another plugin...

                                          ...
                                          $:.delete(rubyzip)

                                          to tidy up, ad it's no longer needed...

                                          ...`

                                          The Rubyzip methods allow you to add multiple files into a ZIP file - in fact you can do most ZIP/unZIP things with it in conjunction with zlib...

                                          TIG

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

                                          Advertisement