vagrant-toplevel-cookbooks 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 178843c8d03b44be962596b2e58734a87d52f3bc
4
+ data.tar.gz: 0fbe0df8f9ee147df80230538e6ca36511017f3c
5
+ SHA512:
6
+ metadata.gz: a4c49e5574b45c8b5a8329d726142b392389124eb000a9e1ea6f24cccf4ae391e58f4a48c697d0caaf03e0dc0df8eb11e0b6dc32240fd76258e925b5e2b97190
7
+ data.tar.gz: b780118c0f618241a7bf1b6eaccdf8bf82ce0f21a8394f2ea834820e20aaf44fa82adab5dffbb2bfcdce8699e4407d70caf21e86fb418a12bbddd6301ba90af6
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ # OS-specific
2
+ .DS_Store
3
+
4
+ # Bundler/Rubygems
5
+ *.gem
6
+ .bundle
7
+ pkg/*
8
+ tags
9
+ Gemfile.lock
10
+
11
+ # Vagrant
12
+ .vagrant
13
+ !example_box/Vagrantfile
14
+
15
+ # Berkshelf
16
+ cookbooks
17
+ Berksfile.lock
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format=doc
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ script:
5
+ - rake spec
data/CHANGELOG.md ADDED
@@ -0,0 +1,29 @@
1
+
2
+ # 0.2.0 (July 7, 2014)
3
+
4
+ * several **breaking changes**:
5
+ * rename plugin to "vagrant-toplevel-cookbooks"
6
+ * update to berkshelf 3 for [ChefDK](http://www.getchef.com/downloads/chef-dk) (berkshelf 2 is no longer supported)
7
+ * remove berkshelf gem dependency (`berks` must be on the `$PATH`)
8
+ * update development dependencies to latest vagrant 1.6 and adapt Vagrantfile samples
9
+
10
+ # 0.1.4 (Oct 5, 2013)
11
+
12
+ * Use Berkshelf API rather than shelling out
13
+
14
+ # 0.1.3 (Oct 5, 2013)
15
+
16
+ * Fix permanently thrown exception (left-over from debugging)
17
+
18
+ # 0.1.2 (Oct 5, 2013)
19
+
20
+ * Silence output of git commands
21
+ * Fix several issues with checkout and updating of refs
22
+
23
+ # 0.1.1 (Oct 5, 2013)
24
+
25
+ * Fix missing berkshelf dependency
26
+
27
+ # 0.1.0 (Oct 5, 2013)
28
+
29
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,19 @@
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", "1.6.3",
10
+ git: "https://github.com/mitchellh/vagrant.git",
11
+ ref: "v1.6.3"
12
+ gem "berkshelf", "3.1.3"
13
+ end
14
+
15
+ group :plugins do
16
+ gem "vagrant-toplevel-cookbooks", path: "."
17
+ gem "vagrant-omnibus", "1.4.1"
18
+ gem "vagrant-cachier", "0.7.2"
19
+ end
data/LICENSE ADDED
@@ -0,0 +1,8 @@
1
+ The MIT License (MIT)
2
+ Copyright (c) 2013 Torben Knerr
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5
+
6
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7
+
8
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # Vagrant Top-Level Cookbooks Plugin
2
+
3
+ [![Build Status](https://travis-ci.org/tknerr/vagrant-toplevel-cookbooks.png?branch=master)](https://travis-ci.org/tknerr/vagrant-toplevel-cookbooks)
4
+
5
+
6
+ This [Vagrant](http://www.vagrantup.com) 1.2+ plugin lets you specify the [top-level cookbooks](http://lists.opscode.com/sympa/arc/chef/2014-01/msg00419.html) to deploy your VMs with. It will take care of cloning the top-level cookbook from the Git repository, resolve its dependencies via Berkshelf, and configure the Chef Solo provisioner accordingly.
7
+
8
+ Note: this plugin was previously (until v0.1.4) named `vagrant-application-cookbooks`, but since the term "application cookbook" is so much overloaded in the Chef community [I now call them "top-level cookbooks"](https://github.com/berkshelf/berkshelf/issues/535#issuecomment-40890497).
9
+
10
+ ## Features
11
+
12
+ * allows you to deploy [top-level cookbooks](http://red-badger.com/blog/2013/06/24/berkshelf-application-cookbooks/) from a git repository (remote or local)
13
+ * lets you choose a specific `ref` (i.e. commit, tag or branch) to deploy
14
+ * resolves each VMs toplevel cookbook dependencies in isolation to `.vagrant/app-cookbooks/<vm-name>/cookbooks/` (i.e. no inter-VM dependency conflicts)
15
+ * uses the `Berksfile` that is shipped with the toplevel cookbook to resolve dependencies
16
+ * configures the `cookbooks_path` of the `:chef_solo` provisioner accordingly
17
+
18
+ ## Usage
19
+
20
+ Install using standard Vagrant 1.1+ plugin installation methods or via bindler.
21
+
22
+ To deploy the `sample-app` toplevel cookbook from the `master` branch:
23
+ ```ruby
24
+ Vagrant.configure("2") do |config|
25
+ config.vm.define :sample do |sample_config|
26
+ sample_config.app_cookbook.url = "https://github.com/tknerr/sample-toplevel-cookbook"
27
+ sample_config.vm.provision :chef_solo do |chef|
28
+ chef.add_recipe "sample-app"
29
+ end
30
+ end
31
+ end
32
+ ```
33
+
34
+ Or to deploy from a specific git `ref`, `branch` or `tag`:
35
+ ```ruby
36
+ ...
37
+ sample_config.app_cookbook.url = "https://github.com/tknerr/sample-toplevel-cookbook"
38
+ sample_config.app_cookbook.ref = "some_ref"
39
+ ...
40
+ ```
41
+
42
+ You can also use local file URLs:
43
+ ```ruby
44
+ ...
45
+ sample_config.app_cookbook.url = "file:///path/to/toplevel-cookbook"
46
+ ...
47
+ ```
48
+
49
+
50
+ ## Development
51
+
52
+ To work on the `vagrant-toplevel-cookbooks` plugin, clone this repository out, and use
53
+ [Bundler](http://gembundler.com) to get the dependencies:
54
+
55
+ ```
56
+ $ bundle
57
+ ```
58
+
59
+ Once you have the dependencies, verify the unit tests pass with `rake`:
60
+
61
+ ```
62
+ $ bundle exec rake
63
+ ```
64
+
65
+ If those pass, you're ready to start developing the plugin. You can test
66
+ the plugin without installing it into your Vagrant environment by using the
67
+ `Vagrantfile` in the top level of this directory and use bundler to execute Vagrant.
68
+
69
+ To test that the `my_app` vm is deployed with the `sample-app` top-level cookbook simply run:
70
+ ```
71
+ $ bundle exec vagrant up my_app
72
+ ```
73
+
data/Rakefile ADDED
@@ -0,0 +1,21 @@
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
+ # Change to the directory of this file.
11
+ Dir.chdir(File.expand_path("../", __FILE__))
12
+
13
+ # This installs the tasks that help with gem creation and
14
+ # publishing.
15
+ Bundler::GemHelper.install_tasks
16
+
17
+ # Install the `spec` task so that we can run tests.
18
+ RSpec::Core::RakeTask.new
19
+
20
+ # Default task is to run the unit tests
21
+ task :default => "spec"
data/TODO.md ADDED
@@ -0,0 +1,17 @@
1
+
2
+ # TODO
3
+
4
+ - [x] improve log/info output
5
+ - [-] configure app cookbook in chef_solo config rather than vm config
6
+ - [x] warn if cookbook_path is manually configured and will be overridden
7
+ - [x] skip everything (e.g. cloning, resolving deps) for vms which don't define an app cookbook
8
+ - [x] skip everything for vms which don't have a chef provisioner
9
+ - [x] support for cloning a specific ref / branch / tag
10
+ - [-] configure the default recipe automatically
11
+ - [x] use Berkshelf Ruyb API rather than shelling out
12
+ - [x] add spec tests for the config
13
+ - [ ] add spec tests for the clone action
14
+ - [ ] check if url is a valid url
15
+ - [ ] use i18n
16
+ - [x] suppress stdout / stderr when shelling out git commands
17
+ - [ ] add support for more provisioners / dependency managers
data/Vagrantfile ADDED
@@ -0,0 +1,71 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant.configure("2") do |config|
5
+
6
+ config.omnibus.chef_version = "11.12.8"
7
+ config.cache.scope = :box
8
+
9
+ config.vm.box = "opscode_ubuntu-12.04"
10
+ config.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-12.04_chef-provisionerless.box"
11
+
12
+ #
13
+ # configure vm to be deployed with toplevel cookbook
14
+ #
15
+ config.vm.define :my_app do |my_app_config|
16
+ # app cookbook to deploy
17
+ my_app_config.toplevel_cookbook.url = "https://github.com/tknerr/sample-toplevel-cookbook"
18
+
19
+ my_app_config.vm.provision :chef_solo do |chef|
20
+ chef.add_recipe "sample-app"
21
+ chef.json = {
22
+ :sample_app => {
23
+ :words_of_wisdom => "Chuck Norris' beard can type 140 wpm!"
24
+ }
25
+ }
26
+ end
27
+ end
28
+
29
+ #
30
+ # example for deploying a specific branch
31
+ #
32
+ config.vm.define :my_app_branched do |my_app_config|
33
+ # app cookbook to deploy
34
+ my_app_config.toplevel_cookbook.url = "https://github.com/tknerr/sample-toplevel-cookbook"
35
+ my_app_config.toplevel_cookbook.ref = "lxc"
36
+
37
+ my_app_config.vm.provision :chef_solo do |chef|
38
+ chef.add_recipe "sample-app"
39
+ end
40
+ end
41
+
42
+ #
43
+ # example using a local file url
44
+ #
45
+ config.vm.define :my_app_local_file do |my_app_config|
46
+ # app cookbook to deploy
47
+ my_app_config.toplevel_cookbook.url = "file://D:/Repos/_github/_cookbooks/sample-toplevel-cookbook"
48
+
49
+ my_app_config.vm.provision :chef_solo do |chef|
50
+ chef.add_recipe "sample-app"
51
+ end
52
+ end
53
+
54
+ #
55
+ # example without toplevel cookbook configured
56
+ #
57
+ config.vm.define :my_app_no_toplevel_cookbook do |my_app_config|
58
+ my_app_config.vm.provision :chef_solo do |chef|
59
+ chef.add_recipe "sample-app"
60
+ end
61
+ end
62
+
63
+ #
64
+ # example without provisioner - should kick in here
65
+ #
66
+ config.vm.define :my_app_no_provisioner do |my_app_config|
67
+ # app cookbook to deploy
68
+ my_app_config.toplevel_cookbook.url = "https://github.com/tknerr/sample-toplevel-cookbook"
69
+ end
70
+
71
+ end
@@ -0,0 +1,18 @@
1
+ require "pathname"
2
+
3
+ require "vagrant-toplevel-cookbooks/plugin"
4
+
5
+ module VagrantPlugins
6
+ module ApplicationCookbooks
7
+ lib_path = Pathname.new(File.expand_path("../vagrant-toplevel-cookbooks", __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,14 @@
1
+ require 'pathname'
2
+
3
+ module VagrantPlugins
4
+ module TopLevelCookbooks
5
+ module Action
6
+
7
+ def self.action_root
8
+ Pathname.new(File.expand_path("../action", __FILE__))
9
+ end
10
+
11
+ autoload :Clone, action_root.join("clone")
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,119 @@
1
+ module VagrantPlugins
2
+ module TopLevelCookbooks
3
+ module Action
4
+
5
+ # This middleware checks if reqiured plugins are present
6
+ class Clone
7
+
8
+ attr_reader :cloned_repo_path, :cookbook_install_path, :git_url, :git_ref
9
+
10
+ def initialize(app, env)
11
+ @app = app
12
+ @env = env
13
+
14
+ # machine-specific paths to clone git repo and install cookbooks
15
+ @cloned_repo_path = env[:root_path].join('.vagrant', 'toplevel-cookbooks', env[:machine].name.to_s, 'repo')
16
+ @cookbook_install_path = env[:root_path].join('.vagrant', 'toplevel-cookbooks', env[:machine].name.to_s, 'cookbooks')
17
+
18
+ # shortcut for values from config
19
+ @git_url = env[:machine].config.toplevel_cookbook.url
20
+ @git_ref = env[:machine].config.toplevel_cookbook.ref
21
+ end
22
+
23
+ def provisioners(name)
24
+ @env[:machine].config.vm.provisioners.select{ |prov| prov.name == name }
25
+ end
26
+
27
+ def log(msg)
28
+ @env[:ui].info msg
29
+ end
30
+
31
+ def is_cloned?
32
+ File.exist?(cloned_repo_path) && get_origin.eql?(git_url)
33
+ end
34
+
35
+ def get_origin
36
+ `cd #{cloned_repo_path} && git config --get remote.origin.url`.strip
37
+ end
38
+
39
+ def cookbooks_path_configured?(provisioner)
40
+ # see https://github.com/mitchellh/vagrant/blob/master/plugins/provisioners/chef/config/chef_solo.rb#L41-45
41
+ provisioner.config.cookbooks_path != [[:host, "cookbooks"], [:vm, "cookbooks"]]
42
+ end
43
+
44
+ def has_chef_solo_provisioner?
45
+ provisioners(:chef_solo).size > 0
46
+ end
47
+
48
+ def app_cookbook_configured?
49
+ git_url != nil
50
+ end
51
+
52
+ def clean_and_clone_repo
53
+ FileUtils.rm_rf cloned_repo_path
54
+ FileUtils.mkdir_p cloned_repo_path
55
+ unless system("git clone -q #{git_url} #{cloned_repo_path}")
56
+ raise "something went wrong while cloning '#{git_url}'"
57
+ end
58
+ end
59
+
60
+ def checkout_and_update
61
+ Dir.chdir(cloned_repo_path) do
62
+ # retrieve all refs
63
+ system("git fetch -q --all")
64
+ # checkout ref
65
+ unless system("git checkout -q #{git_ref}")
66
+ raise "something went wrong while checking out '#{git_ref}'"
67
+ end
68
+ # update ref only if we are on a branch, i.e. not on a detached HEAD
69
+ unless `git symbolic-ref -q HEAD`.empty?
70
+ system("git pull -q")
71
+ end
72
+ end
73
+ end
74
+
75
+ def install_cookbooks
76
+ Dir.chdir(cloned_repo_path) do
77
+ FileUtils.rm_rf cookbook_install_path
78
+ system "berks vendor #{cookbook_install_path}"
79
+ end
80
+ end
81
+
82
+ def configure_chef_solo
83
+ provisioners(:chef_solo).each do |provisioner|
84
+ if cookbooks_path_configured? provisioner
85
+ @env[:ui].warn "WARNING: already configured `cookbooks_path` will be overridden!"
86
+ end
87
+ provisioner.config.cookbooks_path = provisioner.config.send(:prepare_folders_config, cookbook_install_path)
88
+ end
89
+ end
90
+
91
+
92
+ def call(env)
93
+
94
+ if app_cookbook_configured? && has_chef_solo_provisioner?
95
+
96
+ if not is_cloned?
97
+ log "Cloning top-level cookbook from '#{git_url}'"
98
+ clean_and_clone_repo
99
+ else
100
+ log "Using top-level cookbook '#{git_url}'"
101
+ end
102
+
103
+ log "Ensuring top-level cookbook is checked out at '#{git_ref}'"
104
+ checkout_and_update
105
+
106
+ log "Installing top-level cookbook dependencies to '#{cookbook_install_path}'"
107
+ install_cookbooks
108
+
109
+ log "Configuring Chef Solo provisioner for top-level cookbook"
110
+ configure_chef_solo
111
+ end
112
+
113
+ # continue if ok
114
+ @app.call(env)
115
+ end
116
+ end
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,35 @@
1
+ require "vagrant"
2
+
3
+ module VagrantPlugins
4
+ module TopLevelCookbooks
5
+ class Config < Vagrant.plugin(2, :config)
6
+
7
+ # git url to clone from
8
+ attr_accessor :url
9
+ # git ref / branch to checkout
10
+ attr_accessor :ref
11
+
12
+ def initialize
13
+ @url = UNSET_VALUE
14
+ @ref = UNSET_VALUE
15
+ end
16
+
17
+ def validate(machine)
18
+ errors = _detected_errors
19
+ if @ref != nil
20
+ errors << "'toplevel_cookbook.url' must be specified when 'toplevel_cookbook.ref' is used" if @url.nil?
21
+ end
22
+ { "vagrant-toplevel-cookbooks" => errors }
23
+ end
24
+
25
+ def finalize!
26
+ @url = nil if @url == UNSET_VALUE
27
+ if @url != nil
28
+ @ref = 'master' if @ref == UNSET_VALUE
29
+ else
30
+ @ref = nil if @ref == UNSET_VALUE
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,33 @@
1
+ begin
2
+ require "vagrant"
3
+ rescue LoadError
4
+ raise "The Vagrant TopLevelCookbooks plugin must be run within Vagrant."
5
+ end
6
+
7
+ # This is a sanity check to make sure no one is attempting to install
8
+ # this into an early Vagrant version.
9
+ if Vagrant::VERSION < "1.2.0"
10
+ raise "The Vagrant TopLevelCookbooks plugin is only compatible with Vagrant 1.2+"
11
+ end
12
+
13
+ module VagrantPlugins
14
+ module TopLevelCookbooks
15
+ class Plugin < Vagrant.plugin("2")
16
+ name "TopLevelCookbooks"
17
+ description "This plugin allows you to deploy Top-Level Cookbooks"
18
+
19
+ config "toplevel_cookbook" do
20
+ require_relative "config"
21
+ Config
22
+ end
23
+
24
+ require_relative "action"
25
+ clone_action_hook = lambda do |hook|
26
+ hook.before Vagrant::Action::Builtin::ConfigValidate, VagrantPlugins::TopLevelCookbooks::Action::Clone
27
+ end
28
+ action_hook 'clone-toplevel-cookbook-on-machine-up', :machine_action_up, &clone_action_hook
29
+ action_hook 'clone-toplevel-cookbook-on-machine-reload', :machine_action_reload, &clone_action_hook
30
+ action_hook 'clone-toplevel-cookbook-on-machine-provision', :machine_action_provision, &clone_action_hook
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module TopLevelCookbooks
3
+ VERSION = "0.2.0"
4
+ end
5
+ end
@@ -0,0 +1,40 @@
1
+ require "vagrant-toplevel-cookbooks/config"
2
+
3
+ describe VagrantPlugins::TopLevelCookbooks::Config do
4
+ let(:instance) { described_class.new }
5
+
6
+ describe "defaults" do
7
+ subject do
8
+ instance.tap do |o|
9
+ o.finalize!
10
+ end
11
+ end
12
+
13
+ its("url") { should be_nil }
14
+ its("ref") { should be_nil }
15
+ end
16
+
17
+ describe "overriding defaults" do
18
+ it "should use the specified url with 'master' branch as default" do
19
+ instance.url = "https://github.com/some/repo"
20
+ instance.finalize!
21
+ instance.url.should == "https://github.com/some/repo"
22
+ instance.ref.should == "master"
23
+ end
24
+
25
+ it "should be possible to specify a different branch" do
26
+ instance.url = "https://github.com/some/repo"
27
+ instance.ref = "my_branch"
28
+ instance.finalize!
29
+ instance.url.should == "https://github.com/some/repo"
30
+ instance.ref.should == "my_branch"
31
+ end
32
+
33
+ it "should error if a branch is specified but no url" do
34
+ instance.ref = "my_branch"
35
+ instance.finalize!
36
+ err_hash = instance.validate(nil)
37
+ err_hash['vagrant-toplevel-cookbooks'].size.should == 1
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,56 @@
1
+ $:.unshift File.expand_path("../lib", __FILE__)
2
+ require "vagrant-toplevel-cookbooks/version"
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "vagrant-toplevel-cookbooks"
6
+ s.version = VagrantPlugins::TopLevelCookbooks::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = "Torben Knerr"
9
+ s.email = "mail@tknerr.de"
10
+ s.homepage = "https://github.com/tknerr/vagrant-toplevel-cookbooks"
11
+ s.summary = "Deploy Chef \"Top-Level Cookbooks\" directly from a Git repository"
12
+ s.description = "Deploy Chef \"Top-Level Cookbooks\" directly from a Git repository"
13
+
14
+ s.required_rubygems_version = ">= 1.3.6"
15
+ s.rubyforge_project = "vagrant-toplevel-cookbooks"
16
+
17
+ s.add_development_dependency "rake"
18
+ s.add_development_dependency "rspec-core", "~> 2.12.2"
19
+ s.add_development_dependency "rspec-expectations", "~> 2.12.1"
20
+ s.add_development_dependency "rspec-mocks", "~> 2.12.1"
21
+
22
+ # The following block of code determines the files that should be included
23
+ # in the gem. It does this by reading all the files in the directory where
24
+ # this gemspec is, and parsing out the ignored files from the gitignore.
25
+ # Note that the entire gitignore(5) syntax is not supported, specifically
26
+ # the "!" syntax, but it should mostly work correctly.
27
+ root_path = File.dirname(__FILE__)
28
+ all_files = Dir.chdir(root_path) { Dir.glob("**/{*,.*}") }
29
+ all_files.reject! { |file| [".", ".."].include?(File.basename(file)) }
30
+ gitignore_path = File.join(root_path, ".gitignore")
31
+ gitignore = File.readlines(gitignore_path)
32
+ gitignore.map! { |line| line.chomp.strip }
33
+ gitignore.reject! { |line| line.empty? || line =~ /^(#|!)/ }
34
+
35
+ unignored_files = all_files.reject do |file|
36
+ # Ignore any directories, the gemspec only cares about files
37
+ next true if File.directory?(file)
38
+
39
+ # Ignore any paths that match anything in the gitignore. We do
40
+ # two tests here:
41
+ #
42
+ # - First, test to see if the entire path matches the gitignore.
43
+ # - Second, match if the basename does, this makes it so that things
44
+ # like '.DS_Store' will match sub-directories too (same behavior
45
+ # as git).
46
+ #
47
+ gitignore.any? do |ignore|
48
+ File.fnmatch(ignore, file, File::FNM_PATHNAME) ||
49
+ File.fnmatch(ignore, File.basename(file), File::FNM_PATHNAME)
50
+ end
51
+ end
52
+
53
+ s.files = unignored_files
54
+ s.executables = unignored_files.map { |f| f[/^bin\/(.*)/, 1] }.compact
55
+ s.require_path = 'lib'
56
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-toplevel-cookbooks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Torben Knerr
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec-core
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 2.12.2
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 2.12.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-expectations
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 2.12.1
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 2.12.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-mocks
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.12.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 2.12.1
69
+ description: Deploy Chef "Top-Level Cookbooks" directly from a Git repository
70
+ email: mail@tknerr.de
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - CHANGELOG.md
76
+ - Gemfile
77
+ - lib/vagrant-toplevel-cookbooks/action/clone.rb
78
+ - lib/vagrant-toplevel-cookbooks/action.rb
79
+ - lib/vagrant-toplevel-cookbooks/config.rb
80
+ - lib/vagrant-toplevel-cookbooks/plugin.rb
81
+ - lib/vagrant-toplevel-cookbooks/version.rb
82
+ - lib/vagrant-toplevel-cookbooks.rb
83
+ - LICENSE
84
+ - Rakefile
85
+ - README.md
86
+ - spec/vagrant-toplevel-cookbooks/config_spec.rb
87
+ - TODO.md
88
+ - vagrant-toplevel-cookbooks.gemspec
89
+ - Vagrantfile
90
+ - .gitignore
91
+ - .rspec
92
+ - .travis.yml
93
+ homepage: https://github.com/tknerr/vagrant-toplevel-cookbooks
94
+ licenses: []
95
+ metadata: {}
96
+ post_install_message:
97
+ rdoc_options: []
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - '>='
108
+ - !ruby/object:Gem::Version
109
+ version: 1.3.6
110
+ requirements: []
111
+ rubyforge_project: vagrant-toplevel-cookbooks
112
+ rubygems_version: 2.0.14
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: Deploy Chef "Top-Level Cookbooks" directly from a Git repository
116
+ test_files: []