Skip to content

Commit 20f5719

Browse files
committed
Add validation to avoid this plugin from being installed on ruby < 1.9.0 && rails < 3.0.0 && redmine < 2.1.0 (Relates #1)
1 parent c06ed47 commit 20f5719

File tree

2 files changed

+41
-10
lines changed

2 files changed

+41
-10
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@ __Features__:
1212
* Adds a task which allows the cronjob to fetch emails from all active email configurations.
1313
* Allows a configuration to be inactivated to stop its emails synchronisation with Redmine.
1414

15+
__Restrictions__:
16+
17+
* The plugin requires a Ruby version equal or higher than 1.9.x.
18+
* The plugin requires a Rails version equal or higher than 3.x.x.
19+
* The plugin requires a Redmine version equal or higher than 2.1.0.
20+
1521
__Remarks__:
1622

17-
* The plugin is prepared and intended to run with any IMAP and POP3 email account, however
23+
* The plugin is prepared and intended to run with any IMAP and POP3 email account, however
1824
some issues can accur due to security certificates.
1925
* When using SSL, please check that the machine has the proper certificates installed
2026
by running the following terminal commands:

init.rb

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,38 @@
11
require 'redmine'
22
require 'email_configurations_hooks'
33

4-
Redmine::Plugin.register :redmine_email_fetcher do
5-
name 'Redmine Email Fetcher plugin'
6-
author 'Luis Maia'
7-
description 'This plugin allow us to configure several IMAP and POP3 email accounts from where emails can be fetch to Redmine'
8-
version '0.0.1'
9-
url 'https://github.com/luismaia/redmine_email_fetcher'
10-
author_url 'https://github.com/luismaia'
11-
12-
menu :admin_menu, :email_configurations, {controller: 'email_configurations', action: 'index'}, caption: :title_email_configurations
4+
if RUBY_VERSION < '1.9'
5+
ruby_version_error = '*** error redmine_email_fetcher: This plugin (redmine_email_fetcher) was not installed, '\
6+
'since it requires a Ruby version equal or higher than 1.9 (and your Ruby version '\
7+
"is #{RUBY_VERSION})"
8+
9+
# Rails.logger.error ruby_version_error
10+
puts ruby_version_error
11+
12+
elsif Rails::VERSION::MAJOR < 3
13+
rails_version_error = '*** error redmine_email_fetcher: This plugin (redmine_email_fetcher) was not installed, '\
14+
'since it requires a Rails version equal or higher than 3 (and your Rails version '\
15+
"is #{Rails::VERSION::MAJOR})"
16+
17+
# Rails.logger.error rails_version_error
18+
puts rails_version_error
19+
20+
else
21+
Redmine::Plugin.register :redmine_email_fetcher do
22+
name 'Redmine Email Fetcher plugin'
23+
author 'Luis Maia'
24+
description 'This plugin allows the configuration of several IMAP and POP3 email accounts'\
25+
'from where emails can be fetch into Redmine'
26+
version '0.0.2'
27+
url 'https://github.com/luismaia/redmine_email_fetcher'
28+
author_url 'https://github.com/luismaia'
29+
requires_redmine version_or_higher: '2.1.0'
30+
31+
menu :admin_menu,
32+
:email_configurations,
33+
{ controller: 'email_configurations', action: 'index' },
34+
caption: :title_email_configurations
35+
end
36+
37+
# puts 'This plugin works with the current Ruby, Rails and Redmine versions'
1338
end

0 commit comments

Comments
 (0)