vagrant-camera 0.0.1
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 +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +44 -0
- data/Rakefile +1 -0
- data/lib/vagrant/camera.rb +15 -0
- data/lib/vagrant/camera/command.rb +82 -0
- data/lib/vagrant/camera/version.rb +5 -0
- data/vagrant-camera.gemspec +24 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c81df67d12a15b817e8cf106043e712612a4f504
|
4
|
+
data.tar.gz: 9cfcc308cec962a92d950454190c4fb33e6e04c0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 93b4af0b731d8e96b0bcd88cfefc1fd69240eb3151d09e99058a45abcc2ac36b1246044ddec32d054d6615155d4edfe5456260b336fa0d7afe8d072905f80de3
|
7
|
+
data.tar.gz: 219715fc460b541026d57c62d7f418318da9e78322f61062fc6ebd68966203389ca36946281dc9fc5a612f229b59e0240258509589e6a0d4d994f6b6a2355bd1
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Kelly Becker, CLDRDR Inc
|
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,44 @@
|
|
1
|
+
# Vagrant::Camera
|
2
|
+
|
3
|
+
Takes screenshots of your Vagrant VMs.
|
4
|
+
|
5
|
+
Inspired by [latortuga/vagrant-screenshot](https://github.com/latortuga/vagrant-screenshot)
|
6
|
+
|
7
|
+
## Dependencies
|
8
|
+
|
9
|
+
- Virtual Box Provider and VM
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Install them gem
|
14
|
+
|
15
|
+
$ gem install vagrant-camera
|
16
|
+
|
17
|
+
Add this line to your application's Vagrantfile:
|
18
|
+
|
19
|
+
require 'vagrant/camera'
|
20
|
+
|
21
|
+
Or install as a global vagrant plugin
|
22
|
+
|
23
|
+
$ vagrant plugin install vagrant-camera
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Usage: vagrant camera [vm-name] [options] [-h]
|
28
|
+
-o, --open Open generated image after capture
|
29
|
+
-s, --save PATH Save images to a specific directory.
|
30
|
+
-h, --help Print this help
|
31
|
+
|
32
|
+
## Contributing
|
33
|
+
|
34
|
+
1. Fork it
|
35
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
36
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
37
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
38
|
+
5. Create new Pull Request
|
39
|
+
|
40
|
+
## Licensing
|
41
|
+
|
42
|
+
Copyright (c) 2013 Kelly Becker, CLDRDR Inc
|
43
|
+
|
44
|
+
MIT License, see LICENSE.txt for more details.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'tmpdir'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module Vagrant
|
5
|
+
module Camera
|
6
|
+
class Command < Vagrant.plugin("2", :command)
|
7
|
+
|
8
|
+
def execute
|
9
|
+
@options = {}
|
10
|
+
@screenshots = []
|
11
|
+
|
12
|
+
opts = OptionParser.new do |o|
|
13
|
+
o.banner = "Usage: vagrant camera [vm-name] [options] [-h]"
|
14
|
+
|
15
|
+
if open?
|
16
|
+
o.on("-o", "--open", "Open generated image after capture") do |c|
|
17
|
+
@options[:open] = true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
o.on("-s PATH", "--save", "Save images to a specific directory.") do |c|
|
22
|
+
@options[:save_location] = c
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
@argv = parse_options(opts)
|
27
|
+
return if !@argv
|
28
|
+
|
29
|
+
capture_screens
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def open?
|
35
|
+
!%x{which open}.chomp.to_s.empty?
|
36
|
+
end
|
37
|
+
|
38
|
+
def capture_screens
|
39
|
+
with_target_vms(@argv[0]) do |vm|
|
40
|
+
|
41
|
+
unless vm.provider.to_s.include?("VirtualBox")
|
42
|
+
@env.ui.send :error, "Cannot capture screenshot, we can only capture screenshots on virtualbox instances."
|
43
|
+
return
|
44
|
+
end
|
45
|
+
|
46
|
+
if vm.state.id != :running
|
47
|
+
@env.ui.send :warn, "Skipping #{vm.name} because it's not running."
|
48
|
+
else
|
49
|
+
@env.ui.send :info, "Capturing screenshot of #{vm.name}"
|
50
|
+
|
51
|
+
filename = File.join(Dir.tmpdir, "screenshot_#{vm.name}_#{Time.now.to_i}.png")
|
52
|
+
|
53
|
+
vm.provider.driver.execute_command [
|
54
|
+
"controlvm",
|
55
|
+
vm.provider.driver.uuid,
|
56
|
+
"screenshotpng",
|
57
|
+
filename
|
58
|
+
]
|
59
|
+
|
60
|
+
@env.ui.send :success, "Screenshot saved at #{filename}"
|
61
|
+
@screenshots << filename
|
62
|
+
|
63
|
+
%x{open #{@screenshots.join(' ')}} if @options[:open]
|
64
|
+
|
65
|
+
unless @options[:save_location].nil?
|
66
|
+
@screenshots.each do |file|
|
67
|
+
new_file = File.join(@options[:save_location], File.basename(file))
|
68
|
+
|
69
|
+
begin
|
70
|
+
FileUtils.copy(file, new_file)
|
71
|
+
@env.ui.send :success, "#{file} -> #{new_file}"
|
72
|
+
rescue => e
|
73
|
+
@env.ui.send(:error, e.message)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vagrant/camera/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "vagrant-camera"
|
8
|
+
spec.version = Vagrant::Camera::VERSION
|
9
|
+
spec.authors = ["Kelly Becker"]
|
10
|
+
spec.email = ["kellylsbkr@gmail.com"]
|
11
|
+
spec.description = %q{Takes screenshots of a VM}
|
12
|
+
spec.summary = %q{Takes screenshots of a VM}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
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.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_dependency "vagrant"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vagrant-camera
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Kelly Becker
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-07 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.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: vagrant
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Takes screenshots of a VM
|
56
|
+
email:
|
57
|
+
- kellylsbkr@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/vagrant/camera.rb
|
68
|
+
- lib/vagrant/camera/command.rb
|
69
|
+
- lib/vagrant/camera/version.rb
|
70
|
+
- vagrant-camera.gemspec
|
71
|
+
homepage: ''
|
72
|
+
licenses:
|
73
|
+
- MIT
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project:
|
91
|
+
rubygems_version: 2.0.3
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: Takes screenshots of a VM
|
95
|
+
test_files: []
|