vagrant-rsync-pick 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f995ff084ec2f492472a6c28c40ae8c99bc35773
4
- data.tar.gz: 4aad87822f8ae4f12c28649d1a9b1cb6d35c38e2
3
+ metadata.gz: f1301b662d505e51841b60af3387b67cb21af4d7
4
+ data.tar.gz: b0a1f1fdffda9a7c6ff785928cd7474e6467e472
5
5
  SHA512:
6
- metadata.gz: fb1650dc33f28f935055904c1543a4817f43a25661fec8d9dcd787ab0577d986dfb9d0917fec1a446fc7ad40848c20e5824fce6a9bc1b4f6199afd91bad44aef
7
- data.tar.gz: 3a5520f1a8d5b32878a9115b78dc2e698032bcc55b5c950cda1892652276867c1a8cefa3ff2552b19a4954fc33ddd453456e0328796c29e6e14371eb6c84ce48
6
+ metadata.gz: 2c5af10decb98626e2959ed697c9829cc3b1251f9c8a39c6039606903ce44f6507301313a93d9cf7eee951c1d83323bad2b532abbf6f5c3c4f3c085d1d674bda
7
+ data.tar.gz: 97c3ef8a8e331254d2a82e6f80a7740498c8a9e73c19af1024e86eba520450e5951b4a7422cb8d1e4595abab8085cc5fdfde479b8807334f67d86837a6f98fbc
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
13
+ Vagrantfile
14
+ *log
15
+ *gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2.3
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.15.0
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in vagrant_rsync_pick.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem "vagrant", git: "https://github.com/mitchellh/vagrant.git"
8
+ end
9
+
10
+ # group :plugins do
11
+ # gem "vagrant-rsync-pick", path: "."
12
+ # end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Zinovyev Ivan
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.
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Ivan Zinovyev
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
13
+ all 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
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # vagrant-rsync-pick
2
+
3
+ The plugin allows you to pick atomic changes from the guest machine folder via rsync.
4
+
5
+ The `rsync` shared folder type is much faster (10x times maybe)
6
+ than nfs/virtualbox/smb and others.
7
+
8
+ But it has one huge disadvantage: it isn't possible to sync data
9
+ in a bidirectional way at all. So when you generate a new migration
10
+ or rake task for example your changes are kept on your guest machine only.
11
+
12
+ ## Installation
13
+
14
+ $ vagrant plugin install vagrant-rsync-pick
15
+
16
+ And then configure your guest directory (where the files are taken from)
17
+ and your host directory (where the files are stored to):
18
+
19
+ ```ruby
20
+ config.rsync_pick.guest_dir = "/var/www/my-app"
21
+ config.rsync_pick.host_dir = Dir.pwd
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ Execute this command so the file(s) is(are) rsynced to you host folder:
27
+
28
+ $ vagrant rpick db/migrate/20100825634193_create_table.rb
29
+
30
+ ## Contributing
31
+
32
+ Bug reports and pull requests are welcome on GitHub at https://github.com/zinovyev/vagrant_rsync_pick. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
33
+
34
+ ## License
35
+
36
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
37
+
38
+ ## Code of Conduct
39
+
40
+ Everyone interacting in the VagrantRsyncPick project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/vagrant_rsync_pick/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,110 @@
1
+ require "vagrant"
2
+
3
+ module VagrantPlugins
4
+ module RsyncPick
5
+ class Command < ::Vagrant.plugin("2", :command)
6
+ attr_reader :argv, :opts
7
+
8
+ class << self
9
+ def synopsis
10
+ "picks atomic changes from the guest machine folder via rsync"
11
+ end
12
+ end
13
+
14
+ def initialize(argv, env)
15
+ super
16
+ init_options
17
+ end
18
+
19
+ def execute
20
+ raise_errors
21
+ p command
22
+ system command
23
+ end
24
+
25
+ private
26
+
27
+ def raise_errors
28
+ unless file_path
29
+ raise ::Vagrant::Errors::VagrantError.new,
30
+ "Argument file_name is required"
31
+ end
32
+
33
+ unless ssh_info
34
+ raise ::Vagrant::Errors::VagrantError.new,
35
+ "Run vagrant up first to start the box"
36
+ end
37
+
38
+ config_errors = config.validate(machine)
39
+ if config_errors && config_errors[Config::SECTION_NAME]
40
+ raise ::Vagrant::Errors::VagrantError.new,
41
+ config_errors[Config::SECTION_NAME].compact
42
+ end
43
+ end
44
+
45
+ def command
46
+ [
47
+ "rsync",
48
+ "-rzav",
49
+ "-e",
50
+ "\"#{ssh_options}\"",
51
+ guest_path,
52
+ host_path
53
+ ].join(" ")
54
+ end
55
+
56
+ def ssh_options
57
+ "ssh -i #{ssh_info[:private_key_path].first} -p #{ssh_info[:port]}"
58
+ end
59
+
60
+ def guest_path
61
+ File.join(
62
+ "#{ssh_info[:username]}@#{ssh_info[:host]}:#{guest_dir}",
63
+ file_path
64
+ )
65
+ end
66
+
67
+ def host_path
68
+ File.join(host_dir, file_path)
69
+ end
70
+
71
+ def file_path
72
+ @argv[0]
73
+ end
74
+
75
+ def init_options
76
+ opts = OptionParser.new do |o|
77
+ o.banner = "Usage: vagrant rsync-pick relative/file/path"
78
+ end
79
+ parse_options(opts)
80
+ end
81
+
82
+ def host_dir
83
+ config.send(Config::SECTION_NAME).host_dir || @env.root_path
84
+ end
85
+
86
+ def guest_dir
87
+ config.send(Config::SECTION_NAME).guest_dir || "/"
88
+ end
89
+
90
+ def config
91
+ return machine.config
92
+ end
93
+
94
+ def ssh_info
95
+ return machine.ssh_info
96
+ end
97
+
98
+ def machine
99
+ @machine ||= fetch_machine
100
+ end
101
+
102
+ def fetch_machine
103
+ machine_name = @env.primary_machine_name.to_s
104
+ with_target_vms([machine_name], single_target: true) do |machine|
105
+ return machine
106
+ end
107
+ end
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,29 @@
1
+ module VagrantPlugins
2
+ module RsyncPick
3
+ class Config < Vagrant.plugin(2, :config)
4
+ SECTION_NAME = "rsync_pick"
5
+
6
+ attr_accessor :guest_dir, :host_dir
7
+
8
+ def initialize
9
+ # @guest_dir = UNSET_VALUE
10
+ # @host_dir = UNSET_VALUE
11
+ end
12
+
13
+ def validate(machine)
14
+ errors = _detected_errors
15
+ unless @guest_dir
16
+ errors << "Config value rsync_pick.guest_dir is required"
17
+ # errors << I18n.t("vagrant_rsync_pick.validation.guest_dir_required")
18
+ end
19
+
20
+ unless @host_dir
21
+ errors << "Config value rsync_pick.host_dir is required"
22
+ # errors << I18n.t("vagrant_rsync_pick.validation.host_dir_required")
23
+ end
24
+
25
+ { SECTION_NAME => errors }
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,20 @@
1
+ require 'vagrant'
2
+
3
+ module VagrantPlugins
4
+ module RsyncPick
5
+ class Plugin < ::Vagrant.plugin("2")
6
+ name "rsync-pick"
7
+ description "Picks atomic changes from the guest machine folder via rsync"
8
+
9
+ config "rsync_pick" do
10
+ require_relative "config"
11
+ Config
12
+ end
13
+
14
+ command "rpick" do
15
+ require_relative "command"
16
+ Command
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module RsyncPick
3
+ VERSION = "0.2.0"
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require_relative "vagrant-rsync-pick/version"
2
+ require_relative "vagrant-rsync-pick/plugin"
3
+
4
+ module VagrantPlugins
5
+ module RsyncPick
6
+ end
7
+ end
data/locales/en.yml ADDED
@@ -0,0 +1,7 @@
1
+ en:
2
+ vagrant_rsync_pick:
3
+ validation:
4
+ file_required: "File name is required"
5
+ guest_dir_required: "Config value rsync_pick.guest_dir is required"
6
+ host_dir_required: "Config value rsync_pick.host_dir is required"
7
+
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ require_relative "lib/vagrant-rsync-pick/version"
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "vagrant-rsync-pick"
6
+ spec.version = VagrantPlugins::RsyncPick::VERSION
7
+ spec.authors = ["Ivan Zinovyev"]
8
+ spec.email = ["vanyazin@gmail.com"]
9
+
10
+ spec.summary = "Pick atomic changes from guest machine with rsync"
11
+ spec.homepage = "https://github.com/zinovyev/vagrant-rsync-pick"
12
+ spec.license = "MIT"
13
+
14
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
15
+ f.match(%r{^(test|spec|features|testdrive)/})
16
+ end
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.15"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "rspec", "~> 3.0"
24
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-rsync-pick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Zinovyev
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2017-06-29 00:00:00.000000000 Z
11
+ date: 2017-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,7 +58,23 @@ email:
58
58
  executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
- files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".ruby-version"
65
+ - ".travis.yml"
66
+ - Gemfile
67
+ - LICENSE
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - lib/vagrant-rsync-pick.rb
72
+ - lib/vagrant-rsync-pick/command.rb
73
+ - lib/vagrant-rsync-pick/config.rb
74
+ - lib/vagrant-rsync-pick/plugin.rb
75
+ - lib/vagrant-rsync-pick/version.rb
76
+ - locales/en.yml
77
+ - vagrant-rsync-pick.gemspec
62
78
  homepage: https://github.com/zinovyev/vagrant-rsync-pick
63
79
  licenses:
64
80
  - MIT