Module: Merb::Plugins

Defined in:
lib/merb-core/plugins.rb

Class Method Summary collapse

Class Method Details

.add_generators(*generators) ⇒ Object

Parameters

*generators

Generator paths to add to the list of plugin generators.

Notes

This is the recommended way to register your plugin's generators in Merb.

:api: plugin


76
77
78
# File 'lib/merb-core/plugins.rb', line 76

def self.add_generators(*generators)
  Merb.add_generators(*generators)
end

.add_rakefiles(*rakefiles) ⇒ Object

Parameters

*rakefiles

Rakefiles to add to the list of plugin Rakefiles.

Notes

This is a recommended way to register your plugin's Raketasks in Merb.

Examples

From merb_sequel plugin:

if defined(Merb::Plugins)

Merb::Plugins.add_rakefiles "merb_sequel" / "merbtasks"

end

:api: plugin


63
64
65
# File 'lib/merb-core/plugins.rb', line 63

def self.add_rakefiles(*rakefiles)
  Merb.add_rakefiles(*rakefiles)
end

.configObject

Returns the configuration settings hash for plugins. This is prepopulated from Merb.root / “config/plugins.yml” if it is present.

Returns

Hash

The configuration loaded from Merb.root / “config/plugins.yml” or, if the load fails, an empty hash whose default value is another Hash.

:api: plugin


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/merb-core/plugins.rb', line 14

def self.config
  @config ||= begin
    # this is so you can do Merb.plugins.config[:helpers][:awesome] = "bar"
    config_hash = Hash.new {|h,k| h[k] = {}}
    file = Merb.root / "config" / "plugins.yml"

    if File.exists?(file)
      require 'yaml'
      to_merge = YAML.load_file(file)
    else
      to_merge = {}
    end
    
    config_hash.merge(to_merge)
  end
end

.generatorsObject

Returns

Array(String)

All Generator load paths Merb uses for plugins.

:api: plugin


43
44
45
# File 'lib/merb-core/plugins.rb', line 43

def self.generators
  Merb.generators
end

.rakefilesObject

Returns

Array(String)

All Rakefile load paths Merb uses for plugins.

:api: plugin


35
36
37
# File 'lib/merb-core/plugins.rb', line 35

def self.rakefiles
  Merb.rakefiles
end