Module: TorQML::Plugins

Defined in:
lib/torqml/plugins.rb

Overview

TorQML module of plugins

Constant Summary collapse

VERSION =

Version of Plugins module.

"0.1"

Class Method Summary collapse

Class Method Details

.default_pathString

Returns default path of plugin directory.

Returns:

  • (String)

    the default directory



12
13
14
# File 'lib/torqml/plugins.rb', line 12

def default_path
  ENV['HOME'] + '/.torqml/plugins'
end

.load(app, dir) ⇒ Object

Loads QML/C++ plugins.

Parameters:

  • app (QML::Application)

    QML application

  • dir (Pathname)

    path to the directory that contains plugins



30
31
32
33
34
35
36
# File 'lib/torqml/plugins.rb', line 30

def load(app, dir)
  Pathname.glob(dir + '*/plugin.rb').each do |path|
    # add directories into import path of the application
    app.engine.add_import_path("#{path.realpath.dirname}/qml") if (path.realpath.dirname + 'qml').exist?
    app.engine.add_import_path("#{path.realpath.dirname}/ext") if (path.realpath.dirname + 'ext').exist?
  end
end

.preload(dir) ⇒ Object

Preloads ruby modules of plugins.

Parameters:

  • dir (Pathname)

    path to the directory that contains plugins



19
20
21
22
23
24
# File 'lib/torqml/plugins.rb', line 19

def preload(dir)
  Pathname.glob(dir + '*/plugin.rb').each do |path|
    # load ruby modules
    require(path.realpath.dirname + path.basename)
  end
end