Module: Merb::Plugins

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

Class Method Summary (collapse)

Class Method Details

+ (Object) add_generators(*generators)

Add generator load paths.

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



74
75
76
# File 'merb-core/lib/merb-core/plugins.rb', line 74

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

+ (Object) add_rakefiles(*rakefiles)

Add Rakefile load paths.

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

Examples:

From the merb_sequel plugin:

if defined(Merb::Plugins)
  Merb::Plugins.add_rakefiles "merb_sequel" / "merbtasks"
end


61
62
63
# File 'merb-core/lib/merb-core/plugins.rb', line 61

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

+ (Hash) config

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



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

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

+ (Array<String>) generators

Get all Generator load paths Merb uses for plugins.



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

def self.generators
  Merb.generators
end

+ (Array<String>) rakefiles

Get all Rakefile load paths Merb uses for plugins.



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

def self.rakefiles
  Merb.rakefiles
end