Extension rbz maker
-
are you still using
path_to_components = File.join(File.dirname(__FILE__), 'Components')
I'm unsure if that works from inside a rbs, I remember there was some problem with it...
-
Yes ! So how can I do otherwise ?
-
@tntdavid said:
Yes ! So how can I do otherwise ? :shock:
It's hard without knowing your folder structure...
once installed from rbz
you should have a plain 'extension' .rb file and a same name folder...
inside the folder you should have a plain .rb 'loader' file
that loads the .rbs file
plus any other folders...is that how it is set up?
post a screen shot of the folder structure...john
-
ClickChange
--------ClickChange_logic.rb
--------Components
----------------01-DOOR.skp
----------------02-WINDOWS.skp
----------------03-GRIPS.skp
----------------04-TAPS.skp
----------------05-ELECTRICAL HOBS.skp
----------------06-GAS HOBS.skp
----------------07-EXTRACTOR.skp
----------------08-WALL PANEL.skp
----------------09-FRUITS.skp
----------------10-FLOWERS.skp
--------Resources
----------------add_01.png
----------------add_02.png
----------------add_03.png
----------------add_04.png
----------------add_05.png
----------------add_06.png
----------------add_07.png
----------------add_08.png
----------------add_09.png
----------------add_10.png
----------------add_11.pngClickChange.rb
-
@tntdavid said:
ClickChange > --------ClickChange_logic.rb > ....etc
is this now the rbs that's failing?
if so you need another .rbClickChange --------ClickChange_loader.rb --------ClickChange_logic.rbs ....etc
the minimum ClickChange_loader.rb needs to do is
require('ClickChange_logic')
, but it may be a little more involved than that...I never encrypt any files, so this is from remembering other threads...
john
-
(1) You need to use author namespace and file/folder prefix.
[Assuming the Ruby namespaceTNT
has not been used by anyone else...]
ie (in "Plugins" folder): [pre:2sn8ckc3]TNT_ClickChange.rb
TNT_ClickChange/ClickChange_loader.rb
TNT_ClickChange/ClickChange_logic.rbs
TNT_ClickChange/Components
TNT_ClickChange/Resources[/pre:2sn8ckc3](2) Then the
%(#400080)[Plugins/TNT_ClickChange.rb]
file:<span class="syntaxdefault"></span><span class="syntaxcomment"># encoding; UTF-8<br /></span><span class="syntaxkeyword">require(</span><span class="syntaxstring">"extensions"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">module TNT<br /> module ClickChange<br /><br /> VERSION </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">"1.0.0"<br /><br /></span><span class="syntaxdefault"> </span><span class="syntaxkeyword">@@</span><span class="syntaxdefault">extension </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> SketchupExtension</span><span class="syntaxkeyword">;;new(<br /></span><span class="syntaxdefault"> </span><span class="syntaxstring">"ClickChange"</span><span class="syntaxkeyword">,<br /></span><span class="syntaxdefault"> </span><span class="syntaxstring">"TNT_ClickChange/ClickChange_loader.rb"<br /></span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)<br /><br /></span><span class="syntaxdefault"> </span><span class="syntaxkeyword">@@</span><span class="syntaxdefault">extension</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">description </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">"ClickChange is a great plugin for ..."<br /></span><span class="syntaxdefault"> </span><span class="syntaxkeyword">@@</span><span class="syntaxdefault">extension</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">version </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> VERSION<br /> </span><span class="syntaxkeyword">@@</span><span class="syntaxdefault">extension</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">creator </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">"TNT David"<br /></span><span class="syntaxdefault"> </span><span class="syntaxkeyword">@@</span><span class="syntaxdefault">extension</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">copyright </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">"©2014 by www.composant-dynamique.com"<br /><br /></span><span class="syntaxdefault"> def self</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">extension</span><span class="syntaxkeyword">()<br /></span><span class="syntaxdefault"> </span><span class="syntaxkeyword">@@</span><span class="syntaxdefault">extension<br /> end<br /><br /> Sketchup</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">register_extension</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">@@</span><span class="syntaxdefault">extension</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> true </span><span class="syntaxkeyword">)<br /><br /></span><span class="syntaxdefault"> end<br />end<br /></span>
(3) Then the
%(#400080)[TNT_ClickChange/ClickChange_loader.rb]
file:<span class="syntaxdefault"></span><span class="syntaxcomment"># encoding; UTF-8<br /></span><span class="syntaxdefault">module TNT<br /> module ClickChange<br /><br /> DIR_ABS </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">dirname</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">__File__</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> DIR_REL </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> DIR_ABS</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">split</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'/'</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">last<br /><br /> Sketchup</span><span class="syntaxkeyword">;;require(</span><span class="syntaxstring">"ClickChange_logic.rbs"</span><span class="syntaxkeyword">)<br /><br /></span><span class="syntaxdefault"> end<br />end<br /></span>
(4) Your
%(#400080)[TNT_ClickChange/ClickChange_logic.rbs]
file needs to be defined inside the nestedTNT::ClickChange
namespace, and use the local constantsDIR_ABS
andDIR_REL
. -
OK, my latest updates to the RubyZip methods:
Note that if these are within a RBS scrambled file, and used in SketchUp version < 2014, then the generating of a path from inside
use_piggyback_lib()
will not work. A absolute path must be generated outside the RBS in an unscrambled script, and assigned to a constant, as in the above example.
Also, any statements using theEncoding
class, are for Ruby 2.0+ versions of SketchUp.FYI, My plugin will not support those old versions, by choice. So I generate the path internally.
And RubyZip also has dependencies from the Standard Ruby Lib, so I'm not so sure it'd work on most user's systems, unless they install my standard Lib extension.
Lastly, I myself use an internal boolean@@debug
module variable, instead of$VERBOSE
to decide whether to print exception backtraces.<span class="syntaxdefault"></span><span class="syntaxcomment"># encoding; UTF-8<br /><br /></span><span class="syntaxdefault"> PLUGIN_NAME </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxstring">"TNT_ClickChange"</span><span class="syntaxdefault"> </span><span class="syntaxcomment"># or some other plugin name<br /><br /></span><span class="syntaxdefault"> </span><span class="syntaxkeyword">@@</span><span class="syntaxdefault">piggyback_lib </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> false<br /><br /> </span><span class="syntaxcomment">#{# RUBYZIP METHODS<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault"> def is_RubyZip_loaded</span><span class="syntaxkeyword">?()<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment"># The first time be sure RubyZip library is loaded<br /></span><span class="syntaxdefault"> if defined</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">Zip</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> load_zip_version</span><span class="syntaxkeyword">()</span><span class="syntaxdefault"> unless defined</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">Zip</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">VERSION</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> return true<br /> end<br /> </span><span class="syntaxcomment"># Load or install the rubyzip gem library;<br /></span><span class="syntaxdefault"> begin<br /> require</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"zip"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment"># If already loaded returns false.<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment"># If the gem is installed, it will be activated, "zip.rb" run, and true is returned.<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment"># The danger here is that anyone could publish a gem named "Zip", with a "zip.rb"<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment"># loader, and that such gem could get installed and activated, instead of RubyZip.<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault"> rescue LoadError </span><span class="syntaxkeyword">=></span><span class="syntaxdefault"> e<br /> </span><span class="syntaxcomment"># Gem;;LoadError is a LoadError subclass<br /></span><span class="syntaxdefault"> if e</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">message </span><span class="syntaxkeyword">=~</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">/(</span><span class="syntaxdefault">cannot load such file </span><span class="syntaxkeyword">\-\-</span><span class="syntaxdefault"> zip</span><span class="syntaxkeyword">)/<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment"># The gem is not installed OR RubyGems did not load<br /></span><span class="syntaxdefault"> if defined</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">Gem</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment"># RubyGems is loaded, the gem needs installing.<br /></span><span class="syntaxdefault"> begin<br /> Gem</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">install</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"rubyzip"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> rescue Gem</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">InstallError</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> Gem</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">LoadError </span><span class="syntaxkeyword">=></span><span class="syntaxdefault"> e<br /> puts</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"#{PLUGIN_NAME} Error; #<#{e.class.name}; #{e.message}>"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> puts</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">e</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">backtrace</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> if $VERBOSE<br /> use_piggyback_lib</span><span class="syntaxkeyword">()<br /></span><span class="syntaxdefault"> end<br /> else </span><span class="syntaxcomment"># RubyGems did not load, perhaps unicode install path bug, etc.<br /></span><span class="syntaxdefault"> puts</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"#{PLUGIN_NAME} Error; RubyGems is not loaded."</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> use_piggyback_lib</span><span class="syntaxkeyword">()<br /></span><span class="syntaxdefault"> end<br /> else </span><span class="syntaxcomment"># some other loadError<br /></span><span class="syntaxdefault"> puts</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"#{PLUGIN_NAME} Error; #<LoadError; #{e.message}>"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> use_piggyback_lib</span><span class="syntaxkeyword">()<br /></span><span class="syntaxdefault"> end<br /> rescue </span><span class="syntaxkeyword">=></span><span class="syntaxdefault"> e </span><span class="syntaxcomment"># StandardError & it's subclasses;<br /></span><span class="syntaxdefault"> puts</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"#{PLUGIN_NAME} Error; #<#{e.class.name}; #{e.message}>"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> puts</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">e</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">backtrace</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> if $VERBOSE<br /> use_piggyback_lib</span><span class="syntaxkeyword">()<br /></span><span class="syntaxdefault"> else<br /> load_zip_version</span><span class="syntaxkeyword">()</span><span class="syntaxdefault"> unless defined</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">Zip</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">VERSION</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> ensure<br /> unless defined</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">Zip</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment"># Ensure the load of the Zip library;<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment"># after new gem install or using piggyback library.<br /></span><span class="syntaxdefault"> begin<br /> require</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"zip"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> rescue StandardError</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> LoadError </span><span class="syntaxkeyword">=></span><span class="syntaxdefault"> e<br /> puts</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"#{PLUGIN_NAME} Error; #<#{e.class.name}; #{e.message}>"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> puts</span><span class="syntaxkeyword">(</span><span class="syntaxstring">" (Tried to load piggyback RubyZip library.)"</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> if piggyback_lib</span><span class="syntaxkeyword">?<br /></span><span class="syntaxdefault"> puts</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">e</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">backtrace</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> if $VERBOSE<br /> else<br /> load_zip_version</span><span class="syntaxkeyword">()</span><span class="syntaxdefault"> unless defined</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">Zip</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">VERSION</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> end<br /> </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault"> end<br /> end </span><span class="syntaxcomment"># outer require("zip")<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault"> defined</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">Zip</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">?</span><span class="syntaxdefault"> true </span><span class="syntaxkeyword">;</span><span class="syntaxdefault"> false<br /> </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault"> end </span><span class="syntaxcomment"># is_RubyZip_loaded?()<br /><br /></span><span class="syntaxdefault"> def is_Zip_FileSystem_loaded</span><span class="syntaxkeyword">?()<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault"> unless defined</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">Zip</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> is_RubyZip_loaded</span><span class="syntaxkeyword">?()<br /></span><span class="syntaxdefault"> return false unless defined</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">Zip</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> end<br /> </span><span class="syntaxcomment"># load the FileSystem extension to class Zip;;File<br /></span><span class="syntaxdefault"> begin<br /> require</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"zip/filesystem"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> rescue </span><span class="syntaxkeyword">=></span><span class="syntaxdefault"> e<br /> puts</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"#{PLUGIN_NAME} Error; #<#{e.class.name}; #{e.message}.>"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> return false<br /> else<br /> return true<br /> end<br /> </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault"> end </span><span class="syntaxcomment"># is_Zip_FileSystem_loaded?()<br /><br /></span><span class="syntaxdefault"> def load_zip_version</span><span class="syntaxkeyword">()<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault"> return true if defined</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">Zip</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">VERSION</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment"># otherwise, load the VERSION constant of module Zip;<br /></span><span class="syntaxdefault"> begin<br /> require</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"zip/version"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> rescue StandardError</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> ScriptError</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> LoadError </span><span class="syntaxkeyword">=></span><span class="syntaxdefault"> e<br /> puts</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"#{PLUGIN_NAME} Error; #<#{e.class.name}; #{e.message}.>"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> return false<br /> else<br /> return true<br /> end<br /> </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault"> end </span><span class="syntaxcomment"># load_zip_version()<br /><br /></span><span class="syntaxdefault"> def piggyback_lib</span><span class="syntaxkeyword">?()<br /></span><span class="syntaxdefault"> </span><span class="syntaxkeyword">@@</span><span class="syntaxdefault">piggyback_lib<br /> end<br /><br /> def use_piggyback_lib</span><span class="syntaxkeyword">()<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment"># Push the piggyback RubyZip library directory into $LOAD_PATH;<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault"> unless defined</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">Zip</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">||<br /></span><span class="syntaxdefault"> </span><span class="syntaxkeyword">$;.</span><span class="syntaxdefault">any</span><span class="syntaxkeyword">?{|</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">|</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">exist</span><span class="syntaxkeyword">?(</span><span class="syntaxstring">"#{path}/zip.rb"</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment"># Only happens if the rubyzip gem cannot be installed or loaded.<br /></span><span class="syntaxdefault"> thisfilepath </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> caller</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">0</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">first</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">split</span><span class="syntaxkeyword">(/(\;\</span><span class="syntaxdefault">d</span><span class="syntaxkeyword">+\;</span><span class="syntaxdefault">in</span><span class="syntaxkeyword">|\;\</span><span class="syntaxdefault">d</span><span class="syntaxkeyword">+\</span><span class="syntaxdefault">z</span><span class="syntaxkeyword">|\;</span><span class="syntaxdefault">in </span><span class="syntaxkeyword">`</span><span class="syntaxstring">)/).first #</span><span class="syntaxkeyword">`<br /></span><span class="syntaxdefault"> thisfilepath</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">force_encoding</span><span class="syntaxkeyword">(</span><span class="syntaxstring">'UTF-8'</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> unless thisfilepath</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">encoding </span><span class="syntaxkeyword">!=</span><span class="syntaxdefault"> Encoding</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">UTF_8<br /> $LOAD_PATH </span><span class="syntaxkeyword"><<</span><span class="syntaxdefault"> </span><span class="syntaxstring">"#{thisfilepath}/rubyzip/lib"<br /></span><span class="syntaxdefault"> puts</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"#{PLUGIN_NAME}; (Using \"fallback\" plugin distribution of rubyzip.)"</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> </span><span class="syntaxkeyword">@@</span><span class="syntaxdefault">piggyback_lib </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> true<br /> </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault"> end<br /> </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault"> end </span><span class="syntaxcomment"># use_piggyback_lib()<br /><br /></span><span class="syntaxdefault"> def zip_version</span><span class="syntaxkeyword">()<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault"> if defined</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">Zip</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">VERSION</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault"> Zip</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">VERSION<br /> else </span><span class="syntaxcomment"># load the VERSION constant of module Zip<br /></span><span class="syntaxdefault"> load_zip_version</span><span class="syntaxkeyword">()</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">?</span><span class="syntaxdefault"> Zip</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">VERSION </span><span class="syntaxkeyword">;</span><span class="syntaxdefault"> false<br /> end<br /> </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault"> end </span><span class="syntaxcomment"># zip_version()<br /><br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment">#}#<br /> </span><span class="syntaxdefault"></span>
-
@inteloide said:
May I have your help on :
- the installation of gem rubyzip, to make it easier for user
This is what I am doing in one of my plugins. (Of course, my
PLUGIN_NAME
constant has a different string name.)I have a "fallback" version of rubyzip, with a "rubyzip" sub-directory of the plugin sub-directory.
It only gets used if the latest version cannot be installed from rubygems.org.
The "fallback" rubyzip's path is pushed into the$LOAD_PATH
array by the methoduse_piggyback_lib()
.EDIT3: New version of code example: Same topic: Later post, on page 2
EDIT: Made a few small code edits.
-
@driven said:
(4) Your TNT_ClickChange/ClickChange_logic.rbs file needs to be defined inside the nested TNT::ClickChange namespace, and use the local constants DIR_ABS and DIR_REL.
Should be written like this ?
TNT;;ClickChange "C;\Dossier David\TNT_ClickChange" DIR_ABS and DIR_REL
Thank you
-
@tntdavid said:
@driven said:
(4) Your TNT_ClickChange/ClickChange_logic.rbs file needs to be defined inside the nested TNT::ClickChange namespace, and use the local constants DIR_ABS and DIR_REL.
Should be written like this ?
TNT;;ClickChange "C;\Dossier David\TNT_ClickChange" DIR_ABS and DIR_REL
NO.
"ClickChange_logic.rb" should be written like this:
<span class="syntaxdefault"></span><span class="syntaxcomment"># encoding; UTF-8<br /></span><span class="syntaxdefault">module TNT<br /> module ClickChange<br /><br /> </span><span class="syntaxcomment"># The local constants DIR_ABS and DIR_REL are accessible here,<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment"># if this file is required (loaded by) "ClickChange_loader.rb"<br /><br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment"># The code of "ClickChange_logic.rbs" goes here because this<br /></span><span class="syntaxdefault"> </span><span class="syntaxcomment"># file ACTUALLY IS "ClickChange_logic.rb" before scrambling.<br /><br /></span><span class="syntaxdefault"> end<br />end</span>
@tntdavid said:
"C;\Dossier David\TNT_ClickChange"
Lately, I do not know why anyone would ever put some data directory in the
%(#8000BF)[%SystemDrive%]
Root directory.
That is asking for trouble. And the Microsoft (and third party,) data & profile migration tools, will not look there for folders to copy to the migration archive.User data belongs in the user profile folder hierarchy,... ie:
%(#8000BF)[%USERPROFILE%]
and if they are considered documents (which plugins actually are,) then they belong beneath the "Documents" folder.Any migration assistant or backup tool will always select the "Documents" folder hierarchy for copying.
-
@tntdavid said:
Yes ! So how can I do otherwise ?
In the root RB file, define a constant to FILE and use that constant in your RBS files.
Here is an example:
<span class="syntaxdefault"><br /></span><span class="syntaxkeyword">require </span><span class="syntaxstring">"sketchup.rb"<br /></span><span class="syntaxkeyword">require </span><span class="syntaxstring">"extensions.rb"<br /><br /></span><span class="syntaxdefault">module Example<br /><br /> PATH_ROOT </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">dirname</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">__FILE__</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">freeze<br /> PATH </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">PATH_ROOT</span><span class="syntaxkeyword">, </span><span class="syntaxstring">"sub-folder-name"</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">freeze<br /><br /> unless file_loaded</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">__FILE__</span><span class="syntaxkeyword">)<br /> </span><span class="syntaxdefault">loader </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">PATH</span><span class="syntaxkeyword">, </span><span class="syntaxstring">"core.rb"</span><span class="syntaxkeyword">)<br /> </span><span class="syntaxdefault">ex </span><span class="syntaxkeyword">= </span><span class="syntaxdefault">SketchupExtension</span><span class="syntaxkeyword">.new(</span><span class="syntaxstring">"My Super Extension"</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">loader</span><span class="syntaxkeyword">)<br /> </span><span class="syntaxdefault">Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">register_extension</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">ex</span><span class="syntaxkeyword">, </span><span class="syntaxdefault">true</span><span class="syntaxkeyword">)<br /> </span><span class="syntaxdefault">end<br /><br />end </span><span class="syntaxcomment"># Example<br /><br /></span><span class="syntaxdefault">file_loaded</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">__FILE__</span><span class="syntaxkeyword">)<br /> </span><span class="syntaxdefault"></span>
-
Thomas, your late to the party.
He was specifically asking about quirks with rbs under SketchUp 8.And I gave examples above
http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=59990%26amp;#p548015 -
A nice feature would be to remove all comments before scrambling rb files.
This way, if someone unscrambles it, the code would be less understandable. -
Problem solved thank you for your help
Advertisement