vagrant-winscp-sync 0.0.1.dev

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.vagrant
19
+ *.iml
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ # We depend on Vagrant for development, but we don't add it as a
7
+ # gem dependency because we expect to be installed within the
8
+ # Vagrant environment itself using `vagrant plugin`.
9
+ gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git"
10
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Dave Keen
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.
@@ -0,0 +1,29 @@
1
+ # Vagrant::Winscp::Sync
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'vagrant-winscp-sync'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install vagrant-winscp-sync
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,9 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ # Immediately sync all stdout so that tools like buildbot can
5
+ # immediately load in the output.
6
+ $stdout.sync = true
7
+ $stderr.sync = true
8
+
9
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,61 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant.require_plugin "vagrant-winscp-sync"
5
+
6
+ ipaddress = "10.0.0.21"
7
+
8
+ Vagrant.configure("2") do |config|
9
+ # Every Vagrant virtual environment requires a box to build off of.
10
+ config.vm.box = "precise64"
11
+
12
+ # The url from where the 'config.vm.box' box will be fetched if it
13
+ # doesn't already exist on the user's system.
14
+ config.vm.box_url = "http://files.vagrantup.com/precise64.box"
15
+
16
+ # Create a forwarded port mapping which allows access to a specific port
17
+ # within the machine from a port on the host machine. In the example below,
18
+ # accessing "localhost:8080" will access port 80 on the guest machine.
19
+ #config.vm.network :forwarded_port, guest: 80, host: 8080
20
+
21
+ # Create a private network, which allows host-only access to the machine
22
+ # using a specific IP.
23
+ config.vm.network :private_network, ip: ipaddress
24
+
25
+ # Create a public network, which generally matched to bridged network.
26
+ # Bridged networks make the machine appear as another physical device on
27
+ # your network.
28
+ # config.vm.network :public_network
29
+
30
+ # Share an additional folder to the guest VM. The first argument is
31
+ # the path on the host to the actual folder. The second argument is
32
+ # the path on the guest to mount the folder. And the optional third
33
+ # argument is a set of non-required options.
34
+ # config.vm.synced_folder "../data", "/vagrant_data"
35
+ config.vm.synced_folder ".", "/vagrant", disabled: true
36
+
37
+ # Provider-specific configuration so you can fine-tune various
38
+ # backing providers for Vagrant. These expose provider-specific options.
39
+ # Example for VirtualBox:
40
+ #
41
+ config.vm.provider :virtualbox do |vb|
42
+ # # Don't boot with headless mode
43
+ # vb.gui = true
44
+ #
45
+ # Use VBoxManage to customize the VM. For example to change memory:
46
+ # vb.customize ["modifyvm", :id, "--memory", "2048"]
47
+ end
48
+ #
49
+ # View the documentation for the provider you're using for more
50
+ # information on available options.
51
+
52
+ # Enable provisioning with chef solo, specifying a cookbooks path, roles
53
+ # path, and data_bags path (all relative to this Vagrantfile), and adding
54
+ # some recipes and/or roles.
55
+ config.vm.provision :winscp_sync do |winscp|
56
+ winscp.session = "platypus_vagrant"
57
+ winscp.remote_dir = "/home/vagrant/platypus"
58
+ winscp.file_mask = "|.git/;.vagrant/;.idea/;*/app/cache/;*/app/logs/;*/chef/"
59
+ end
60
+
61
+ end
@@ -0,0 +1,18 @@
1
+ require "pathname"
2
+
3
+ require "vagrant-winscp-sync/plugin"
4
+
5
+ module VagrantPlugins
6
+ module WinSCP
7
+ #lib_path = Pathname.new(File.expand_path("../vagrant-winscp-sync", __FILE__))
8
+ #autoload :Action, lib_path.join("action")
9
+ #autoload :Errors, lib_path.join("errors")
10
+
11
+ # This returns the path to the source of this plugin.
12
+ #
13
+ # @return [Pathname]
14
+ def self.source_root
15
+ @source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,32 @@
1
+ module VagrantPlugins
2
+ module WinSCP
3
+ module Config
4
+ class Sync < Vagrant.plugin("2", :config)
5
+ attr_accessor :session
6
+ attr_accessor :local_dir
7
+ attr_accessor :remote_dir
8
+ attr_accessor :file_mask
9
+
10
+ def initialize
11
+ super
12
+ @session = UNSET_VALUE
13
+ @local_dir = UNSET_VALUE
14
+ @remote_dir = UNSET_VALUE
15
+ @file_mask = UNSET_VALUE
16
+ end
17
+
18
+ def finalize!
19
+ @local_dir = Dir.pwd if @local_dir == UNSET_VALUE
20
+ @file_mask = "*" if @local_dir == UNSET_VALUE
21
+ end
22
+
23
+ def validate(machine)
24
+ return { "session" => ["The WinSCP session must be set"] } if (@session == UNSET_VALUE)
25
+ return { "remote_dir" => ["The remote dir must be set"] } if (@remote_dir == UNSET_VALUE)
26
+ return {}
27
+ end
28
+
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,27 @@
1
+ begin
2
+ require "vagrant"
3
+ rescue LoadError
4
+ raise "The Vagrant WinSCP sync plugin must be run within Vagrant."
5
+ end
6
+
7
+ if Vagrant::VERSION < "1.2.0"
8
+ raise "The Vagrant AWS plugin is only compatible with Vagrant 1.2+"
9
+ end
10
+
11
+ module VagrantPlugins
12
+ module WinSCP
13
+ class Plugin < Vagrant.plugin("2")
14
+ name "WinSCP"
15
+
16
+ config(:winscp_sync, :provisioner) do
17
+ require File.expand_path("../config/sync", __FILE__)
18
+ Config::Sync
19
+ end
20
+
21
+ provisioner(:winscp_sync) do
22
+ require File.expand_path("../provisioner/sync", __FILE__)
23
+ Provisioner::Sync
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,80 @@
1
+ require 'open3'
2
+
3
+ module VagrantPlugins
4
+ module WinSCP
5
+ module Provisioner
6
+ class Sync < Vagrant.plugin("2", :provisioner)
7
+
8
+ # Initializes the provisioner with the machine that it will be
9
+ # provisioning along with the provisioner configuration (if there
10
+ # is any).
11
+ #
12
+ # The provisioner should _not_ do anything at this point except
13
+ # initialize internal state.
14
+ #
15
+ # @param [Machine] machine The machine that this will be provisioning.
16
+ # @param [Object] config Provisioner configuration, if one was set.
17
+ def initialize(machine, config)
18
+ super
19
+ end
20
+
21
+ # Called with the root configuration of the machine so the provisioner
22
+ # can add some configuration on top of the machine.
23
+ #
24
+ # During this step, and this step only, the provisioner should modify
25
+ # the root machine configuration to add any additional features it
26
+ # may need. Examples include sharing folders, networking, and so on.
27
+ # This step is guaranteed to be called before any of those steps are
28
+ # done so the provisioner may do that.
29
+ #
30
+ # No return value is expected.
31
+ def configure(root_config)
32
+
33
+ end
34
+
35
+ # This is the method called when the actual provisioning should be
36
+ # done. The communicator is guaranteed to be ready at this point,
37
+ # and any shared folders or networks are already setup.
38
+ #
39
+ # No return value is expected.
40
+ def provision
41
+ session = @config.session
42
+ local_dir = @config.local_dir
43
+ remote_dir = @config.remote_dir
44
+ file_mask = @config.file_mask
45
+
46
+ open_command = "open \"\"#{session}\"\""
47
+ sync_command = "synchronize remote \"\"#{local_dir}\"\" \"\"#{remote_dir}\"\" -filemask=\"\"#{file_mask}\"\" "
48
+
49
+ run_cmd [ "\"C:\\Program Files (x86)\\WinSCP\\winscp.com\" /console /command \"#{open_command}\" \"#{sync_command}\" " ]
50
+
51
+ u2d_command = "keepuptodate \"\"#{local_dir}\"\" \"\"#{remote_dir}\"\" -filemask=\"\"#{file_mask}\"\" "
52
+ Process.spawn "\"C:\\Program Files (x86)\\WinSCP\\winscp.com\" /console /command \"#{open_command}\" \"#{u2d_command}\" "
53
+ end
54
+
55
+ def run_cmd(cmd)
56
+ @machine.ui.info "running: #{cmd.join ' '}"
57
+ Open3.popen3(*cmd) do |stdin, stdout, stderr, wait_thread|
58
+ stdin.close
59
+ readers = [stdout, stderr]
60
+ while not readers.empty?
61
+ rs, = IO.select(readers)
62
+ break if rs.empty?
63
+ rs.each do |r|
64
+ begin
65
+ got = r.readpartial(1024)
66
+ out = (r == stdout) ? $stdout : $stderr
67
+ out.print got
68
+ rescue EOFError
69
+ readers.delete_if { |s| r == s }
70
+ end
71
+ end
72
+ end
73
+ wait_thread.value.success?
74
+ end
75
+ end
76
+
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module WinSCP
3
+ VERSION = "0.0.1.dev"
4
+ end
5
+ 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-winscp-sync/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-winscp-sync"
8
+ spec.version = VagrantPlugins::WinSCP::VERSION
9
+ spec.authors = ["Dave Keen"]
10
+ spec.email = []
11
+ spec.description = %q{A Vagrant plugin for syncing files on Windows via WinSCP instead of shared folders}
12
+ spec.summary = %q{A Vagrant plugin for syncing files on Windows via WinSCP instead of shared folders}
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
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-winscp-sync
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.dev
5
+ prerelease: 6
6
+ platform: ruby
7
+ authors:
8
+ - Dave Keen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-12 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: A Vagrant plugin for syncing files on Windows via WinSCP instead of shared
47
+ folders
48
+ email: []
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - Gemfile
55
+ - LICENSE.txt
56
+ - README.md
57
+ - Rakefile
58
+ - Vagrantfile
59
+ - lib/vagrant-winscp-sync.rb
60
+ - lib/vagrant-winscp-sync/config/sync.rb
61
+ - lib/vagrant-winscp-sync/plugin.rb
62
+ - lib/vagrant-winscp-sync/provisioner/sync.rb
63
+ - lib/vagrant-winscp-sync/version.rb
64
+ - vagrant-winscp-sync.gemspec
65
+ homepage: ''
66
+ licenses:
67
+ - MIT
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ segments:
79
+ - 0
80
+ hash: 793044369
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ! '>'
85
+ - !ruby/object:Gem::Version
86
+ version: 1.3.1
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 1.8.24
90
+ signing_key:
91
+ specification_version: 3
92
+ summary: A Vagrant plugin for syncing files on Windows via WinSCP instead of shared
93
+ folders
94
+ test_files: []