Skip to content

Commit

Permalink
Merge pull request #3 from opf/feature/unified_register
Browse files Browse the repository at this point in the history
allow our custom register to pass blocks so plugins don't have to rely on the bare-bones Redmine::Plugin
  • Loading branch information
sschu committed Jan 17, 2014
2 parents 2a6268f + f6c7898 commit 27f8ab5
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ module OpenProject::RepositoryAuthentication

register 'openproject-repository_authentication',
:author_url => 'http://finn.de',
:requires_openproject => '>= 3.0.0pre6'
:requires_openproject => '>= 3.0.0pre6' do
menu :project_menu,
:repo_auth,
{:controller => '/repo_auth_controller', :action => :index},
:caption => "Repo Auth!"
end

patches [:SysController]
end
Expand Down
2 changes: 2 additions & 0 deletions doc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ See doc/COPYRIGHT.md for more details.

# Changelog

* Allows plugin register to receive a block so plugins don't have to register with this plugin AND Redmine::Plugin

## 1.0.5

* Readme: Add note about db:create and db:migrate in same rake process
Expand Down
6 changes: 4 additions & 2 deletions lib/open_project/plugins/acts_as_op_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ def self.included(base)
# options: An options Hash, at least :requires_openproject is recommended to
# define the minimal version of OpenProject the plugin is compatible with
# Another common option is :author_url.
base.send(:define_method, :register) do |gem_name, options|
# block: Pass a block to the plugin (for defining permissions, menu items and the like)
base.send(:define_method, :register) do |gem_name, options, &block|
base.initializer "#{engine_name}.register_plugin" do
spec = Bundler.environment.specs[gem_name][0]

Redmine::Plugin.register engine_name.to_sym do
p = Redmine::Plugin.register engine_name.to_sym do
name spec.summary
author spec.authors.kind_of?(Array) ? spec.authors[0] : spec.authors
description spec.description
Expand All @@ -85,6 +86,7 @@ def self.included(base)
send(name, value)
end
end
p.instance_eval(&block) if (p && block)
end

# Workaround to ensure settings are available after unloading in development mode
Expand Down

0 comments on commit 27f8ab5

Please sign in to comment.