Module: YleTf::Plugin::Loader
- Defined in:
- lib/yle_tf/plugin/loader.rb
Constant Summary collapse
- BUNDLER_PLUGIN_GROUP =
:tf_plugins
Class Method Summary collapse
- .bundler_plugins ⇒ Object
- .bundler_set_up? ⇒ Boolean
- .core_plugins ⇒ Object
- .load_bundler_plugins ⇒ Object
- .load_core_plugins ⇒ Object
- .load_plugins ⇒ Object
- .load_user_plugins ⇒ Object
- .print_bundler_plugin_list ⇒ Object
- .user_plugins ⇒ Object
Class Method Details
.bundler_plugins ⇒ Object
39 40 41 42 43 44 |
# File 'lib/yle_tf/plugin/loader.rb', line 39 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? ⇒ Boolean
50 51 52 |
# File 'lib/yle_tf/plugin/loader.rb', line 50 def self.bundler_set_up? defined?(Bundler) && Bundler.respond_to?(:require) end |
.core_plugins ⇒ Object
35 36 37 |
# File 'lib/yle_tf/plugin/loader.rb', line 35 def self.core_plugins Dir.glob(File.('../../../yle_tf_plugins/**/plugin.rb', __FILE__)) end |
.load_bundler_plugins ⇒ Object
21 22 23 24 25 26 |
# File 'lib/yle_tf/plugin/loader.rb', line 21 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 ⇒ Object
14 15 16 17 18 19 |
# File 'lib/yle_tf/plugin/loader.rb', line 14 def self.load_core_plugins core_plugins.each do |plugin_file| Logger.debug("Loading core plugin: #{File.basename(plugin_file, '.rb')}") load(plugin_file) end end |
.load_plugins ⇒ Object
8 9 10 11 12 |
# File 'lib/yle_tf/plugin/loader.rb', line 8 def self.load_plugins load_core_plugins load_bundler_plugins load_user_plugins end |
.load_user_plugins ⇒ Object
28 29 30 31 32 33 |
# File 'lib/yle_tf/plugin/loader.rb', line 28 def self.load_user_plugins user_plugins.each do |plugin| Logger.debug("Loading user plugin: #{plugin}") require(plugin) end end |
.print_bundler_plugin_list ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/yle_tf/plugin/loader.rb', line 54 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 ⇒ Object
46 47 48 |
# File 'lib/yle_tf/plugin/loader.rb', line 46 def self.user_plugins ENV.fetch('TF_PLUGINS', '').split(/[ ,]+/) end |