vagrant-protect 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in vagrant-chefnode.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Ryutaro YOSHIBA
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # vagrant-protect
2
+
3
+ This gemfile enables you to protect vagrant box from destroying.
4
+
5
+ ## Installation
6
+
7
+ execute:
8
+
9
+ vagrant plugin install 'vagrant-protect'
10
+
11
+ ## Usage
12
+
13
+ If you would like to protect your VM from destroying, please add the configuration as follows to your Vagrantfile
14
+
15
+ config.protect.enabled = true
16
+
17
+
18
+ ## Contributing
19
+
20
+ 1. Fork it
21
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
22
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
23
+ 4. Push to the branch (`git push origin my-new-feature`)
24
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # vim: set fileencoding=utf-8
3
+
4
+ require "vagrant"
5
+ require "vagrant-protect/command"
6
+
7
+ module VagrantProtect
8
+ class Plugin < Vagrant.plugin("2")
9
+ name "protect"
10
+ description <<-DESC
11
+ Protect vagrant instance from destroying
12
+ DESC
13
+
14
+ config 'protect' do
15
+ require File.expand_path("../vagrant-protect/config", __FILE__)
16
+ Config
17
+ end
18
+
19
+ action_hook(self::ALL_ACTIONS) do |hook|
20
+ hook.before(VagrantPlugins::ProviderVirtualBox::Action::Destroy, VagrantProtect::Command)
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,20 @@
1
+ # coding: utf-8
2
+ # vim: set fileencoding=utf-8
3
+
4
+ module VagrantProtect
5
+ class Command
6
+
7
+ def initialize(app, env)
8
+ @app = app
9
+ @env = env
10
+ end
11
+
12
+ def call(env)
13
+ if env[:machine].config.protect.enabled
14
+ env[:ui].info "Only executed shutdown because destroy command is disabled"
15
+ return
16
+ end
17
+ @app.call(env)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,15 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # vim: set fileencoding=utf-8
3
+
4
+ require 'vagrant'
5
+
6
+ module VagrantProtect
7
+ class Config < Vagrant.plugin(2, :config)
8
+ attr_accessor :enabled
9
+
10
+ def initialize
11
+ @enabled = false
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,8 @@
1
+ # -*- encoding: utf-8 -*-
2
+ # vim: set fileencoding=utf-8
3
+
4
+ module Vagrant
5
+ module Protect
6
+ VERSION = "0.0.1"
7
+ end
8
+ end
@@ -0,0 +1,21 @@
1
+ # coding: utf-8
2
+ require File.expand_path('../lib/vagrant-protect/version', __FILE__)
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "vagrant-protect"
6
+ spec.version = Vagrant::Protect::VERSION
7
+ spec.authors = ["Ryutaro YOSHIBA"]
8
+ spec.email = ["ryuzee@gmail.com"]
9
+ spec.description = %q{Protect vagrant instance from destroying}
10
+ spec.summary = %q{Protect vagrant instance from destroying}
11
+ spec.homepage = ""
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files`.split("\n")
15
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_development_dependency "bundler", "~> 1.3"
20
+ spec.add_development_dependency "rake"
21
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-protect
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ryutaro YOSHIBA
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-09-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Protect vagrant instance from destroying
47
+ email:
48
+ - ryuzee@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - LICENSE.txt
56
+ - README.md
57
+ - Rakefile
58
+ - lib/vagrant-protect.rb
59
+ - lib/vagrant-protect/command.rb
60
+ - lib/vagrant-protect/config.rb
61
+ - lib/vagrant-protect/version.rb
62
+ - vagrant-protect.gemspec
63
+ homepage: ''
64
+ licenses:
65
+ - MIT
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 1.8.23
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: Protect vagrant instance from destroying
88
+ test_files: []