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

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7407 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-09-20 02:12:17 +00:00
parent 58563b4bcb
commit e9cbfa032f
1 changed files with 18 additions and 18 deletions

View File

@ -1,16 +1,16 @@
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2008 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2 # as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version. # of the License, or (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@ -22,7 +22,7 @@ module Redmine
@@listener_classes = [] @@listener_classes = []
@@listeners = nil @@listeners = nil
@@hook_listeners = {} @@hook_listeners = {}
class << self class << self
# Adds a listener class. # Adds a listener class.
# Automatically called when a class inherits from Redmine::Hook::Listener. # Automatically called when a class inherits from Redmine::Hook::Listener.
@ -31,29 +31,29 @@ module Redmine
@@listener_classes << klass @@listener_classes << klass
clear_listeners_instances clear_listeners_instances
end end
# Returns all the listerners instances. # Returns all the listerners instances.
def listeners def listeners
@@listeners ||= @@listener_classes.collect {|listener| listener.instance} @@listeners ||= @@listener_classes.collect {|listener| listener.instance}
end end
# Returns the listeners instances for the given hook. # Returns the listeners instances for the given hook.
def hook_listeners(hook) def hook_listeners(hook)
@@hook_listeners[hook] ||= listeners.select {|listener| listener.respond_to?(hook)} @@hook_listeners[hook] ||= listeners.select {|listener| listener.respond_to?(hook)}
end end
# Clears all the listeners. # Clears all the listeners.
def clear_listeners def clear_listeners
@@listener_classes = [] @@listener_classes = []
clear_listeners_instances clear_listeners_instances
end end
# Clears all the listeners instances. # Clears all the listeners instances.
def clear_listeners_instances def clear_listeners_instances
@@listeners = nil @@listeners = nil
@@hook_listeners = {} @@hook_listeners = {}
end end
# Calls a hook. # Calls a hook.
# Returns the listeners response. # Returns the listeners response.
def call_hook(hook, context={}) def call_hook(hook, context={})
@ -101,11 +101,11 @@ module Redmine
def self.default_url_options def self.default_url_options
{:only_path => true } {:only_path => true }
end end
# Helper method to directly render a partial using the context: # Helper method to directly render a partial using the context:
# #
# class MyHook < Redmine::Hook::ViewListener # class MyHook < Redmine::Hook::ViewListener
# render_on :view_issues_show_details_bottom, :partial => "show_more_data" # render_on :view_issues_show_details_bottom, :partial => "show_more_data"
# end # end
# #
def self.render_on(hook, options={}) def self.render_on(hook, options={})
@ -117,23 +117,23 @@ module Redmine
# Helper module included in ApplicationHelper and ActionControllerso that # Helper module included in ApplicationHelper and ActionControllerso that
# hooks can be called in views like this: # hooks can be called in views like this:
# #
# <%= call_hook(:some_hook) %> # <%= call_hook(:some_hook) %>
# <%= call_hook(:another_hook, :foo => 'bar' %> # <%= call_hook(:another_hook, :foo => 'bar' %>
# #
# Or in controllers like: # Or in controllers like:
# call_hook(:some_hook) # call_hook(:some_hook)
# call_hook(:another_hook, :foo => 'bar' # call_hook(:another_hook, :foo => 'bar'
# #
# Hooks added to views will be concatenated into a string. Hooks added to # Hooks added to views will be concatenated into a string. Hooks added to
# controllers will return an array of results. # controllers will return an array of results.
# #
# Several objects are automatically added to the call context: # Several objects are automatically added to the call context:
# #
# * project => current project # * project => current project
# * request => Request instance # * request => Request instance
# * controller => current Controller instance # * controller => current Controller instance
# #
module Helper module Helper
def call_hook(hook, context={}) def call_hook(hook, context={})
if is_a?(ActionController::Base) if is_a?(ActionController::Base)
@ -142,7 +142,7 @@ module Redmine
else else
default_context = {:controller => controller, :project => @project, :request => request} default_context = {:controller => controller, :project => @project, :request => request}
Redmine::Hook.call_hook(hook, default_context.merge(context)).join(' ') Redmine::Hook.call_hook(hook, default_context.merge(context)).join(' ')
end end
end end
end end
end end