Sha256: 5d939ee8b6aa2856ba7deef483fe0e98787436ddc4f7588539957deb9d24be82

Contents?: true

Size: 1.94 KB

Versions: 11

Compression:

Stored size: 1.94 KB

Contents

module Merb

  module Plugins

    # 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
    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

    # ==== Returns
    # Array(String):: All Rakefile load paths Merb uses for plugins.
    #
    # @api plugin
    def self.rakefiles
      Merb.rakefiles
    end
    
    # ==== Returns
    # Array(String):: All Generator load paths Merb uses for plugins.
    #
    # @api plugin
    def self.generators
      Merb.generators
    end

    # ==== 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
    def self.add_rakefiles(*rakefiles)
      Merb.add_rakefiles(*rakefiles)
    end
    
    # ==== 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
    def self.add_generators(*generators)
      Merb.add_generators(*generators)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
merb-core-1.1.3 spec10/public/webrat/test_app/gems/gems/merb-core-0.9.14/lib/merb-core/plugins.rb
merb-core-1.1.2 spec10/public/webrat/test_app/gems/gems/merb-core-0.9.14/lib/merb-core/plugins.rb
merb-core-1.1.1 spec10/public/webrat/test_app/gems/gems/merb-core-0.9.14/lib/merb-core/plugins.rb
merb-core-1.1.0 spec10/public/webrat/test_app/gems/gems/merb-core-0.9.14/lib/merb-core/plugins.rb
merb-core-1.1.0.rc1 spec10/public/webrat/test_app/gems/gems/merb-core-0.9.14/lib/merb-core/plugins.rb
merb-core-1.1.0.pre spec10/public/webrat/test_app/gems/gems/merb-core-0.9.14/lib/merb-core/plugins.rb
merb-core-0.9.10 lib/merb-core/plugins.rb
merb-core-0.9.12 lib/merb-core/plugins.rb
merb-core-0.9.13 lib/merb-core/plugins.rb
merb-core-0.9.11 lib/merb-core/plugins.rb
merb-core-0.9.9 lib/merb-core/plugins.rb