Sha256: b8ab01f3a1f4633bdc461d523895aedcd81b559daf4cb355cf37326df8d01795

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

#-------------------------------------------------------------------------------
#
#    Author: Unknown
# Copyright: Copyright (c) 2017
#   License: None
#
#-------------------------------------------------------------------------------

require 'json'

require 'extensions.rb'
require 'sketchup.rb'

module Example
module HelloWorld

  file = __FILE__.dup
  # Account for Ruby encoding bug under Windows.
  file.force_encoding('UTF-8') if file.respond_to?(:force_encoding)
  # Support folder should be named the same as the root .rb file.
  folder_name = File.basename(file, '.*')

  # Path to the root .rb file (this file).
  PATH_ROOT = File.dirname(file).freeze

  # Path to the support folder.
  PATH = File.join(PATH_ROOT, folder_name).freeze

  # Extension information.
  extension_json_file = File.join(PATH, 'extension.json')
  extension_json = File.read(extension_json_file)
  EXTENSION = ::JSON.parse(extension_json, symbolize_names: true).freeze

  unless file_loaded?(__FILE__)
    loader = File.join(PATH, 'main')
    @extension = SketchupExtension.new(EXTENSION[:name], loader)
    @extension.description = EXTENSION[:description]
    @extension.version     = EXTENSION[:version]
    @extension.copyright   = EXTENSION[:copyright]
    @extension.creator     = EXTENSION[:creator]
    Sketchup.register_extension(@extension, true)
  end

end # module HelloWorld
end # module Example

file_loaded(__FILE__)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
skippy-0.2.0.a fixtures/my_project/src/hello_world.rb