vagrant-portinfo 0.0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 571010625ed94d21b5164427eff8565c1129d2a4
4
+ data.tar.gz: 5688da79f06c8790aaef40b6c6a6790bfeb71b84
5
+ SHA512:
6
+ metadata.gz: 15274a005f0d166b53e6d7ad43e1c9d8c594d8db876a1adae61fb58423c331844abfe802e774219fb8c7c13e042b19d90ee56f2a9e76beed54339bb2b4b926a8
7
+ data.tar.gz: 7c40faebfe98bb24641efc25af29373a958cf550d452382ad5d43c5d5b0ea6589a89c9d769cbc52e88e12f4c19e19d1baa36ca694bf1a8745c9bd09a7accf3e1
data/.gitignore ADDED
@@ -0,0 +1,37 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /vendor/bundle
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ Gemfile.lock
31
+ # .ruby-version
32
+ # .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
36
+
37
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "https://rubygems.org"
2
+
3
+ group :development do
4
+ gem "vagrant", git: "https://github.com/mitchellh/vagrant.git"
5
+ end
6
+
7
+ group :plugins do
8
+ gem "vagrant-portinfo", path: "."
9
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 kuboj
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # Vagrant-portinfo
2
+
3
+ Vagrant plugin for displaying forwarded ports. Currently, only VirtualBox provider is supported.
4
+
5
+ ## Installation
6
+
7
+ ```
8
+ $ vagrant plugin install vagrant-portinfo
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```
14
+ $ vagrant portinfo
15
+ ```
16
+
17
+ ## Example
18
+
19
+ ## Contributing
20
+
21
+ 1. Fork it ( https://github.com/[my-github-username]/vagrant-portinfo/fork )
22
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
23
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
24
+ 4. Push to the branch (`git push origin my-new-feature`)
25
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,62 @@
1
+ module Vagrant
2
+ module Portinfo
3
+ class Command < Vagrant.plugin('2', :command)
4
+ def self.synopsis
5
+ "prints information about ports forwarded of a running machine."
6
+ end
7
+
8
+ def execute
9
+ # options = {}
10
+
11
+ opts = OptionParser.new do |o|
12
+ o.banner = "Usage: vagrant portinfo [name]"
13
+ o.separator ''
14
+ end
15
+
16
+ # Parse the options
17
+ argv = parse_options(opts)
18
+ return if !argv
19
+
20
+ with_target_vms(argv, reverse: true) { |m| print_ports(m) }
21
+ end
22
+
23
+ private
24
+ def print_ports(machine)
25
+ @env.ui.info("#{machine.name} (#{machine.index_uuid[0..6]})")
26
+ @env.ui.info("-" * 80)
27
+
28
+ unless machine.provider_name == :virtualbox
29
+ print_unknown
30
+ return
31
+ end
32
+
33
+ out = Vagrant::Util::Subprocess.execute("vboxmanage", "showvminfo", machine.id)
34
+
35
+ unless out.exit_code.zero?
36
+ print_unknown
37
+ return
38
+ end
39
+
40
+ parse_vminfo(out.stdout).each do |i|
41
+ @env.ui.info("guest: #{i[:guest_port]}\thost: #{i[:host_port]}")
42
+ end
43
+ end
44
+
45
+ def print_unknown
46
+ @env.ui.info("<UNKNOWN>")
47
+ end
48
+
49
+ def parse_vminfo(s)
50
+ out = []
51
+ s.lines.select { |l| l =~ /guest port/ }.each do |l|
52
+ out << {
53
+ :host_port => l[/host\ port\ =\ \d*/, 0][/\d+/].to_i,
54
+ :guest_port => l[/guest\ port\ =\ \d*/, 0][/\d+/].to_i
55
+ }
56
+ end
57
+
58
+ out
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,15 @@
1
+ require "vagrant"
2
+
3
+ module Vagrant
4
+ module Portinfo
5
+ class Plugin < Vagrant.plugin("2")
6
+ name "vagrant-portinfo"
7
+ description "The `portinfo` command provides information about forwarded ports."
8
+
9
+ command "portinfo" do
10
+ require_relative "command"
11
+ Command
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ module Vagrant
2
+ module Portinfo
3
+ VERSION = "0.0.4"
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ require "vagrant"
2
+ require "vagrant/util/subprocess"
3
+ require "vagrant-portinfo/version"
4
+ require "vagrant-portinfo/plugin"
5
+ require "vagrant-portinfo/errors"
6
+
7
+ module Vagrant
8
+ module Portinfo
9
+ # Your code goes here...
10
+ end
11
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-portinfo/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-portinfo"
8
+ spec.version = Vagrant::Portinfo::VERSION
9
+ spec.authors = ["Jakub Jursa"]
10
+ spec.email = ["jju@rsd.com"]
11
+ spec.summary = %q{Vagrant plugin for displaying forwarded ports}
12
+ spec.description = %q{Vagrant plugin for displaying forwarded ports}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-portinfo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Jakub Jursa
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Vagrant plugin for displaying forwarded ports
42
+ email:
43
+ - jju@rsd.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE
51
+ - README.md
52
+ - Rakefile
53
+ - lib/vagrant-portinfo.rb
54
+ - lib/vagrant-portinfo/command.rb
55
+ - lib/vagrant-portinfo/plugin.rb
56
+ - lib/vagrant-portinfo/version.rb
57
+ - vagrant-portinfo.gemspec
58
+ homepage: ''
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.4.6
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Vagrant plugin for displaying forwarded ports
82
+ test_files: []