capistrano-karaf 1.3.1 → 1.4.0
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.
- data/lib/capistrano-karaf/core.rb +1 -1
- data/lib/capistrano-karaf/install.rb +58 -0
- data/lib/capistrano-karaf/semver.rb +70 -0
- metadata +3 -1
@@ -0,0 +1,58 @@
|
|
1
|
+
# Functions for installing / upgrading software on a karaf machine
|
2
|
+
|
3
|
+
require 'capistrano-karaf/core'
|
4
|
+
require 'capistrano-karaf/extended'
|
5
|
+
require 'capistrano-karaf/semver'
|
6
|
+
|
7
|
+
module Capistrano_Karaf
|
8
|
+
include Semantic_Versions
|
9
|
+
|
10
|
+
# Upgrade a list of projects in karaf
|
11
|
+
#
|
12
|
+
# projects - a list of hashes containing:
|
13
|
+
# - :feature_url - the string containing the feature url
|
14
|
+
# - :feature - the string containing the feature name to upgrade
|
15
|
+
# - :version - the string containing the version
|
16
|
+
# - :action - specifies when to upgrade the feature, one of [ :lt, :eq, :gt ]
|
17
|
+
#
|
18
|
+
# Examples
|
19
|
+
# upgrade([{:feature_url => "mvn:repository/featurea/xml/features/1.1.0",
|
20
|
+
# :feature => "featurea",
|
21
|
+
# :version => "1.1.0",
|
22
|
+
# :action => gt
|
23
|
+
# },
|
24
|
+
# {:feature_url => "mvn:repository/featureb/xml/features/1.2.0",
|
25
|
+
# :feature => "featureb",
|
26
|
+
# :version => "1.2.0",
|
27
|
+
# :action => gt
|
28
|
+
# }])
|
29
|
+
# # => nil
|
30
|
+
#
|
31
|
+
# Returns nothing
|
32
|
+
def upgrade (projects)
|
33
|
+
features = list_features()
|
34
|
+
projects.each do |project|
|
35
|
+
install_new_feature = true
|
36
|
+
installed_features = find_installed_with_name(features, project[:feature])
|
37
|
+
|
38
|
+
p = method(project[:action])
|
39
|
+
installed_features.each do |f|
|
40
|
+
if p.call(f["version"], project[:version])
|
41
|
+
feature_uninstall("#{project[:feature]}/#{f['version']}")
|
42
|
+
else
|
43
|
+
install_new_feature = false
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
if install_new_feature
|
48
|
+
add_url(project[:feature_url])
|
49
|
+
feature_install(project[:feature])
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
def find_installed_with_name (features, name)
|
56
|
+
features.select {|f| f["name"] == name and f["status"] == "installed"}
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# Functions for semantic versions
|
2
|
+
|
3
|
+
module Semantic_Versions
|
4
|
+
# Verify if the provided version is greater than the installed version
|
5
|
+
#
|
6
|
+
# Parameters
|
7
|
+
# - installed - a string containing the installed version
|
8
|
+
# - provided - a string containging the provided version
|
9
|
+
#
|
10
|
+
# Example
|
11
|
+
# gt("2.18.0", "2.19.0")
|
12
|
+
# # returns true
|
13
|
+
#
|
14
|
+
# Returns a boolean which is true if the provided is greater than the installed
|
15
|
+
def gt (installed, provided)
|
16
|
+
compare(installed, provided) == :gt
|
17
|
+
end
|
18
|
+
|
19
|
+
# Verify if the provided version is less than the installed version
|
20
|
+
#
|
21
|
+
# Parameters
|
22
|
+
# - installed - a string containing the installed version
|
23
|
+
# - provided - a string containging the provided version
|
24
|
+
#
|
25
|
+
# Example
|
26
|
+
# lt("2.18.0", "2.19.0")
|
27
|
+
# # returns false
|
28
|
+
#
|
29
|
+
# Returns a boolean which is true if the provided is less than the installed
|
30
|
+
def lt (installed, provided)
|
31
|
+
compare(installed, provided) == :lt
|
32
|
+
end
|
33
|
+
|
34
|
+
# Verify if the provided version is equal to the installed version
|
35
|
+
#
|
36
|
+
# Parameters
|
37
|
+
# - installed - a string containing the installed version
|
38
|
+
# - provided - a string containging the provided version
|
39
|
+
#
|
40
|
+
# Example
|
41
|
+
# eq("2.18.0", "2.19.0")
|
42
|
+
# # returns false
|
43
|
+
#
|
44
|
+
# Returns a boolean which is true if the provided is equal to the installed
|
45
|
+
def eq (installed, provided)
|
46
|
+
compare(installed, provided) == :eq
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
def compare (installed, provided)
|
51
|
+
installed_parts = installed.split('.')
|
52
|
+
provided_parts = provided.split('.')
|
53
|
+
|
54
|
+
installed_parts.zip(provided_parts).each do |versions|
|
55
|
+
inst, prov = versions
|
56
|
+
|
57
|
+
if inst.nil? then
|
58
|
+
return :gt
|
59
|
+
elsif prov.nil? then
|
60
|
+
return :lt
|
61
|
+
elsif inst < prov then
|
62
|
+
return :gt
|
63
|
+
elsif inst > prov then
|
64
|
+
return :lt
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
:eq
|
69
|
+
end
|
70
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-karaf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -20,6 +20,8 @@ files:
|
|
20
20
|
- lib/capistrano-karaf.rb
|
21
21
|
- lib/capistrano-karaf/core.rb
|
22
22
|
- lib/capistrano-karaf/extended.rb
|
23
|
+
- lib/capistrano-karaf/semver.rb
|
24
|
+
- lib/capistrano-karaf/install.rb
|
23
25
|
homepage: http://github.com/bhoflack/capistrano-karaf
|
24
26
|
licenses:
|
25
27
|
- bsd
|