openproject-plugins 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 82f6dd65effd37dc2d14bea60a33b61ccdc78655
4
+ data.tar.gz: 879a92f8812e7c07d835802b56307453cf04d6d9
5
+ SHA512:
6
+ metadata.gz: 8b1583c4f8c496217155e355a87ba08c423655331f2391929c730b254cce44e5985387c9f4b4b566865cbc83836de8f4ae233aef06cd00fe397493743ed8844b
7
+ data.tar.gz: 768a7f518c111bd89ae8f5ddd081c7486721a534839dc75d3d343630e9cca1048a5cd3ce7604f58635b6d2068cde8cdb389cc740b584c329fd79fe9ba63aaaa3
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ <!---- copyright
2
+ OpenProject is a project management system.
3
+
4
+ Copyright (C) 2012-2013 the OpenProject Team
5
+
6
+ This program is free software; you can redistribute it and/or
7
+ modify it under the terms of the GNU General Public License version 3.
8
+
9
+ See doc/COPYRIGHT.md for more details.
10
+
11
+ ++-->
12
+
13
+ # OpenProject Plugins Plugin
14
+
15
+ This plugin aims to make writing plugins easier. It provides a generator for creating a basic plugin structure and a module that simplifies setting up the plugin Rails engine. Thus, it is also a dependency for many plugins.
16
+
17
+ ## Usage
18
+
19
+ Make sure to include the plugins plugin before all other plugins in your Gemfile, otherwise the module used by the plugin Rails engines (`OpenProject::Plugins::ActsAsOpEngine`) is not available when a plugin is being loaded.
20
+
21
+ ### Generator
22
+
23
+ bundle exec rails generate open_project:plugin <plugin name> <target folder>
24
+
25
+ The generator will create a new subfolder within `<target folder>`, named `openproject-<plugin name>`.
26
+
27
+ Example:
28
+
29
+ bundle exec rails generate open_project:plugin xls_export .
30
+
31
+ ### ActsAsOpEngine
32
+
33
+ The generated engine uses `ActsAsOpEngine` by default, so just have a look at this file.
34
+ For more information on how to use `ActsAsOpEngine`, just see the comments in its [source code](lib/open_project/plugins/acts_as_op_engine.rb).
35
+ It offers methods to load patches and register assets besides others.
36
+
37
+ #### Example
38
+ ```ruby
39
+ module OpenProject::RepositoryAuthentication
40
+ class Engine < ::Rails::Engine
41
+ engine_name :openproject_repository_authentication
42
+
43
+ include OpenProject::Plugins::ActsAsOpEngine
44
+
45
+ register 'openproject-repository_authentication',
46
+ :author_url => 'http://finn.de',
47
+ :requires_openproject => '>= 3.0.0pre6'
48
+
49
+ patches [:SysController]
50
+ end
51
+ end
52
+ ```
53
+
54
+ ## Get in Contact
55
+
56
+ OpenProject is supported by its community members, both companies as well as individuals. There are different possibilities of getting help:
57
+ * OpenProject [support page](https://www.openproject.org/projects/openproject/wiki/Support)
58
+ * E-Mail Support - info@openproject.org
59
+
60
+ ## Start Collaborating
61
+
62
+ Join the OpenProject community and start collaborating. We envision building a platform to share ideas, contributions, and discussions around OpenProject and project collaboration. Each commitment is noteworthy as it helps to improve the software and the project.
63
+ More details will be added on the OpenProject Community [contribution page](https://www.openproject.org/projects/openproject/wiki/Contribution).
64
+
65
+ In case you find a bug or need a feature, please report at https://www.openproject.org/projects/plugin-plugins/issues
66
+
67
+ ## License
68
+
69
+ (c) 2013 - Finn GmbH
70
+
71
+ This plugin is licensed under the GNU GPL v3. See doc/COPYRIGHT.md for details.
@@ -0,0 +1,19 @@
1
+ Description:
2
+ Creates a new plugin with the given name in the specified directory
3
+
4
+ Usage:
5
+ rails generate open_project:plugin NAME DIRECTORY
6
+
7
+ Example:
8
+ rails generate open_project:plugin stuff ~/
9
+
10
+ This will create:
11
+ ~/openproject-stuff
12
+ ~/openproject-stuff/CHANGELOG.md
13
+ ~/openproject-stuff/openproject-stuff.gemspec
14
+ ~/openproject-stuff/lib
15
+ ~/openproject-stuff/lib/openproject-stuff.rb
16
+ ~/openproject-stuff/lib/open_project
17
+ ~/openproject-stuff/lib/open_project/stuff.rb
18
+ ~/openproject-stuff/lib/open_project/stuff
19
+ ~/openproject-stuff/lib/open_project/stuff/engine.rb
@@ -0,0 +1,55 @@
1
+ #-- copyright
2
+ # OpenProject is a project management system.
3
+ #
4
+ # Copyright (C) 2012-2013 the OpenProject Team
5
+ #
6
+ # This program is free software; you can redistribute it and/or
7
+ # modify it under the terms of the GNU General Public License version 3.
8
+ #
9
+ # See doc/COPYRIGHT.md for more details.
10
+ #++
11
+
12
+ class OpenProject::PluginGenerator < Rails::Generators::Base
13
+ source_root File.expand_path('../templates', __FILE__)
14
+
15
+ argument :plugin_name, :type => :string, :default => "openproject-new-plugin"
16
+ argument :root_folder, :type => :string, :default => "vendor/gems"
17
+
18
+ # every public method is run when the generator is invoked
19
+ def generate_plugin
20
+ plugin_dir
21
+ lib_dir
22
+ end
23
+
24
+ def full_name
25
+ @full_name ||= begin
26
+ "openproject-#{plugin_name}"
27
+ end
28
+ end
29
+
30
+ private
31
+ def raise_on_params
32
+ puts plugin_name
33
+ puts root_folder
34
+ end
35
+
36
+ def plugin_path
37
+ "#{root_folder}/openproject-#{plugin_name}"
38
+ end
39
+
40
+ def plugin_dir
41
+ @plugin_dir ||= begin
42
+ directory('', plugin_path, :recursive => false)
43
+ end
44
+ end
45
+
46
+ def lib_path
47
+ "#{plugin_path}/lib"
48
+ end
49
+
50
+ def lib_dir
51
+ @lib_dir ||= begin
52
+ directory('lib', lib_path)
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,19 @@
1
+ # encoding: UTF-8
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ require 'open_project/<%= plugin_name %>/version'
5
+ # Describe your gem and declare its dependencies:
6
+ Gem::Specification.new do |s|
7
+ s.name = "<%= full_name %>"
8
+ s.version = OpenProject::<%= plugin_name.camelcase %>::VERSION
9
+ s.authors = "Finn GmbH"
10
+ s.email = "info@finn.de"
11
+ s.homepage = "http://www.finn.de"
12
+ s.summary = FIXME
13
+ s.description = FIXME
14
+ s.license = FIXME # e.g. "MIT" or "GPLv3"
15
+
16
+ s.files = Dir["{app,config,db,lib}/**/*"] + %w(CHANGELOG.md README.md)
17
+
18
+ s.add_dependency "rails", "~> 3.2.14"
19
+ end
@@ -0,0 +1,3 @@
1
+ # Changelog
2
+
3
+ * `#<ticket number>` Create plugin
@@ -0,0 +1,7 @@
1
+ # OpenProject <%= plugin_name.gsub('_',' ').titlecase %> Plugin
2
+
3
+ FIXME Add description and check issue tracker link below
4
+
5
+ ## Issue Tracker
6
+
7
+ https://www.openproject.org/projects/<%= plugin_name.gsub('_','-') %>/issues
@@ -0,0 +1 @@
1
+ require 'open_project/<%= plugin_name %>'
@@ -0,0 +1,5 @@
1
+ module OpenProject
2
+ module <%= plugin_name.camelcase %>
3
+ require "open_project/<%= plugin_name %>/engine"
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ module OpenProject::<%= plugin_name.camelcase %>
2
+ class Engine < ::Rails::Engine
3
+ engine_name :openproject_<%= plugin_name %>
4
+
5
+ include OpenProject::Plugins::ActsAsOpEngine
6
+
7
+ register 'OpenProject <%= plugin_name.gsub('_', ' ').titleize %>',
8
+ '<%= full_name %>',
9
+ :author_url => 'http://finn.de',
10
+ :requires_openproject => '>= 3.0.0pre13'
11
+
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ module OpenProject
2
+ module <%= plugin_name.camelcase %>
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ #-- copyright
2
+ # OpenProject is a project management system.
3
+ #
4
+ # Copyright (C) 2012-2013 the OpenProject Team
5
+ #
6
+ # This program is free software; you can redistribute it and/or
7
+ # modify it under the terms of the GNU General Public License version 3.
8
+ #
9
+ # See doc/COPYRIGHT.md for more details.
10
+ #++
11
+
12
+ module OpenProject
13
+ module Plugins
14
+ require 'open_project/plugins/engine'
15
+ end
16
+ end
@@ -0,0 +1,129 @@
1
+ #-- copyright
2
+ # OpenProject is a project management system.
3
+ #
4
+ # Copyright (C) 2012-2013 the OpenProject Team
5
+ #
6
+ # This program is free software; you can redistribute it and/or
7
+ # modify it under the terms of the GNU General Public License version 3.
8
+ #
9
+ # See doc/COPYRIGHT.md for more details.
10
+ #++
11
+
12
+ module OpenProject::Plugins
13
+ module ActsAsOpEngine
14
+
15
+ def self.included(base)
16
+ base.send(:define_method, :name) do
17
+ ActiveSupport::Inflector.demodulize(base).downcase
18
+ end
19
+
20
+ # Don't use the PatchRegistry for now, as the core classes doesn't notify of class loading
21
+ # Use the old config.to_prepare method, but we can hopefully someday switch to on-demand
22
+ # patching once the PatchRegistry works.
23
+
24
+ # base.send(:define_method, :patch) do |target, patch|
25
+ # OpenProject::Plugins::PatchRegistry.register(target, patch)
26
+ # end
27
+
28
+ # Disable LoadDependency for the same reason
29
+ # base.send(:define_method, :load_dependent) do |target, *dependencies|
30
+ # OpenProject::Plugins::LoadDependency.register(target, *dependencies)
31
+ # end
32
+
33
+ # Patch classes
34
+ #
35
+ # Looks for patches via autoloading in
36
+ # <plugin root>/lib/openproject/<plugin name>/patches/<patched_class>_patch.rb
37
+ # Make sure the patch module has the name the Rails autoloading expects.
38
+ #
39
+ # Example:
40
+ # patches [:IssuesController]
41
+ # This looks for OpenProject::XlsExport::Patches::IssuesControllerPatch
42
+ # in openproject/xls_export/patches/issues_controller_patch.rb
43
+ base.send(:define_method, :patches) do |patched_classes|
44
+ plugin_name = engine_name
45
+ base.config.to_prepare do
46
+ patched_classes.each do |klass_name|
47
+ plugin_module = plugin_name.sub(/^openproject_/, '').camelcase
48
+ patch = "OpenProject::#{plugin_module}::Patches::#{klass_name.to_s}Patch".constantize
49
+ klass = klass_name.to_s.constantize
50
+ klass.send(:include, patch) unless klass.included_modules.include?(patch)
51
+ end
52
+ end
53
+ end
54
+
55
+ # Define assets provided by the plugin
56
+ base.send(:define_method, :assets) do |assets|
57
+ base.initializer '#{engine_name}.precompile_assets' do |app|
58
+ app.config.assets.precompile += assets.to_a
59
+ end
60
+ end
61
+
62
+ # Register a plugin with OpenProject
63
+ #
64
+ # Uses Gem specification for plugin name, author etc.
65
+ #
66
+ # gem_name: The gem name, used for querying the gem for metadata like author
67
+ # options: An options Hash, at least :requires_openproject is recommended to
68
+ # define the minimal version of OpenProject the plugin is compatible with
69
+ # Another common option is :author_url.
70
+ base.send(:define_method, :register) do |gem_name, options|
71
+ base.initializer "#{engine_name}.register_plugin" do
72
+ spec = Bundler.environment.specs[gem_name][0]
73
+
74
+ Redmine::Plugin.register engine_name.to_sym do
75
+ name spec.summary
76
+ author spec.authors.kind_of?(Array) ? spec.authors[0] : spec.authors
77
+ description spec.description
78
+ version spec.version
79
+ url spec.homepage
80
+
81
+ options.each do |name, value|
82
+ send(name, value)
83
+ end
84
+ end
85
+ end
86
+
87
+ # Workaround to ensure settings are available after unloading in development mode
88
+ plugin_name = engine_name
89
+ if options.include? :settings
90
+ base.class_eval do
91
+ config.to_prepare do
92
+ Setting.create_setting("plugin_#{plugin_name}",
93
+ { 'serialized' => true }.merge(options[:settings]))
94
+ Setting.create_setting_accessors("plugin_#{plugin_name}")
95
+ end
96
+ end
97
+ end
98
+ end
99
+
100
+ base.class_eval do
101
+ config.autoload_paths += Dir["#{config.root}/lib/"]
102
+
103
+ config.before_configuration do |app|
104
+ # This is required for the routes to be loaded first
105
+ # as the routes should be prepended so they take precedence over the core.
106
+ app.config.paths['config/routes'].unshift File.join(config.root, "config", "routes.rb")
107
+ end
108
+
109
+ initializer "#{engine_name}.remove_duplicate_routes", :after => "add_routing_paths" do |app|
110
+ # removes duplicate entry from app.routes_reloader
111
+ # As we prepend the plugin's routes to the load_path up front and rails
112
+ # adds all engines' config/routes.rb later, we have double loaded the routes
113
+ # This is not harmful as such but leads to duplicate routes which decreases performance
114
+ app.routes_reloader.paths.uniq!
115
+ end
116
+
117
+ initializer "#{engine_name}.register_test_paths" do |app|
118
+ app.config.plugins_to_test_paths << self.root
119
+ end
120
+
121
+ # adds our factories to factory girl's load path
122
+ initializer "#{engine_name}.register_factories", :after => "factory_girl.set_factory_paths" do |app|
123
+ FactoryGirl.definition_file_paths << File.expand_path(self.root.to_s + '/spec/factories') if defined?(FactoryGirl)
124
+ end
125
+ end
126
+ end
127
+
128
+ end
129
+ end
@@ -0,0 +1,38 @@
1
+ #-- copyright
2
+ # OpenProject is a project management system.
3
+ #
4
+ # Copyright (C) 2012-2013 the OpenProject Team
5
+ #
6
+ # This program is free software; you can redistribute it and/or
7
+ # modify it under the terms of the GNU General Public License version 3.
8
+ #
9
+ # See doc/COPYRIGHT.md for more details.
10
+ #++
11
+
12
+ require 'rails/engine'
13
+
14
+ module OpenProject::Plugins
15
+ class Engine < ::Rails::Engine
16
+
17
+ engine_name :openproject_plugins
18
+
19
+ require 'open_project/plugins/patch_registry'
20
+ require 'open_project/plugins/load_dependency'
21
+ require 'open_project/plugins/acts_as_op_engine'
22
+
23
+ config.after_initialize do
24
+ spec = Bundler.environment.specs['openproject-plugins'][0]
25
+
26
+ Redmine::Plugin.register :openproject_plugins do
27
+ name 'OpenProject Plugins'
28
+ author ((spec.authors.kind_of? Array) ? spec.authors[0] : spec.authors)
29
+ author_url spec.homepage
30
+ url 'https://www.openproject.org/projects/plugins'
31
+ description spec.description
32
+ version spec.version
33
+
34
+ requires_openproject ">= 3.0.0pre8"
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,24 @@
1
+ #-- copyright
2
+ # OpenProject is a project management system.
3
+ #
4
+ # Copyright (C) 2012-2013 the OpenProject Team
5
+ #
6
+ # This program is free software; you can redistribute it and/or
7
+ # modify it under the terms of the GNU General Public License version 3.
8
+ #
9
+ # See doc/COPYRIGHT.md for more details.
10
+ #++
11
+
12
+ module OpenProject::Plugins
13
+ module LoadDependency
14
+ def self.register(target, *dependencies)
15
+
16
+ ActiveSupport.on_load(target) do
17
+ dependencies.each do |dependency|
18
+ require_dependency dependency
19
+ end
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,33 @@
1
+ #-- copyright
2
+ # OpenProject is a project management system.
3
+ #
4
+ # Copyright (C) 2012-2013 the OpenProject Team
5
+ #
6
+ # This program is free software; you can redistribute it and/or
7
+ # modify it under the terms of the GNU General Public License version 3.
8
+ #
9
+ # See doc/COPYRIGHT.md for more details.
10
+ #++
11
+
12
+ module OpenProject::Plugins
13
+ module PatchRegistry
14
+ def self.register(target, patch)
15
+ #patches[target] << patch
16
+
17
+ ActiveSupport.on_load(target) do
18
+ require_dependency patch
19
+ constant = patch.camelcase.constantize
20
+
21
+ target.to_s.camelcase.constantize.send(:include, constant)
22
+ end
23
+ end
24
+
25
+ protected
26
+
27
+ def self.patches
28
+ @patches ||= Hash.new do |h, k|
29
+ h[k] = []
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,16 @@
1
+ #-- copyright
2
+ # OpenProject is a project management system.
3
+ #
4
+ # Copyright (C) 2012-2013 the OpenProject Team
5
+ #
6
+ # This program is free software; you can redistribute it and/or
7
+ # modify it under the terms of the GNU General Public License version 3.
8
+ #
9
+ # See doc/COPYRIGHT.md for more details.
10
+ #++
11
+
12
+ module OpenProject
13
+ module Plugins
14
+ VERSION = "1.0.2"
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+ #-- copyright
2
+ # OpenProject is a project management system.
3
+ #
4
+ # Copyright (C) 2012-2013 the OpenProject Team
5
+ #
6
+ # This program is free software; you can redistribute it and/or
7
+ # modify it under the terms of the GNU General Public License version 3.
8
+ #
9
+ # See doc/COPYRIGHT.md for more details.
10
+ #++
11
+
12
+ require 'open_project/plugins'
metadata ADDED
@@ -0,0 +1,120 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: openproject-plugins
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Finn GmbH
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 3.2.9
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 3.2.9
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: cucumber-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: database_cleaner
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: |2
70
+ This plugin aims to make writing plugins easier. It provides a generator for creating a
71
+ basic plugin structure and a module that simplifies setting up the plugin Rails engine.
72
+ Thus, it is also a dependency for many openproject plugins.
73
+ email: info@finn.de
74
+ executables: []
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - lib/open_project/plugins.rb
79
+ - lib/open_project/plugins/load_dependency.rb
80
+ - lib/open_project/plugins/version.rb
81
+ - lib/open_project/plugins/engine.rb
82
+ - lib/open_project/plugins/patch_registry.rb
83
+ - lib/open_project/plugins/acts_as_op_engine.rb
84
+ - lib/openproject-plugins.rb
85
+ - lib/generators/open_project/plugin/plugin_generator.rb
86
+ - lib/generators/open_project/plugin/USAGE
87
+ - lib/generators/open_project/plugin/templates/lib/open_project/%plugin_name%/engine.rb.tt
88
+ - lib/generators/open_project/plugin/templates/lib/open_project/%plugin_name%/version.rb.tt
89
+ - lib/generators/open_project/plugin/templates/lib/open_project/%plugin_name%.rb.tt
90
+ - lib/generators/open_project/plugin/templates/lib/%full_name%.rb.tt
91
+ - lib/generators/open_project/plugin/templates/%full_name%.gemspec.tt
92
+ - lib/generators/open_project/plugin/templates/README.md.tt
93
+ - lib/generators/open_project/plugin/templates/CHANGELOG.md
94
+ - README.md
95
+ homepage: http://www.finn.de
96
+ licenses:
97
+ - GPLv3
98
+ metadata: {}
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubyforge_project:
115
+ rubygems_version: 2.1.0
116
+ signing_key:
117
+ specification_version: 4
118
+ summary: OpenProject Plugins Plugin
119
+ test_files: []
120
+ has_rdoc: