Class: BoxGrinder::PluginHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/boxgrinder-build/helpers/plugin-helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, options = {}) ⇒ PluginHelper



43
44
45
46
# File 'lib/boxgrinder-build/helpers/plugin-helper.rb', line 43

def initialize( config, options = {} )
  @options  = config
  @log      = options[:log] || LogHelper.new
end

Instance Attribute Details

#delivery_pluginsObject (readonly)

Returns the value of attribute delivery_plugins.



92
93
94
# File 'lib/boxgrinder-build/helpers/plugin-helper.rb', line 92

def delivery_plugins
  @delivery_plugins
end

#os_pluginsObject (readonly)

Returns the value of attribute os_plugins.



90
91
92
# File 'lib/boxgrinder-build/helpers/plugin-helper.rb', line 90

def os_plugins
  @os_plugins
end

#platform_pluginsObject (readonly)

Returns the value of attribute platform_plugins.



91
92
93
# File 'lib/boxgrinder-build/helpers/plugin-helper.rb', line 91

def platform_plugins
  @platform_plugins
end

Instance Method Details

#load_pluginsObject



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/boxgrinder-build/helpers/plugin-helper.rb', line 48

def load_plugins
  read_and_require

  @os_plugins       = PluginManager.instance.plugins[:os]
  @platform_plugins = PluginManager.instance.plugins[:platform]
  @delivery_plugins = PluginManager.instance.plugins[:delivery]

  print_plugins( 'os' ) { @os_plugins }
  print_plugins( 'platform' ) { @platform_plugins }
  print_plugins( 'delivery' ) { @delivery_plugins }

  self
end


76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/boxgrinder-build/helpers/plugin-helper.rb', line 76

def print_plugins( type )
  @log.debug "Loading #{type} plugins..."

  plugins = yield

  @log.debug "We have #{plugins.size} #{type} plugin(s) registered"

  plugins.each do |plugin_name_or_type, plugin_info|
    @log.debug "- #{plugin_name_or_type} plugin for #{plugin_info[:full_name]}."
  end

  @log.debug "Plugins loaded."
end

#read_and_requireObject



62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/boxgrinder-build/helpers/plugin-helper.rb', line 62

def read_and_require
  @options.additional_plugins.each do |plugin|
    @log.trace "Loading plugin '#{plugin}'..."

    begin
      require plugin
      @log.trace "- OK"
    rescue LoadError => e
      @log.trace "- Not found: #{e.message.strip.chomp}"
      @log.warn "Specified plugin: '#{plugin}' wasn't found. Make sure its name is correct, skipping..."
    end
  end
end