sketchucation logo sketchucation
    • Login
    โ„น๏ธ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Issues with Scrambler

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 3 Posters 1.2k Views 3 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.
    • K Offline
      kwalkerman
      last edited by

      Hello,

      I have a plugin where files live in a sub-folder, and are loaded by a file in the main Plugins folder. I'd like to scramble the files in the sub-folder before distributing. However, once I scramble the files, I am getting errors.

      If I use the command 'require', I get errors like this:

      
      require 'test/test2'
      Error; #<LoadError; (eval);1;in `require'; no such file to load -- test/test2>
      (eval);1
      (eval);1
      
      

      If I use the command 'load', I get these errors:

      
      load 'test/test2.rbs'
      Error; #<SyntaxError; (eval);1;in `load'; C;/Program Files (x86)/Google/Google SketchUp 8/Plugins/test/test2.rbs;1; no .<digit> floating literal anymore; put 0 before dot
      RBS1.0
           ^
      C;/Program Files (x86)/Google/Google SketchUp 8/Plugins/test/test2.rbs;1; syntax error, unexpected tINTEGER
      RBS1.0
            ^
      C;/Program Files (x86)/Google/Google SketchUp 8/Plugins/test/test2.rbs;1; Invalid char `\010' in expression>
      (eval);1
      (eval);1
      
      

      the rbs file looked like this when it was a ruby:

      
      
      	UI.messagebox("test2")
      
      
      

      any ideas? I used the scrambler found here: https://developers.google.com/sketchup/docs/utilities

      Thanks.

      --
      Karen

      1 Reply Last reply Reply Quote 0
      • K Offline
        kwalkerman
        last edited by

        Sketchup::require != require ๐Ÿ‘Š

        Thanks Dan.

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

          @kwalkerman said:

          Sketchup::require != require

          Actually to be more precise...
          Sketchup.method(:require) != method(:require)

          true

          If you type method(:require) at the console (it is equiv to calling: method(:require).inspect,) you see:

          #<Method: Object(Kernel)#require>
          The "#require" means it is an instance method.
          The "Object(Kernel)" means it is an object of Object, inherited from the mixin module Kernel.

          The mixin module Kernel is mixed into class Object by the Ruby Core. Since all objects are descendants of Object, the methods in module Kernel are global methods, and are inherited on down the line by all classes and modules.

          If you type *AnyClass*.ancestors you'll see the two top ancestors are always [...,Object,Kernel].

          This is how your custom modules and classes get these methods.. but they are inherited as private methods. Even the Sketchup module when it was first declared, inherited a require method from Kernel via Object.
          But the API team overrode it inside the Sketchup module (to allow it to handle rbs loading,) and then cloned it as a public module method, so we could call it from outside as a library function.

          If you type at the console: Sketchup.method(:require).inspect, you see:

          #<Method: Sketchup.require>
          This shows it is not inherited, and is a singleton (module) method.
          But since we know that a method of the same name 'require', is inherited by all class and module objects, we know it has to have been overridden.
          We can verify with: Sketchup.private_methods(true).include?("require")
          false
          Which means it no longer contains the private method "require" it inherited from Kernel.

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • TomPendergrassT Offline
            TomPendergrass
            last edited by

            This is an old thread, But I'd just like to go on the record that Sketchup 2014 has fixed one of the issues. I have a .rbs that includes the previously mentioned FILE. It runs just fine in 2014, yet it breaks down in 2013, giving me the following error:

            no .<digit> floating literal anymore; put 0 before dot

            good luck fellow coders.

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

              (I added a note to the above post that it has been fixed.)

              I'm not here much anymore.

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

                Karen.. this is a forehead smacker (so get your hand ready.)

                Standard Ruby has no idea what a scrambled rbs file is, or how to decrypt it.

                So the SU development team created a module method that could open, decrypt and then evaluate them.

                You need to use the Sketchup::require() module method.

                There are other issues with scrambling. The Ruby keywords __LINE__ and __FILE__ do not currently work inside scrambled rubies. (Fixed in SketchUp 2014+ using Ruby 2.0 or higher.)

                I'm am glad that you have decided to use your own filespace. It's only smart.
                I posted an example of doing this with scrambled rubies.

                See: [ code ] SketchupExtension and rbs rubies

                ๐Ÿ’ญ

                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