vagrant-hanewin-nfs 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 86eaa089c16acff0deda7577fd1eecdbbe7ff9a1
4
+ data.tar.gz: 8029c4504075cb41dbbde665540e6a563fadece6
5
+ SHA512:
6
+ metadata.gz: 2691d09c321f290557ab6ac7e7b820c2ce7e35ff064052eb88326a12b3b0be5bbfeb0cf646ec8e1dd3b6a7dbb95a1b99feb3debf076cc0464aa4a0f52ae376da
7
+ data.tar.gz: 0a40d401e5d1f637a8b4ba7b16925be19bae294be82b189e48ff6314b9b44bf72f9b4be1d71d465d5d242a21c625484b3ceb932ca743041c02553086427b6540
@@ -0,0 +1,13 @@
1
+ # RubyMine
2
+ .idea
3
+
4
+ # Bundler/Rubygems
5
+ *.gem
6
+ .bundle
7
+ pkg/*
8
+ tags
9
+ Gemfile.lock
10
+
11
+ # Vagrant
12
+ .vagrant
13
+ Vagrantfile
@@ -0,0 +1,46 @@
1
+ CHANGELOG
2
+ =========
3
+
4
+ 1.0.5
5
+ -----
6
+
7
+ Match vagrant documentation for activating nfs
8
+
9
+
10
+ 1.0.4
11
+ -----
12
+
13
+ Improve batch file
14
+ Update readme
15
+ Update WinNFSd
16
+
17
+
18
+ 1.0.3
19
+ -----
20
+
21
+ Move nfspaths file to .vagrant dir
22
+
23
+
24
+ 1.0.2
25
+ -----
26
+
27
+ 2013-12-18
28
+
29
+ Improve setting up of the firewall rules
30
+
31
+
32
+ 1.0.1
33
+ -----
34
+
35
+ 2013-12-18
36
+
37
+ Fix batch file
38
+ Easy setup for the firewall rules
39
+
40
+
41
+ 1.0.0
42
+ -----
43
+
44
+ 2013-12-12
45
+
46
+ First release
data/Gemfile ADDED
@@ -0,0 +1,12 @@
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", :tag => "v1.5.1"
10
+ gem "rspec"
11
+ gem "rake"
12
+ end
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2013 Alexander Schneider - Jankowfsky AG
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,34 @@
1
+ # Vagrant Hanewin NFS
2
+
3
+ Manage and adds support for NFS on windows.
4
+
5
+ ## Supported Platforms
6
+
7
+ Only tested with Vagrant 1.5.0 or later
8
+
9
+ Supported guests:
10
+
11
+ * Linux
12
+
13
+ ## Installation
14
+
15
+ ```
16
+ $ vagrant plugin install vagrant-hanewin-nfs
17
+ ```
18
+
19
+ ## Hanewin NFS
20
+
21
+ You need to install Hanewin NFS Server to use this plugin. Hanewin NFS is
22
+ shareware and can be evaluated for 30 days.D
23
+
24
+ You can get it here:
25
+
26
+ http://www.hanewin.de/nfs-d.htm
27
+
28
+
29
+ ## Thanks to
30
+
31
+ * @GM-Alex [vagrant-winnfsd](https://github.com/GM-Alex/vagrant-winnfsd) idea and basic structure of this plugin.
32
+
33
+
34
+
@@ -0,0 +1,17 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'rspec/core/rake_task'
4
+
5
+ # Immediately sync all stdout so that tools like buildbot can
6
+ # immediately load in the output.
7
+ $stdout.sync = true
8
+ $stderr.sync = true
9
+
10
+ # This installs the tasks that help with gem creation and
11
+ # publishing.
12
+ Bundler::GemHelper.install_tasks
13
+
14
+ # Install the `spec` task so that we can run tests.
15
+ # Spec needs ruby >= 2.0
16
+ RSpec::Core::RakeTask.new
17
+
@@ -0,0 +1,18 @@
1
+ module VagrantPlugins
2
+ module VagrantHanewinNfs
3
+ require 'vagrant-hanewin-nfs/version'
4
+ require 'vagrant-hanewin-nfs/plugin'
5
+
6
+ def self.source_root
7
+ @source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
8
+ end
9
+
10
+ def self.get_nfs_dir
11
+ Pathname.new("C:/Program Files/nfsd/")
12
+ end
13
+
14
+ def self.get_nfs_path(file)
15
+ get_nfs_dir.join(file)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,107 @@
1
+ require 'vagrant-hanewin-nfs'
2
+ require 'vagrant-hanewin-nfs/windows_service'
3
+
4
+ module VagrantPlugins
5
+ module VagrantHanewinNfs
6
+ module Cap
7
+ class NFS
8
+ def self.nfs_config_file_path
9
+ VagrantHanewinNfs.get_nfs_dir.join('exports')
10
+ end
11
+
12
+ def self.logger
13
+ Log4r::Logger.new("vagrant::hosts::windows::nfs")
14
+ end
15
+
16
+ def self.service_name
17
+ "NFSserver"
18
+ end
19
+
20
+ def self.nfs_export(env, ui, id, ips, folders)
21
+ # Get some values we need before we do anything
22
+
23
+ output = ""
24
+
25
+ folders.each do |folder, opts|
26
+ if opts[:nfs] = true
27
+ # Build config
28
+ ips.each do |ip|
29
+ output += "%s -mapall:1000:1000 %s ##VAGRANT#%s#\n" % [opts[:hostpath].gsub('/', '\\'),ip,id]
30
+ end
31
+
32
+ # Rewrite path for mount
33
+ drive=opts[:hostpath][0].downcase
34
+ opts[:hostpath] = "/#{drive}/#{opts[:hostpath][3..-1]}"
35
+
36
+ # Add mountoptions
37
+ opts[:mount_options] = ['vers=3','udp','nolock']
38
+
39
+ end
40
+
41
+ # Remove entries with id
42
+ nfs_cleanup(id)
43
+
44
+ # Append to config
45
+ logger.info("Write nfs exports")
46
+ open(nfs_config_file_path, 'a') do |f|
47
+ f.write output
48
+ f.flush
49
+ f.close
50
+ end
51
+
52
+ # restart nfs
53
+ logger.info("Restart nfs")
54
+ nfs_apply_command = env.host.capability(:nfs_apply_command)
55
+ end
56
+ end
57
+
58
+ def self.nfs_installed(env)
59
+ true
60
+ end
61
+
62
+ def self.nfs_cleanup(id)
63
+ return if !File.exist?(nfs_config_file_path)
64
+
65
+ #id_re = Regexp.escape(id.to_s)
66
+
67
+ output = ""
68
+
69
+ # read per line
70
+ open(nfs_config_file_path, 'r').each do |line|
71
+ match = line.scan(/##VAGRANT#([^#]*)#/)
72
+ if match.length > 0
73
+ next if match[0][0] == id.to_s
74
+ end
75
+ output += line
76
+ end
77
+
78
+ # write to file
79
+ open(nfs_config_file_path, 'w') do |f|
80
+ f.write output
81
+ f.flush
82
+ f.close
83
+ end
84
+ end
85
+
86
+ def self.nfs_prune(environment, ui, valid_ids)
87
+ # TODO Implement me
88
+ end
89
+
90
+ def self.nfs_apply_command(env)
91
+ service = WindowsService.new('NFSserver')
92
+ service.restart
93
+ end
94
+
95
+ def self.nfs_check_command(env)
96
+ service = WindowsService.new('NFSserver')
97
+ service.status
98
+ end
99
+
100
+ def self.nfs_start_command(env)
101
+ service = WindowsService.new('NFSserver')
102
+ service.start
103
+ end
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,26 @@
1
+ require 'vagrant'
2
+ require Vagrant.source_root.join("plugins/kernel_v2/config/vm")
3
+
4
+ module VagrantPlugins
5
+ module VagrantHanewinNfs
6
+ class Config < VagrantPlugins::Kernel_V2::VMConfig
7
+ def finalize!
8
+ switch_back = {}
9
+
10
+ @__synced_folders.each do |id, options|
11
+ if (options[:nfs] || options[:type] == :nfs || options[:type] == "nfs") && Vagrant::Util::Platform.windows?
12
+ switch_back[id] = true
13
+ end
14
+ end
15
+
16
+ super
17
+
18
+ @__synced_folders.each do |id, options|
19
+ if options[:type] != :nfs && !switch_back[id].nil?
20
+ options[:type] = :nfs
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,8 @@
1
+ require Vagrant.source_root.join("plugins/hosts/windows/host")
2
+
3
+ module VagrantPlugins
4
+ module VagrantHanewinNfs
5
+ class Host < VagrantPlugins::HostWindows::Host
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,74 @@
1
+ begin
2
+ require 'vagrant'
3
+ rescue LoadError
4
+ raise "The Vagrant Hanewin NFS plugin must be run within Vagrant."
5
+ end
6
+
7
+ if Vagrant::VERSION < "1.5.0"
8
+ raise "The Vagrant Hanewin NFS plugin is only compatible with Vagrant 1.5.0+"
9
+ end
10
+
11
+ module VagrantPlugins
12
+ module VagrantHanewinNfs
13
+ class Plugin < Vagrant.plugin(2)
14
+ name 'vagrant-hanewin-nfs'
15
+
16
+ description <<-DESC
17
+ This plugin adds NFS support on Windows for Vagrant with the Hanewin NFS Server.
18
+ DESC
19
+
20
+ #action_hook(:init_i18n, :environment_load) { init_plugin }
21
+
22
+ config("vm") do |env|
23
+ require_relative "config"
24
+ Config
25
+ end
26
+
27
+ synced_folder("nfs") do
28
+ require_relative "synced_folder"
29
+ SyncedFolder
30
+ end
31
+
32
+ host("windows_nfs", "windows") do
33
+ require_relative "host"
34
+ Host
35
+ end
36
+
37
+ host_capability("windows_nfs", "nfs_export") do
38
+ require_relative "cap/nfs"
39
+ Cap::NFS
40
+ end
41
+
42
+ host_capability("windows_nfs", "nfs_installed") do
43
+ require_relative "cap/nfs"
44
+ Cap::NFS
45
+ end
46
+
47
+ host_capability("windows_nfs", "nfs_prune") do
48
+ require_relative "cap/nfs"
49
+ Cap::NFS
50
+ end
51
+
52
+ host_capability("windows_nfs", "nfs_apply_command") do
53
+ require_relative "cap/nfs"
54
+ Cap::NFS
55
+ end
56
+
57
+ host_capability("windows_nfs", "nfs_check_command") do
58
+ require_relative "cap/nfs"
59
+ Cap::NFS
60
+ end
61
+
62
+ host_capability("windows_nfs", "nfs_start_command") do
63
+ require_relative "cap/nfs"
64
+ Cap::NFS
65
+ end
66
+
67
+ def self.init_plugin
68
+ I18n.load_path << File.expand_path('locales/en.yml', VagrantHanewinNfs.source_root)
69
+ I18n.reload!
70
+ end
71
+
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,11 @@
1
+ require Vagrant.source_root.join("plugins/synced_folders/nfs/synced_folder")
2
+
3
+ module VagrantPlugins
4
+ module VagrantHanewinNfs
5
+ class SyncedFolder < VagrantPlugins::SyncedFolderNFS::SyncedFolder
6
+ def usable?(machine,raise_error=false)
7
+ return true
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module VagrantHanewinNfs
3
+ VERSION = '1.0.0'
4
+ end
5
+ end
@@ -0,0 +1,82 @@
1
+ require 'open3'
2
+
3
+ module VagrantPlugins
4
+ module VagrantHanewinNfs
5
+ # Class reprents a windows service and allows
6
+ # to control this service via the sc command
7
+ class WindowsService
8
+
9
+ def initialize(name)
10
+ @name = name
11
+ @sc_cmd = "sc"
12
+ @logger = Log4r::Logger.new("vagrant::hosts::windows")
13
+
14
+ end
15
+
16
+ # Run sc command
17
+ def run_cmd(command)
18
+ cmd = "#{@sc_cmd} #{command} \"#{@name}\""
19
+ @logger.debug "WindowsServer run cmd #{cmd}"
20
+ stdout, stderr, status = Open3.capture3(cmd)
21
+
22
+ # Get allowed exit status
23
+ if command == 'start'
24
+ allowed_exitstatus = [0, 32]
25
+ elsif command == 'stop'
26
+ allowed_exitstatus = [0, 38]
27
+ else
28
+ allowed_exitstatus = [0]
29
+ end
30
+
31
+ # Check exitstatus
32
+ if allowed_exitstatus.include? status.exitstatus
33
+ return stdout
34
+ elsif status.exitstatus == 5
35
+ raise "Permission denied"
36
+ elsif [36,103].include? status.exitstatus
37
+ raise "Service #{@name} not found"
38
+ else
39
+ raise "Unknown return code #{status.exitstatus}: #{stdout}"
40
+ end
41
+ end
42
+
43
+ def start
44
+ run_cmd('start')
45
+ wait_for_status('RUNNING')
46
+ end
47
+
48
+ def stop
49
+ run_cmd('stop')
50
+ wait_for_status('STOPPED')
51
+ end
52
+
53
+ def restart
54
+ stop
55
+ start
56
+ end
57
+
58
+ def status
59
+ output = run_cmd('query')
60
+ # Match state
61
+ status = /STATE[\s:]+\d+\s+([\S]+)/.match(output)
62
+ if status.nil?
63
+ return nil
64
+ else
65
+ return status[1]
66
+ end
67
+ end
68
+
69
+ # Waits until service has desired state
70
+ def wait_for_status(state,sleep_duration=0.1, max_tries=20)
71
+ try = 0
72
+ while status != state do
73
+ try += 1
74
+ sleep(sleep_duration)
75
+ if try >= max_tries
76
+ raise "Error waiting for state '#{state}'"
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,9 @@
1
+ ---
2
+ en:
3
+ vagrant_hanewin_nfs:
4
+ hosts:
5
+ windows:
6
+ nfs_export: |-
7
+ Preparing to edit nfs mounting file.
8
+ nfs_prune: |-
9
+ Pruning invalid NFS exports.
@@ -0,0 +1,91 @@
1
+ require 'vagrant'
2
+ require 'vagrant-hanewin-nfs/cap/nfs'
3
+ require 'tempfile'
4
+
5
+
6
+ describe VagrantPlugins::VagrantHanewinNfs::Cap::NFS do
7
+
8
+ before(:each) do
9
+ @tempfile = Tempfile.new("nfs_config")
10
+ @NFS = VagrantPlugins::VagrantHanewinNfs::Cap::NFS
11
+ @NFS.stub(:nfs_config_file_path).and_return(@tempfile.path)
12
+
13
+ @host = double()
14
+ @host.stub(:capability).and_return(true)
15
+
16
+ @env = double()
17
+ @env.stub(:host).and_return(@host)
18
+
19
+ @folders = {
20
+ 'test123' =>
21
+ {
22
+ :nfs => true,
23
+ :hostpath => 'C:/localdev/test'
24
+ },
25
+ }
26
+ @id = "208a0b6b-b713-427b-9c7f-2721ec819b80"
27
+ @ips = ['127.0.0.1','123.45.78.19']
28
+ end
29
+
30
+ describe "#nfs_export" do
31
+ context "not existing config file" do
32
+
33
+ it {
34
+ @NFS.stub(:nfs_config_file_path).and_return(@tempfile.path+"dasda")
35
+
36
+ @tempfile.close
37
+ expect { @NFS.nfs_export(
38
+ @env,
39
+ nil,
40
+ @id,
41
+ @ips,
42
+ @folders,
43
+ ) }.not_to raise_error
44
+
45
+ content = open(@NFS.nfs_config_file_path).read()
46
+ content.should match(/C:\\localdev\\test/)
47
+
48
+ }
49
+ end
50
+ context "already existing config" do
51
+ before(:each) do
52
+ @config_old = "C:\\localdev\\test -mapall:1000:1000 127.0.0.1 ##VAGRANT#208a0b6b-b713-427b-9c7f-2721ec819b80#\nC:\\localdev\\test -mapall:1000:1000 123.45.78.19 ##VAGRANT#208a0b6b-b713-427b-9c7f-2721ec819b80#\n"
53
+ @tempfile.write(@config_old)
54
+ @tempfile.flush
55
+ end
56
+
57
+ describe "correct config should not change" do
58
+ it {
59
+
60
+ expect { @NFS.nfs_export(
61
+ @env,
62
+ nil,
63
+ @id,
64
+ @ips,
65
+ @folders,
66
+ ) }.not_to raise_error
67
+
68
+ content = open(@NFS.nfs_config_file_path).read()
69
+ content.should eq(@config_old)
70
+ }
71
+ end
72
+
73
+ describe "changed ip should change config" do
74
+ it {
75
+
76
+ expect { @NFS.nfs_export(
77
+ @env,
78
+ nil,
79
+ @id,
80
+ ['1.2.3.4'],
81
+ @folders,
82
+ ) }.not_to raise_error
83
+
84
+ content = open(@NFS.nfs_config_file_path).read()
85
+ content.lines.count.should eq(1)
86
+ content.should match(/1\.2\.3\.4/)
87
+ }
88
+ end
89
+ end
90
+ end
91
+ end
@@ -0,0 +1,126 @@
1
+ require "vagrant"
2
+ require "vagrant-hanewin-nfs/windows_service"
3
+
4
+ describe VagrantPlugins::VagrantHanewinNfs::WindowsService do
5
+
6
+ before(:each) do
7
+ @name = 'service1'
8
+ @service = VagrantPlugins::VagrantHanewinNfs::WindowsService.new(@name)
9
+ @stdout_running = "adfadf\n STATE : 4 RUNNING \n asds"
10
+ @stdout_stopped = "adfadf\n STATE : 1 STOPPED \n asds"
11
+ @double_open3 = double('Open3')
12
+ stub_const("Open3", @double_open3)
13
+ end
14
+
15
+ describe "existing service" do
16
+ context "is running" do
17
+ describe '#status' do
18
+ it {
19
+ @double_open3.should_receive(:capture3)
20
+ .with("sc query \"#{@name}\"")
21
+ .and_return([@stdout_running,"",double(:exitstatus => 0)])
22
+ @service.status.should eq("RUNNING")
23
+ }
24
+ end
25
+
26
+ describe '#stop' do
27
+ it {
28
+ @double_open3.should_receive(:capture3)
29
+ .with("sc stop \"#{@name}\"")
30
+ .and_return(["","",double(:exitstatus => 0)])
31
+ @double_open3.should_receive(:capture3)
32
+ .with("sc query \"#{@name}\"")
33
+ .and_return([@stdout_running,"",double(:exitstatus => 0)])
34
+ @double_open3.should_receive(:capture3)
35
+ .with("sc query \"#{@name}\"")
36
+ .and_return([@stdout_stopped,"",double(:exitstatus => 0)])
37
+ @service.stop
38
+ }
39
+ end
40
+
41
+ describe '#start' do
42
+ it {
43
+ @double_open3.should_receive(:capture3)
44
+ .with("sc start \"#{@name}\"")
45
+ .and_return(["Already running","",double(:exitstatus => 32)])
46
+ @double_open3.should_receive(:capture3)
47
+ .with("sc query \"#{@name}\"")
48
+ .and_return([@stdout_running,"",double(:exitstatus => 0)])
49
+ @service.start
50
+ }
51
+ end
52
+ end
53
+
54
+ context "is not running" do
55
+ describe '#status' do
56
+ it {
57
+ @double_open3.should_receive(:capture3)
58
+ .with("sc query \"#{@name}\"")
59
+ .and_return([@stdout_stopped,"",double(:exitstatus => 0)])
60
+ @service.status.should eq("STOPPED")
61
+ }
62
+ end
63
+
64
+ describe '#stop' do
65
+ it {
66
+ @double_open3.should_receive(:capture3)
67
+ .with("sc stop \"#{@name}\"")
68
+ .and_return(["","",double(:exitstatus => 38)])
69
+ @double_open3.should_receive(:capture3)
70
+ .with("sc query \"#{@name}\"")
71
+ .and_return([@stdout_stopped,"",double(:exitstatus => 0)])
72
+ @service.stop
73
+ }
74
+ end
75
+
76
+ describe '#start' do
77
+ it {
78
+ @double_open3.should_receive(:capture3)
79
+ .with("sc start \"#{@name}\"")
80
+ .and_return(["Already running","",double(:exitstatus => 0)])
81
+ @double_open3.should_receive(:capture3)
82
+ .with("sc query \"#{@name}\"")
83
+ .and_return(["UNPARSABLE","",double(:exitstatus => 0)])
84
+ @double_open3.should_receive(:capture3)
85
+ .with("sc query \"#{@name}\"")
86
+ .and_return([@stdout_running,"",double(:exitstatus => 0)])
87
+ @service.start
88
+ }
89
+ end
90
+ end
91
+ end
92
+
93
+ describe "not existing service" do
94
+ before(:each) do
95
+ @name = 'service_not1'
96
+ @service = VagrantPlugins::VagrantHanewinNfs::WindowsService.new(@name)
97
+ end
98
+
99
+ describe '#status' do
100
+ it {
101
+ @double_open3.should_receive(:capture3)
102
+ .with("sc query \"#{@name}\"")
103
+ .and_return([@stdout_stopped,"",double(:exitstatus => 103)])
104
+ expect { @service.status }.to raise_error(/not found/)
105
+ }
106
+ end
107
+
108
+ describe '#stop' do
109
+ it {
110
+ @double_open3.should_receive(:capture3)
111
+ .with("sc stop \"#{@name}\"")
112
+ .and_return([@stdout_stopped,"",double(:exitstatus => 36)])
113
+ expect { @service.stop }.to raise_error(/not found/)
114
+ }
115
+ end
116
+
117
+ describe '#start' do
118
+ it {
119
+ @double_open3.should_receive(:capture3)
120
+ .with("sc start \"#{@name}\"")
121
+ .and_return([@stdout_stopped,"",double(:exitstatus => 36)])
122
+ expect { @service.start }.to raise_error(/not found/)
123
+ }
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,3 @@
1
+ require "vagrant"
2
+ require "vagrant-hanewin-nfs"
3
+
@@ -0,0 +1,53 @@
1
+ $:.unshift File.expand_path("../lib", __FILE__)
2
+ require "vagrant-hanewin-nfs/version"
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.name = 'vagrant-hanewin-nfs'
6
+ gem.version = VagrantPlugins::VagrantHanewinNfs::VERSION
7
+
8
+ gem.summary = 'Adds NFS support for Windows with Hanewin NFS'
9
+ gem.description = <<-EOD
10
+ Manage and adds support for NFS on windows.
11
+ EOD
12
+
13
+ gem.authors = 'Christian Simon'
14
+ gem.email = 'simon@swine.de'
15
+ gem.homepage = 'https://github.com/simonswine/vagrant-hanewin-nfs'
16
+
17
+ gem.has_rdoc = true
18
+ gem.license = 'Apache 2.0'
19
+
20
+ # The following block of code determines the files that should be included
21
+ # in the gem. It does this by reading all the files in the directory where
22
+ # this gemspec is, and parsing out the ignored files from the gitignore.
23
+ # Note that the entire gitignore(5) syntax is not supported, specifically
24
+ # the "!" syntax, but it should mostly work correctly.
25
+ root_path = File.dirname(__FILE__)
26
+ all_files = Dir.chdir(root_path) { Dir.glob("**/{*,.*}") }
27
+ all_files.reject! { |file| [".", ".."].include?(File.basename(file)) }
28
+ gitignore_path = File.join(root_path, ".gitignore")
29
+ gitignore = File.readlines(gitignore_path)
30
+ gitignore.map! { |line| line.chomp.strip }
31
+ gitignore.reject! { |line| line.empty? || line =~ /^(#|!)/ }
32
+
33
+ unignored_files = all_files.reject do |file|
34
+ # Ignore any directories, the gemspec only cares about files
35
+ next true if File.directory?(file)
36
+
37
+ # Ignore any paths that match anything in the gitignore. We do
38
+ # two tests here:
39
+ #
40
+ # - First, test to see if the entire path matches the gitignore.
41
+ # - Second, match if the basename does, this makes it so that things
42
+ # like '.DS_Store' will match sub-directories too (same behavior
43
+ # as git).
44
+ #
45
+ gitignore.any? do |ignore|
46
+ File.fnmatch(ignore, file, File::FNM_PATHNAME) ||
47
+ File.fnmatch(ignore, File.basename(file), File::FNM_PATHNAME)
48
+ end
49
+ end
50
+
51
+ gem.files = unignored_files
52
+ gem.require_path = 'lib'
53
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-hanewin-nfs
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Christian Simon
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-24 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |2
14
+ Manage and adds support for NFS on windows.
15
+ email: simon@swine.de
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - .gitignore
21
+ - CHANGELOG
22
+ - Gemfile
23
+ - LICENSE
24
+ - README.md
25
+ - Rakefile
26
+ - lib/vagrant-hanewin-nfs.rb
27
+ - lib/vagrant-hanewin-nfs/cap/nfs.rb
28
+ - lib/vagrant-hanewin-nfs/config.rb
29
+ - lib/vagrant-hanewin-nfs/host.rb
30
+ - lib/vagrant-hanewin-nfs/plugin.rb
31
+ - lib/vagrant-hanewin-nfs/synced_folder.rb
32
+ - lib/vagrant-hanewin-nfs/version.rb
33
+ - lib/vagrant-hanewin-nfs/windows_service.rb
34
+ - locales/en.yml
35
+ - spec/classes/cap_nfs_spec.rb
36
+ - spec/classes/windows_service_spec.rb
37
+ - spec/spec_helper.rb
38
+ - vagrant-hanewin-nfs.gemspec
39
+ homepage: https://github.com/simonswine/vagrant-hanewin-nfs
40
+ licenses:
41
+ - Apache 2.0
42
+ metadata: {}
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubyforge_project:
59
+ rubygems_version: 2.2.2
60
+ signing_key:
61
+ specification_version: 4
62
+ summary: Adds NFS support for Windows with Hanewin NFS
63
+ test_files: []