capistrano-karaf 1.4.4 → 1.4.5
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/install.rb +39 -4
- metadata +1 -1
@@ -17,12 +17,28 @@ module Install
|
|
17
17
|
# - :feature - the string containing the feature name to upgrade
|
18
18
|
# - :version - the string containing the version
|
19
19
|
# - :condition - specifies when to upgrade the feature, one of [ :lt, :eq, :gt ( the default ) ]
|
20
|
+
# - :hooks - a map containing the hook name and the list of methods to trigger
|
21
|
+
# trigger can be one of :before_upgrade_feature,
|
22
|
+
# :before_uninstall_feature,
|
23
|
+
# :after_uninstall_feature,
|
24
|
+
# :before_install_feature,
|
25
|
+
# :after_install_feature,
|
26
|
+
# :after_upgrade_feature
|
27
|
+
#
|
20
28
|
# or:
|
21
29
|
# - :groupId - the string containing the groupId of the repository
|
22
30
|
# - :repository - the string containing the name of the feature repository
|
23
31
|
# - :feature - the string containing the name of the feature
|
24
32
|
# - :version - the string containing the version or :latest
|
25
33
|
# - :condition - specifies when to upgrade the feature, one of [ :lt, :eq, :gt ( the default ) ]
|
34
|
+
# - :hooks - a map containing the hook name and the list of methods to trigger
|
35
|
+
# trigger can be one of :before_upgrade_feature,
|
36
|
+
# :before_uninstall_feature,
|
37
|
+
# :after_uninstall_feature,
|
38
|
+
# :before_install_feature,
|
39
|
+
# :after_install_feature,
|
40
|
+
# :after_upgrade_feature
|
41
|
+
#
|
26
42
|
# Examples
|
27
43
|
# upgrade([{:feature_url => "mvn:repository/featurea/xml/features/1.1.0",
|
28
44
|
# :feature => "featurea",
|
@@ -46,13 +62,14 @@ module Install
|
|
46
62
|
def upgrade (projects)
|
47
63
|
features = list_features()
|
48
64
|
projects.each do |project|
|
49
|
-
project = {:condition => :gt
|
65
|
+
project = {:condition => :gt,
|
66
|
+
:hooks => {}}.merge(project)
|
50
67
|
|
51
68
|
install_new_feature = true
|
52
69
|
installed_features = find_installed_with_name(features, project[:feature])
|
53
70
|
|
54
71
|
if project.keys.include? :groupId then
|
55
|
-
fh = create_feature_hash(project[:groupId], project[:repository], project[:feature], project[:version], project[:condition])
|
72
|
+
fh = create_feature_hash(project[:groupId], project[:repository], project[:feature], project[:version], project[:condition], project[:hooks])
|
56
73
|
upgrade_feature(installed_features, fh)
|
57
74
|
else
|
58
75
|
upgrade_feature(installed_features, project)
|
@@ -92,8 +109,11 @@ module Install
|
|
92
109
|
p = method(feature[:condition])
|
93
110
|
|
94
111
|
installed_features.each do |f|
|
112
|
+
trigger_event(feature, :before_upgrade_feature)
|
95
113
|
if p.call(f["version"], feature[:version])
|
114
|
+
trigger_event(feature, :before_uninstall_feature)
|
96
115
|
feature_uninstall("#{feature[:feature]}/#{f['version']}")
|
116
|
+
trigger_event(feature, :after_uninstall_feature)
|
97
117
|
else
|
98
118
|
install_new_feature = false
|
99
119
|
end
|
@@ -101,11 +121,25 @@ module Install
|
|
101
121
|
|
102
122
|
if install_new_feature
|
103
123
|
add_url(feature[:feature_url])
|
124
|
+
trigger_event(feature, :before_install_feature)
|
104
125
|
feature_install(feature[:feature])
|
126
|
+
trigger_event(feature, :after_install_feature)
|
127
|
+
end
|
128
|
+
trigger_event(feature, :after_upgrade_feature)
|
129
|
+
end
|
130
|
+
|
131
|
+
def trigger_event (feature, event)
|
132
|
+
feature[:hooks].fetch(event, []).each do |h|
|
133
|
+
if h.is_a? Proc
|
134
|
+
h.call()
|
135
|
+
elsif h.is_a? Symbol
|
136
|
+
proc = method(h)
|
137
|
+
proc.call()
|
138
|
+
end
|
105
139
|
end
|
106
140
|
end
|
107
141
|
|
108
|
-
def create_feature_hash(groupId, repository, feature, version, condition)
|
142
|
+
def create_feature_hash(groupId, repository, feature, version, condition, hooks)
|
109
143
|
version1 = nil
|
110
144
|
if version == :latest then
|
111
145
|
version1 = extract_latest_version(latest_snapshot_version(groupId, repository))
|
@@ -118,7 +152,8 @@ module Install
|
|
118
152
|
{:feature_url => featureUrl,
|
119
153
|
:feature => feature,
|
120
154
|
:version => version1,
|
121
|
-
:condition => condition
|
155
|
+
:condition => condition,
|
156
|
+
:hooks => hooks
|
122
157
|
}
|
123
158
|
end
|
124
159
|
end
|