vagrant-butcher 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,19 +10,18 @@ module Vagrant
10
10
 
11
11
  def initialize(app, env)
12
12
  @app = app
13
- @env = env
14
13
  end
15
14
 
16
- def victim
17
- @victim ||= chef_provisioner(@env).node_name || vm_config(@env).hostname || vm_config(@env).box
15
+ def victim(env)
16
+ @victim ||= chef_provisioner(env).node_name || vm_config(env).hostname || vm_config(env).box
18
17
  end
19
18
 
20
- def delete_resource(resource)
19
+ def delete_resource(resource, env)
21
20
  begin
22
- chef_api(@env).delete_rest("#{resource}s/#{victim}")
23
- @env[:butcher].ui.success "Chef #{resource} '#{victim}' successfully butchered from the server..."
21
+ chef_api(env).delete_rest("#{resource}s/#{victim(env)}")
22
+ env[:butcher].ui.success "Chef #{resource} '#{victim(env)}' successfully butchered from the server..."
24
23
  rescue Exception => e
25
- @env[:butcher].ui.warn "Could not remove #{resource} #{victim}: #{e.message}"
24
+ env[:butcher].ui.warn "Could not remove #{resource} #{victim(env)}: #{e.message}"
26
25
  end
27
26
  end
28
27
 
@@ -34,7 +33,7 @@ module Vagrant
34
33
  raise ::Vagrant::Butcher::VagrantWrapperError.new(e)
35
34
  end
36
35
 
37
- %w(node client).each { |resource| delete_resource(resource) }
36
+ %w(node client).each { |resource| delete_resource(resource, env) }
38
37
  end
39
38
 
40
39
  @app.call(env)
@@ -4,7 +4,11 @@ module Vagrant
4
4
  attr_accessor :ui
5
5
 
6
6
  def initialize
7
- @ui = ::Vagrant::UI::Colored.new('Butcher')
7
+ if Gem::Version.new(::Vagrant::VERSION) >= Gem::Version.new("1.2")
8
+ @ui = ::Vagrant::UI::Colored.new.scope('Butcher')
9
+ else
10
+ @ui = ::Vagrant::UI::Colored.new('Butcher')
11
+ end
8
12
  end
9
13
  end
10
14
  end
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module Butcher
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper.rb'
2
+
3
+ describe Vagrant::Butcher::Env do
4
+ subject { described_class.new }
5
+
6
+ it "is a valid Vagrant UI object" do
7
+ subject.ui.should be_a Vagrant::UI::BasicScope
8
+ end
9
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-butcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-01 00:00:00.000000000 Z
12
+ date: 2013-04-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chef
@@ -99,6 +99,7 @@ files:
99
99
  - lib/vagrant-butcher/version.rb
100
100
  - spec/spec_helper.rb
101
101
  - spec/unit/vagrant_butcher/config_spec.rb
102
+ - spec/unit/vagrant_butcher/env_spec.rb
102
103
  - spec/unit/vagrant_butcher_spec.rb
103
104
  - vagrant-butcher.gemspec
104
105
  homepage: https://github.com/cassianoleal/vagrant-butcher
@@ -130,4 +131,5 @@ summary: When a Vagrant VM that was spun up using Chef-Client is destroyed, it l
130
131
  test_files:
131
132
  - spec/spec_helper.rb
132
133
  - spec/unit/vagrant_butcher/config_spec.rb
134
+ - spec/unit/vagrant_butcher/env_spec.rb
133
135
  - spec/unit/vagrant_butcher_spec.rb