Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
OHR Support
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
97
Issues
97
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
OHR Support
Commits
1796fddd
Commit
1796fddd
authored
Mar 13, 2011
by
Holger Just
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[
#275
] Add requires_chiliproject. We now use the rubygems dependency syntax.
parent
8f4439e0
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
1 deletion
+51
-1
plugin.rb
lib/redmine/plugin.rb
+28
-1
plugin_test.rb
test/unit/lib/redmine/plugin_test.rb
+23
-0
No files found.
lib/redmine/plugin.rb
View file @
1796fddd
...
...
@@ -101,9 +101,36 @@ module Redmine #:nodoc:
self
.
id
.
to_s
<=>
plugin
.
id
.
to_s
end
# Sets a requirement on Redmine version
# Sets a requirement on the ChiliProject version.
# Raises a PluginRequirementError exception if the requirement is not met.
#
# It uses the same syntax as rubygems requirements.
# Examples
# # Requires exactly ChiliProject 1.1.1
# requires_chiliproject "1.1.1"
# requires_chiliproject "= 1.1.1"
# # Requires ChiliProject 1.1.x
# requires_chiliproject "~> 1.1.0"
# # Requires ChiliProject between 1.1.0 and 1.1.5 or higher
# requires_chiliproject ">= 1.1.0", "<= 1.1.5"
def
requires_chiliproject
(
*
args
)
required_version
=
Gem
::
Requirement
.
new
(
*
args
)
chili_version
=
Gem
::
Version
.
new
(
Redmine
::
VERSION
.
to_semver
)
unless
required_version
.
satisfied_by?
chili_version
raise
PluginRequirementError
.
new
(
"
#{
id
}
plugin requires ChiliProject version
#{
required_version
}
but current version is
#{
chili_version
}
."
)
end
true
end
# Sets a requirement on Redmine version.
# Raises a PluginRequirementError exception if the requirement is not met
#
# THIS IS A REDMINE COMPATIBILITY INTERFACE
#
# Examples
# # Requires Redmine 0.7.3 or higher
# requires_redmine :version_or_higher => '0.7.3'
...
...
test/unit/lib/redmine/plugin_test.rb
View file @
1796fddd
...
...
@@ -71,6 +71,29 @@ class Redmine::PluginTest < ActiveSupport::TestCase
end
end
def
test_requires_chiliproject
test
=
self
version
=
Redmine
::
VERSION
.
to_semver
@klass
.
register
:foo
do
test
.
assert
requires_chiliproject
(
'>= 0.1'
)
test
.
assert
requires_chiliproject
(
">=
#{
version
}
"
)
test
.
assert
requires_chiliproject
(
version
)
test
.
assert_raise
Redmine
::
PluginRequirementError
do
requires_chiliproject
(
'>= 99.0.0'
)
end
test
.
assert_raise
Redmine
::
PluginRequirementError
do
requires_chiliproject
(
'< 0.9'
)
end
requires_chiliproject
(
'> 0.9'
,
"<= 99.0.0"
)
test
.
assert_raise
Redmine
::
PluginRequirementError
do
requires_chiliproject
(
'< 0.9'
,
">= 98.0.0"
)
end
test
.
assert
requires_chiliproject
(
"~>
#{
Redmine
::
VERSION
.
to_semver
.
gsub
(
/\d+$/
,
'0'
)
}
"
)
end
end
def
test_requires_redmine_plugin
test
=
self
other_version
=
'0.5.0'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment