torquespec 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,16 +21,25 @@ module TorqueSpec
21
21
 
22
22
  def _deploy(path)
23
23
  url = urlify(path)
24
- domain_api( :operation => "add",
25
- :address => [ "deployment", url ],
26
- :url => url )
27
- domain_api( :operation => "deploy",
28
- :address => [ "deployment", url ] )
24
+ response = JSON.parse( domain_api( :operation => "add",
25
+ :address => [ "deployment", url ],
26
+ :url => url ) )
27
+ if response['outcome']=='success'
28
+ deployments[path] = response['compensating-operation']
29
+ domain_api( :operation => "deploy",
30
+ :address => [ "deployment", url ] )
31
+ else
32
+ response.to_json
33
+ end
29
34
  end
30
35
 
31
36
  def _undeploy(path)
32
- domain_api( :operation => "remove",
33
- :address => [ "deployment", urlify(path) ] )
37
+ if deployments.has_key?(path)
38
+ domain_api( deployments.delete(path) )
39
+ else
40
+ domain_api( :operation => "remove",
41
+ :address => [ "deployment", urlify(path) ] )
42
+ end
34
43
  end
35
44
 
36
45
  def ready?
@@ -41,6 +50,10 @@ module TorqueSpec
41
50
  false
42
51
  end
43
52
 
53
+ def cleanup
54
+ deployments.keys.each { |k| domain_api( deployments.delete(k) ) }
55
+ end
56
+
44
57
  private
45
58
 
46
59
  def domain_api(params)
@@ -51,5 +64,8 @@ module TorqueSpec
51
64
  URI.parse(path).scheme.nil? ? "file:#{path}" : path
52
65
  end
53
66
 
67
+ def deployments
68
+ @deployments ||= {}
69
+ end
54
70
  end
55
71
  end
@@ -26,6 +26,7 @@ module TorqueSpec
26
26
  end
27
27
 
28
28
  def stop
29
+ cleanup
29
30
  return if stopped
30
31
  self.stopped = true
31
32
  if TorqueSpec.lazy
@@ -38,14 +39,14 @@ module TorqueSpec
38
39
 
39
40
  def deploy(url)
40
41
  t0 = Time.now
41
- puts "#{url}"
42
+ puts " deploying #{url}"
42
43
  _deploy(url)
43
- puts " deployed in #{(Time.now - t0).to_i}s"
44
+ puts " deployed #{url} in #{(Time.now - t0).to_i}s"
44
45
  end
45
46
 
46
47
  def undeploy(url)
47
48
  _undeploy(url)
48
- puts " undeployed #{url.split('/')[-1]}"
49
+ puts " removed #{url}"
49
50
  end
50
51
 
51
52
  def wait_for_ready(timeout)
@@ -61,6 +62,10 @@ module TorqueSpec
61
62
  raise "JBoss failed to start"
62
63
  end
63
64
 
65
+ def cleanup
66
+ # modules may mixin if needed
67
+ end
68
+
64
69
  protected
65
70
 
66
71
  def startup(opts)
@@ -1,3 +1,3 @@
1
1
  module TorqueSpec
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: torquespec
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jim Crossley
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-05-16 00:00:00 -04:00
19
+ date: 2011-05-17 00:00:00 -04:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency