remove trailing white-spaces from lib/redmine/plugin.rb

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7408 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-09-20 02:43:47 +00:00
parent e9cbfa032f
commit 3d1d57d04c
1 changed files with 32 additions and 32 deletions

View File

@ -19,10 +19,10 @@ module Redmine #:nodoc:
class PluginNotFound < StandardError; end class PluginNotFound < StandardError; end
class PluginRequirementError < StandardError; end class PluginRequirementError < StandardError; end
# Base class for Redmine plugins. # Base class for Redmine plugins.
# Plugins are registered using the <tt>register</tt> class method that acts as the public constructor. # Plugins are registered using the <tt>register</tt> class method that acts as the public constructor.
# #
# Redmine::Plugin.register :example do # Redmine::Plugin.register :example do
# name 'Example plugin' # name 'Example plugin'
# author 'John Smith' # author 'John Smith'
@ -30,9 +30,9 @@ module Redmine #:nodoc:
# version '0.0.1' # version '0.0.1'
# settings :default => {'foo'=>'bar'}, :partial => 'settings/settings' # settings :default => {'foo'=>'bar'}, :partial => 'settings/settings'
# end # end
# #
# === Plugin attributes # === Plugin attributes
# #
# +settings+ is an optional attribute that let the plugin be configurable. # +settings+ is an optional attribute that let the plugin be configurable.
# It must be a hash with the following keys: # It must be a hash with the following keys:
# * <tt>:default</tt>: default value for the plugin settings # * <tt>:default</tt>: default value for the plugin settings
@ -40,7 +40,7 @@ module Redmine #:nodoc:
# Example: # Example:
# settings :default => {'foo'=>'bar'}, :partial => 'settings/settings' # settings :default => {'foo'=>'bar'}, :partial => 'settings/settings'
# In this example, the settings partial will be found here in the plugin directory: <tt>app/views/settings/_settings.rhtml</tt>. # In this example, the settings partial will be found here in the plugin directory: <tt>app/views/settings/_settings.rhtml</tt>.
# #
# When rendered, the plugin settings value is available as the local variable +settings+ # When rendered, the plugin settings value is available as the local variable +settings+
class Plugin class Plugin
@registered_plugins = {} @registered_plugins = {}
@ -49,9 +49,9 @@ module Redmine #:nodoc:
private :new private :new
def def_field(*names) def def_field(*names)
class_eval do class_eval do
names.each do |name| names.each do |name|
define_method(name) do |*args| define_method(name) do |*args|
args.empty? ? instance_variable_get("@#{name}") : instance_variable_set("@#{name}", *args) args.empty? ? instance_variable_get("@#{name}") : instance_variable_set("@#{name}", *args)
end end
end end
@ -60,7 +60,7 @@ module Redmine #:nodoc:
end end
def_field :name, :description, :url, :author, :author_url, :version, :settings def_field :name, :description, :url, :author, :author_url, :version, :settings
attr_reader :id attr_reader :id
# Plugin constructor # Plugin constructor
def self.register(id, &block) def self.register(id, &block)
p = new(id) p = new(id)
@ -83,7 +83,7 @@ module Redmine #:nodoc:
def self.find(id) def self.find(id)
registered_plugins[id.to_sym] || raise(PluginNotFound) registered_plugins[id.to_sym] || raise(PluginNotFound)
end end
# Clears the registered plugins hash # Clears the registered plugins hash
# It doesn't unload installed plugins # It doesn't unload installed plugins
def self.clear def self.clear
@ -96,15 +96,15 @@ module Redmine #:nodoc:
def self.installed?(id) def self.installed?(id)
registered_plugins[id.to_sym].present? registered_plugins[id.to_sym].present?
end end
def initialize(id) def initialize(id)
@id = id.to_sym @id = id.to_sym
end end
def <=>(plugin) def <=>(plugin)
self.id.to_s <=> plugin.id.to_s self.id.to_s <=> plugin.id.to_s
end end
# Sets a requirement on Redmine version # Sets a requirement on Redmine version
# Raises a PluginRequirementError exception if the requirement is not met # Raises a PluginRequirementError exception if the requirement is not met
# #
@ -119,7 +119,7 @@ module Redmine #:nodoc:
def requires_redmine(arg) def requires_redmine(arg)
arg = { :version_or_higher => arg } unless arg.is_a?(Hash) arg = { :version_or_higher => arg } unless arg.is_a?(Hash)
arg.assert_valid_keys(:version, :version_or_higher) arg.assert_valid_keys(:version, :version_or_higher)
current = Redmine::VERSION.to_a current = Redmine::VERSION.to_a
arg.each do |k, v| arg.each do |k, v|
v = [] << v unless v.is_a?(Array) v = [] << v unless v.is_a?(Array)
@ -178,39 +178,39 @@ module Redmine #:nodoc:
# Adds an item to the given +menu+. # Adds an item to the given +menu+.
# The +id+ parameter (equals to the project id) is automatically added to the url. # The +id+ parameter (equals to the project id) is automatically added to the url.
# menu :project_menu, :plugin_example, { :controller => 'example', :action => 'say_hello' }, :caption => 'Sample' # menu :project_menu, :plugin_example, { :controller => 'example', :action => 'say_hello' }, :caption => 'Sample'
# #
# +name+ parameter can be: :top_menu, :account_menu, :application_menu or :project_menu # +name+ parameter can be: :top_menu, :account_menu, :application_menu or :project_menu
# #
def menu(menu, item, url, options={}) def menu(menu, item, url, options={})
Redmine::MenuManager.map(menu).push(item, url, options) Redmine::MenuManager.map(menu).push(item, url, options)
end end
alias :add_menu_item :menu alias :add_menu_item :menu
# Removes +item+ from the given +menu+. # Removes +item+ from the given +menu+.
def delete_menu_item(menu, item) def delete_menu_item(menu, item)
Redmine::MenuManager.map(menu).delete(item) Redmine::MenuManager.map(menu).delete(item)
end end
# Defines a permission called +name+ for the given +actions+. # Defines a permission called +name+ for the given +actions+.
# #
# The +actions+ argument is a hash with controllers as keys and actions as values (a single value or an array): # The +actions+ argument is a hash with controllers as keys and actions as values (a single value or an array):
# permission :destroy_contacts, { :contacts => :destroy } # permission :destroy_contacts, { :contacts => :destroy }
# permission :view_contacts, { :contacts => [:index, :show] } # permission :view_contacts, { :contacts => [:index, :show] }
# #
# The +options+ argument can be used to make the permission public (implicitly given to any user) # The +options+ argument can be used to make the permission public (implicitly given to any user)
# or to restrict users the permission can be given to. # or to restrict users the permission can be given to.
# #
# Examples # Examples
# # A permission that is implicitly given to any user # # A permission that is implicitly given to any user
# # This permission won't appear on the Roles & Permissions setup screen # # This permission won't appear on the Roles & Permissions setup screen
# permission :say_hello, { :example => :say_hello }, :public => true # permission :say_hello, { :example => :say_hello }, :public => true
# #
# # A permission that can be given to any user # # A permission that can be given to any user
# permission :say_hello, { :example => :say_hello } # permission :say_hello, { :example => :say_hello }
# #
# # A permission that can be given to registered users only # # A permission that can be given to registered users only
# permission :say_hello, { :example => :say_hello }, :require => :loggedin # permission :say_hello, { :example => :say_hello }, :require => :loggedin
# #
# # A permission that can be given to project members only # # A permission that can be given to project members only
# permission :say_hello, { :example => :say_hello }, :require => :member # permission :say_hello, { :example => :say_hello }, :require => :member
def permission(name, actions, options = {}) def permission(name, actions, options = {})
@ -220,10 +220,10 @@ module Redmine #:nodoc:
Redmine::AccessControl.map {|map| map.permission(name, actions, options)} Redmine::AccessControl.map {|map| map.permission(name, actions, options)}
end end
end end
# Defines a project module, that can be enabled/disabled for each project. # Defines a project module, that can be enabled/disabled for each project.
# Permissions defined inside +block+ will be bind to the module. # Permissions defined inside +block+ will be bind to the module.
# #
# project_module :things do # project_module :things do
# permission :view_contacts, { :contacts => [:list, :show] }, :public => true # permission :view_contacts, { :contacts => [:list, :show] }, :public => true
# permission :destroy_contacts, { :contacts => :destroy } # permission :destroy_contacts, { :contacts => :destroy }
@ -233,33 +233,33 @@ module Redmine #:nodoc:
self.instance_eval(&block) self.instance_eval(&block)
@project_module = nil @project_module = nil
end end
# Registers an activity provider. # Registers an activity provider.
# #
# Options: # Options:
# * <tt>:class_name</tt> - one or more model(s) that provide these events (inferred from event_type by default) # * <tt>:class_name</tt> - one or more model(s) that provide these events (inferred from event_type by default)
# * <tt>:default</tt> - setting this option to false will make the events not displayed by default # * <tt>:default</tt> - setting this option to false will make the events not displayed by default
# #
# A model can provide several activity event types. # A model can provide several activity event types.
# #
# Examples: # Examples:
# register :news # register :news
# register :scrums, :class_name => 'Meeting' # register :scrums, :class_name => 'Meeting'
# register :issues, :class_name => ['Issue', 'Journal'] # register :issues, :class_name => ['Issue', 'Journal']
# #
# Retrieving events: # Retrieving events:
# Associated model(s) must implement the find_events class method. # Associated model(s) must implement the find_events class method.
# ActiveRecord models can use acts_as_activity_provider as a way to implement this class method. # ActiveRecord models can use acts_as_activity_provider as a way to implement this class method.
# #
# The following call should return all the scrum events visible by current user that occured in the 5 last days: # The following call should return all the scrum events visible by current user that occured in the 5 last days:
# Meeting.find_events('scrums', User.current, 5.days.ago, Date.today) # Meeting.find_events('scrums', User.current, 5.days.ago, Date.today)
# Meeting.find_events('scrums', User.current, 5.days.ago, Date.today, :project => foo) # events for project foo only # Meeting.find_events('scrums', User.current, 5.days.ago, Date.today, :project => foo) # events for project foo only
# #
# Note that :view_scrums permission is required to view these events in the activity view. # Note that :view_scrums permission is required to view these events in the activity view.
def activity_provider(*args) def activity_provider(*args)
Redmine::Activity.register(*args) Redmine::Activity.register(*args)
end end
# Registers a wiki formatter. # Registers a wiki formatter.
# #
# Parameters: # Parameters: