capistrano-karaf 1.2.3 → 1.2.4

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.
Files changed (2) hide show
  1. data/lib/capistrano-karaf.rb +59 -9
  2. metadata +1 -1
@@ -1,6 +1,7 @@
1
1
  require 'sshkit'
2
2
 
3
3
  SSHKit.config.command_map[:features_addurl] = 'features:addurl'
4
+ SSHKit.config.command_map[:features_listurl] = 'features:listurl'
4
5
  SSHKit.config.command_map[:features_removeurl] = 'features:removeurl'
5
6
  SSHKit.config.command_map[:features_refreshurl] = 'features:refreshurl'
6
7
  SSHKit.config.command_map[:features_install] = 'features:install'
@@ -17,6 +18,14 @@ def add_url (url)
17
18
  execute(:features_addurl, url)
18
19
  end
19
20
 
21
+
22
+ def remove_artifact_urls (groupID, artifactID)
23
+ urlsToRemove=list_urls.select {|url| url['groupID']==groupID&&url['artifactID']==artifactID}
24
+ urlsToRemove.each do |url|
25
+ remove_url ("mvn:#{url["groupID"]}/#{url["artifactID"]}/#{url["version"]}/xml/features")
26
+ end
27
+ end
28
+
20
29
  def remove_url (url)
21
30
  execute(:features_removeurl, url)
22
31
  end
@@ -29,8 +38,16 @@ def feature_install (name)
29
38
  execute(:features_install, name)
30
39
  end
31
40
 
41
+ def feature_uninstall_safe (name)
42
+ if (feature_installed? (name))
43
+ execute(:features_uninstall, name)
44
+ else
45
+ puts "features:#{name} is not installed so does not need to uninstall it"
46
+ end
47
+ end
48
+
32
49
  def feature_uninstall (name)
33
- execute(:features_uninstall, name)
50
+ execute(:features_uninstall, name)
34
51
  end
35
52
 
36
53
  def log_set (level)
@@ -50,6 +67,40 @@ def fragment_bundle? (bundleId)
50
67
  headers.lines.any? {|l| l.match('^Fragment-Host.*')}
51
68
  end
52
69
 
70
+ def break_listing (matcher,data)
71
+ breaklist = []
72
+ data.lines.each do |line|
73
+ m = matcher.match(line)
74
+ if m then
75
+ breaklist.push(m)
76
+ end
77
+ end
78
+ breaklist.collect {|m| Hash[m.names.zip(m.captures)]}
79
+ end
80
+
81
+ def list_urls ()
82
+ url_line_matcher = %r{
83
+ (?<status> \w+){0}
84
+ (?<groupID> [\d\w\.\-]+){0}
85
+ (?<artifactID> [\w\.\-]+){0}
86
+ (?<version> [\w\.\-]+){0}
87
+ \s*\g<status>\s*mvn\:\g<groupID>\/\g<artifactID>\/\g<version>.*
88
+ }x
89
+ data=capture(:features_listurl)
90
+ break_listing url_line_matcher,data
91
+ end
92
+
93
+ def list_features ()
94
+ feature_line_matcher = %r{
95
+ (?<status> \w+){0}
96
+ (?<version> [\d\w\-\.\s]+){0}
97
+ (?<name> [\w\-\:]+){0}
98
+ (?<repository> [\w\-\s\:\.]+){0}
99
+ ^\[\s*\g<status>\s*\]\s\[\s*\g<version>\s*\]\s*\g<name>\s*\g<repository>}x
100
+ data=capture(:features_list)
101
+ break_listing feature_line_matcher,data
102
+ end
103
+
53
104
  def list_bundles ()
54
105
  bundle_line_matcher = %r{(?<id> \d+){0}
55
106
  (?<status> \w+){0}
@@ -63,14 +114,8 @@ def list_bundles ()
63
114
  }x
64
115
 
65
116
  data = capture(:list)
66
- bundles = []
67
- data.lines.each do |line|
68
- m = bundle_line_matcher.match(line)
69
- if m then
70
- bundles.push(m)
71
- end
72
- end
73
- bundles.collect {|m| Hash[m.names.zip(m.captures)]}
117
+
118
+ break_listing bundle_line_matcher,data
74
119
  end
75
120
 
76
121
  def wait_for_all_bundles (timeout = 5, sleeptime = 1, &pred)
@@ -82,6 +127,11 @@ def wait_for_all_bundles (timeout = 5, sleeptime = 1, &pred)
82
127
  end
83
128
  end
84
129
 
130
+ def feature_installed? (name)
131
+ feature=list_features.find {|f| f['name']==name}
132
+ feature['status']=='installed' unless feature.nil?
133
+ end
134
+
85
135
  def wait_for_bundle (timeout = 5, sleeptime = 1, &pred)
86
136
  timeout1 = Time.now + timeout
87
137
 
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.2.3
4
+ version: 1.2.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: