Module: TT::Lib

Defined in:
TT_Lib2/core.rb

Overview

TT_Lib related methods.

Since:

  • 2.0.0

Constant Summary

VERSION =

Library version number.

Since:

  • 2.0.0

PLUGIN_VERSION
PREF_KEY =

Library preference key.

Since:

  • 2.5.0

'TT_Lib2'.freeze
PATH =

Since:

  • 2.0.0

File.dirname( file ).freeze
PATH_LIBS =

Since:

  • 2.0.0

File.join( PATH, 'libraries' ).freeze
PATH_LIBS_CEXT =

Since:

  • 2.0.0

@cext_manager.prepare_path.freeze

Class Method Summary collapse

Class Method Details

.cext_managerObject

TT::Lib.cext_manager

Since:

  • 2.0.0



127
# File 'TT_Lib2/core.rb', line 127

def self.cext_manager; @cext_manager; end

.compatible?(version, plugin_name = 'A plugin installed') ⇒ Boolean

Call this method to check if the installed TT_Lib version is the same or newer than version. If it's not then a messagebox will appear informing the user that a newer TT_Lib is required.

Parameters:

  • version (String)

    a string with the minimun version required in the format 'x.x.x'.

  • plugin_name (String) (defaults to: 'A plugin installed')

    a string describing to the user which plugin require a newer TT_Lib version.

Returns:

  • (Boolean)

Since:

  • 2.0.0



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'TT_Lib2/core.rb', line 142

def self.compatible?(version, plugin_name = 'A plugin installed')
  major, minor, revision  = TT::Lib::VERSION.split('.').map { |s| s.to_i }
  min_major, min_minor, min_revision = version.split('.').map { |s| s.to_i }
  return true if major > min_major
  return true if major == min_major && minor > min_minor
  return true if major == min_major && minor == min_minor && revision >= min_revision
  #UI.messagebox("#{plugin_name} requires a newer version, #{version}, of TT_Lib.")
  if TT.lib2_update.nil?
    url = 'http://www.thomthom.net/software/sketchup/tt_lib2/errors/outdated'
    options = {
      :dialog_title => 'TT_LibĀ² Outdated',
      :scrollable => false, :resizable => false, :left => 200, :top => 200
    }
    w = UI::WebDialog.new( options )
    w.set_size( 500, 300 )
    arguments  = "plugin=#{plugin_name}"
    arguments << "&version=#{TT::Lib::VERSION}"
    arguments << "&minimum=#{version}"
    w.set_url( "#{url}?#{arguments}" )
    w.show
    TT.lib2_update = w
  end
  return false
end

.pathString

Returns The file path where the library is installed.

Returns:

  • (String)

    The file path where the library is installed.

Since:

  • 2.0.0



319
320
321
# File 'TT_Lib2/core.rb', line 319

def self.path
  PATH.dup
end

.reload(return_files = false) ⇒ Integer, Array

Debug method to reload the library modules.

Parameters:

  • return_files (Boolean) (defaults to: false)

    Determines if the method should return the number of files reloaded or an array of the files reloaded.

Returns:

  • (Integer, Array)

Since:

  • 2.0.0



331
332
333
334
335
336
337
338
339
340
# File 'TT_Lib2/core.rb', line 331

def self.reload( return_files=false )
  original_verbose = $VERBOSE
  $VERBOSE = nil # Mute warnings caused by constant redefining.
  x = Dir.glob( File.join(self.path, '*.{rb,rbs}') ).each { |file|
    load file
  }
  (return_files) ? x : x.length
ensure
  $VERBOSE = original_verbose
end