module YleTf::Plugin::Loader
Constants
- BUNDLER_PLUGIN_GROUP
Public Class Methods
bundler_plugins()
click to toggle source
# File lib/yle_tf/plugin/loader.rb, line 46 def self.bundler_plugins plugins = Bundler.definition.current_dependencies.select do |dep| dep.groups.include?(BUNDLER_PLUGIN_GROUP) end plugins.map { |dep| Bundler.definition.specs[dep].first } end
bundler_set_up?()
click to toggle source
# File lib/yle_tf/plugin/loader.rb, line 57 def self.bundler_set_up? defined?(Bundler) && Bundler.respond_to?(:require) end
core_plugin_name(path)
click to toggle source
# File lib/yle_tf/plugin/loader.rb, line 41 def self.core_plugin_name(path) m = %r{.*/yle_tf_plugins/(?<name>.+?)/plugin\.rb$}.match(path) m ? m[:name] : path end
core_plugins()
click to toggle source
# File lib/yle_tf/plugin/loader.rb, line 37 def self.core_plugins Dir.glob(File.expand_path('../../yle_tf_plugins/**/plugin.rb', __dir__)) end
load_bundler_plugins()
click to toggle source
# File lib/yle_tf/plugin/loader.rb, line 23 def self.load_bundler_plugins return if !bundler_set_up? print_bundler_plugin_list if Logger.debug? Bundler.require(BUNDLER_PLUGIN_GROUP) end
load_core_plugins()
click to toggle source
# File lib/yle_tf/plugin/loader.rb, line 16 def self.load_core_plugins core_plugins.each do |plugin_file| Logger.debug { "Loading core plugin: #{core_plugin_name(plugin_file)}" } load(plugin_file) end end
load_plugins()
click to toggle source
# File lib/yle_tf/plugin/loader.rb, line 10 def self.load_plugins load_core_plugins load_bundler_plugins load_user_plugins end
load_user_plugins()
click to toggle source
# File lib/yle_tf/plugin/loader.rb, line 30 def self.load_user_plugins user_plugins.each do |plugin| Logger.debug("Loading user plugin: #{plugin}") require(plugin) end end
print_bundler_plugin_list()
click to toggle source
# File lib/yle_tf/plugin/loader.rb, line 61 def self.print_bundler_plugin_list plugins = bundler_plugins if !plugins.empty? Logger.debug('Loading plugins via Bundler:') plugins.each { |spec| Logger.debug(" - #{spec.name} = #{spec.version}") } end end
user_plugins()
click to toggle source
# File lib/yle_tf/plugin/loader.rb, line 53 def self.user_plugins ENV.fetch('TF_PLUGINS', '').split(/[ ,]+/) end