vagrant-plugins 0.1.0
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/.gitignore +17 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +40 -0
- data/Rakefile +2 -0
- data/lib/vagrant-plugins.rb +14 -0
- data/lib/vagrant-plugins/command.rb +44 -0
- data/lib/vagrant-plugins/helper.rb +15 -0
- data/lib/vagrant-plugins/ui.rb +63 -0
- data/lib/vagrant-plugins/version.rb +3 -0
- data/vagrant-plugins.gemspec +19 -0
- metadata +74 -0
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Robert Schulze
|
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,40 @@
|
|
1
|
+
vagrant-plugins
|
2
|
+
===============
|
3
|
+
|
4
|
+
A vagrant plugin to list active vagrant plugins.
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
If you use the gem version of Vagrant, use:
|
11
|
+
|
12
|
+
```bash
|
13
|
+
$ gem install vagrant-dns
|
14
|
+
```
|
15
|
+
|
16
|
+
otherwise, use:
|
17
|
+
|
18
|
+
```bash
|
19
|
+
$ vagrant gem install vagrant-dns
|
20
|
+
```
|
21
|
+
|
22
|
+
And add this line to your `.vagrantrc` or `Vagrantfile`:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
Vagrant.require_plugin 'vagrant-plugins'
|
26
|
+
```
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
```bash
|
31
|
+
$ vagrant plugins
|
32
|
+
```
|
33
|
+
|
34
|
+
## Contributing
|
35
|
+
|
36
|
+
1. Fork it
|
37
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
38
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
39
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
40
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'vagrant'
|
2
|
+
require "vagrant-plugins/version"
|
3
|
+
require "vagrant-plugins/helper"
|
4
|
+
require "vagrant-plugins/ui"
|
5
|
+
require "vagrant-plugins/command"
|
6
|
+
|
7
|
+
module VagrantPlugininspection
|
8
|
+
class Plugin < Vagrant.plugin("1")
|
9
|
+
name "plugins"
|
10
|
+
description "List all vagrant plugins loaded in the current vagrant environment"
|
11
|
+
|
12
|
+
command('plugins') { Command }
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
|
3
|
+
module VagrantPlugininspection
|
4
|
+
class Command < Vagrant::Command::Base
|
5
|
+
|
6
|
+
def execute
|
7
|
+
options = {}
|
8
|
+
opts = OptionParser.new do |opts|
|
9
|
+
opts.banner = "Usage: vagrant plugins"
|
10
|
+
opts.separator ""
|
11
|
+
|
12
|
+
opts.on("-a", "--all", "List builtin vagrant plugins as well.") do
|
13
|
+
options[:all] = true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
argv = parse_options(opts)
|
18
|
+
return if !argv
|
19
|
+
|
20
|
+
ui = VagrantPlugininspection::UI::Columnized.new('plugins')
|
21
|
+
|
22
|
+
if Vagrant.plugin("1").registered.empty?
|
23
|
+
ui.info "No plugins registered"
|
24
|
+
else
|
25
|
+
|
26
|
+
builtins = VagrantPlugins.constants.map { |p|
|
27
|
+
VagrantPlugininspection::Inflector::constantize("VagrantPlugins::#{p}::Plugin")
|
28
|
+
} if !options[:all]
|
29
|
+
|
30
|
+
plugins = Vagrant.plugin("1").registered.map { |plugin|
|
31
|
+
if options[:all] || !builtins.include?(plugin)
|
32
|
+
{
|
33
|
+
:name => plugin.name,
|
34
|
+
:description => plugin.description
|
35
|
+
}
|
36
|
+
end
|
37
|
+
}.compact
|
38
|
+
|
39
|
+
ui.print_columns plugins, :column_order => [:name, :description]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module VagrantPlugininspection
|
2
|
+
module Inflector
|
3
|
+
# gracefully stolen from ActiveSupport::Inflector
|
4
|
+
def self.constantize(camel_cased_word)
|
5
|
+
names = camel_cased_word.split('::')
|
6
|
+
names.shift if names.empty? || names.first.empty?
|
7
|
+
|
8
|
+
constant = Object
|
9
|
+
names.each do |name|
|
10
|
+
constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
|
11
|
+
end
|
12
|
+
constant
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module VagrantPlugininspection
|
2
|
+
module UI
|
3
|
+
class Columnized < Vagrant::UI::Colored
|
4
|
+
|
5
|
+
def say(type, message, opts=nil)
|
6
|
+
defaults = { :new_line => true, :prefix => true }
|
7
|
+
opts = defaults.merge(opts || {})
|
8
|
+
super
|
9
|
+
end
|
10
|
+
|
11
|
+
def print_columns(data, opts=nil)
|
12
|
+
defaults = { :prefix => false }
|
13
|
+
opts = defaults.merge(opts ||= {})
|
14
|
+
|
15
|
+
columns = opts.delete(:column_order)
|
16
|
+
|
17
|
+
data = clean(data, opts)
|
18
|
+
size = sizes(data)
|
19
|
+
|
20
|
+
table_head = columnize_row(columns.zip(columns), size, columns) + "\n"
|
21
|
+
table_head << (table_head.gsub(/[^\t]/, '-')) + "\n"
|
22
|
+
table_body = data.map { |line| columnize_row(line, size, columns) }.join("\n")
|
23
|
+
|
24
|
+
say :info, table_head << table_body, opts
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
|
29
|
+
BOOL_MAP = {
|
30
|
+
true => '*',
|
31
|
+
false => '',
|
32
|
+
nil => ''
|
33
|
+
}
|
34
|
+
|
35
|
+
def clean(data, opts=nil)
|
36
|
+
data.map{|line|
|
37
|
+
Hash[line.map{ |col|
|
38
|
+
col[1] = BOOL_MAP[col[1]] || col[1].to_s.strip.gsub(/^\s+|\s+$/, '').gsub(/\n|\r/,' ')
|
39
|
+
col
|
40
|
+
}]
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
def sizes(data)
|
45
|
+
s = {}
|
46
|
+
data.each { |line|
|
47
|
+
line.each_pair { |key, value|
|
48
|
+
s[key] = [key.length, value.length, (s[key] || 0)].max
|
49
|
+
}
|
50
|
+
}
|
51
|
+
s
|
52
|
+
end
|
53
|
+
|
54
|
+
def columnize_row(row, size, columns=nil)
|
55
|
+
data = Hash[row.map { |key, value|
|
56
|
+
[key, "%-#{size[key]}s" % [value]]
|
57
|
+
}]
|
58
|
+
|
59
|
+
(columns ? columns.map { |col| data[col] } : data.values).join("\t")
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/vagrant-plugins/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Robert Schulze"]
|
6
|
+
gem.email = ["robert@dotless.de"]
|
7
|
+
gem.description = %q{vagrant-plugins is a vagrant plugin to list all vagrant plugins loaded in the current vagrant environment}
|
8
|
+
gem.summary = %q{vagrant-plugins lists active vagrant plugins}
|
9
|
+
gem.homepage = "https://github.com/dotless-de/vagrant-plugins"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "vagrant-plugins"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = VagrantPlugininspection::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency "vagrant", ">= 1.1.0.dev"
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-plugins
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Robert Schulze
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-15 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: vagrant
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.1.0.dev
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.1.0.dev
|
30
|
+
description: vagrant-plugins is a vagrant plugin to list all vagrant plugins loaded
|
31
|
+
in the current vagrant environment
|
32
|
+
email:
|
33
|
+
- robert@dotless.de
|
34
|
+
executables: []
|
35
|
+
extensions: []
|
36
|
+
extra_rdoc_files: []
|
37
|
+
files:
|
38
|
+
- .gitignore
|
39
|
+
- CHANGELOG.md
|
40
|
+
- Gemfile
|
41
|
+
- LICENSE
|
42
|
+
- README.md
|
43
|
+
- Rakefile
|
44
|
+
- lib/vagrant-plugins.rb
|
45
|
+
- lib/vagrant-plugins/command.rb
|
46
|
+
- lib/vagrant-plugins/helper.rb
|
47
|
+
- lib/vagrant-plugins/ui.rb
|
48
|
+
- lib/vagrant-plugins/version.rb
|
49
|
+
- vagrant-plugins.gemspec
|
50
|
+
homepage: https://github.com/dotless-de/vagrant-plugins
|
51
|
+
licenses: []
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 1.8.24
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: vagrant-plugins lists active vagrant plugins
|
74
|
+
test_files: []
|