bindle 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +20 -0
- data/README.md +78 -0
- data/Rakefile +39 -0
- data/bin/bindle +4 -0
- data/bindle.gemspec +31 -0
- data/lib/bindle.rb +1 -0
- data/lib/bindle/cli.rb +37 -0
- data/lib/bindle/commands/base.rb +46 -0
- data/lib/bindle/commands/init.rb +99 -0
- data/lib/bindle/templates/Cheffile +10 -0
- data/lib/bindle/templates/Gemfile +8 -0
- data/lib/bindle/templates/Vagrantfile +18 -0
- data/lib/bindle/templates/Veeweefile +13 -0
- data/lib/bindle/templates/chef/README.md +0 -0
- data/lib/bindle/templates/chef/roles/base.rb +7 -0
- data/lib/bindle/templates/knife.rb +12 -0
- data/lib/bindle/templates/librarian/chef/config +3 -0
- data/lib/bindle/version.rb +10 -0
- data/test/bindle/commands/test_init.rb +41 -0
- data/test/bindle/test_cli.rb +14 -0
- data/test/helper.rb +73 -0
- data/test/test_bindle.rb +22 -0
- metadata +215 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6aaff858c0e28415785eeaaa924704a3f27ab8a7
|
4
|
+
data.tar.gz: e61e0abe584070e08deebcca973b390199cecce9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 096fedfbeb110aa1e71136fe68537b07502cd5fde211dc34f76e3e2fa0a0a134cb7e055c0127dfbb4dfb0c732dbaa4c89d6ddf69013e0ba4f2937695511a78df
|
7
|
+
data.tar.gz: 7f6fa210c4ca057b07a09b5c08cb138557ddf1d59d65d665fe9b8280db9e912ddd2334cee6f457ab276bb274944eb1c8141407e25c8c7095900a63a7093fd1eb
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Scott Bader
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
# Bindle
|
2
|
+
|
3
|
+
## Description
|
4
|
+
|
5
|
+
Bindle is a server and development environment creation tool.
|
6
|
+
|
7
|
+
It sets up your repository with the correct files to use Vagrant, knife-ec2, knife-solo, and librarian-chef.
|
8
|
+
|
9
|
+
## Dependencies
|
10
|
+
|
11
|
+
To use Vagrant you'll need to install the current version at http://downloads.vagrantup.com/.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
$ gem install bindle
|
16
|
+
|
17
|
+
## Setup
|
18
|
+
|
19
|
+
The following environment variables will need to be set to work with EC2:
|
20
|
+
|
21
|
+
- **AWS_ACCESS_KEY_ID** - AWS API Access Key Id [found here](https://console.aws.amazon.com/iam/home?#security_credential)
|
22
|
+
- **AWS_SECRET_ACCESS_KEY** - AWS API Secret Access Key [found here](https://console.aws.amazon.com/iam/home?#security_credential)
|
23
|
+
- **AWS_SECURITY_KEY_NAME** - Name of EC2 security key to use
|
24
|
+
- **AWS_IDENTITY_FILE** - The path to the identity file matching the security key
|
25
|
+
|
26
|
+
You can also override the following options with an environment variable:
|
27
|
+
|
28
|
+
- **AWS_SSH_USER** - The ssh user to use when accessing a server (defaults to 'ubuntu')
|
29
|
+
- **AWS_DEFAULT_FLAVOR** - The EC2 instance size to use (defaults to 't1.micro')
|
30
|
+
- **AWS_DEFAULT_AMI** - The AMI to use to build a server (defaults to 'ami-8b0772e2' Ubuntu 12.10 image from http://cloud-images.ubuntu.com/quantal/current)
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
`init` sets up the current directory with config files for librarian, a Cheffile, a Gemfile, a knife.rb file, and a base chef role
|
35
|
+
|
36
|
+
To initialize the current directory run:
|
37
|
+
|
38
|
+
$ bindle init
|
39
|
+
|
40
|
+
You can also pass a directory as the first argument to init and it will initialize bindle in that directory
|
41
|
+
|
42
|
+
$ bindle init ~/code/bindle_test
|
43
|
+
|
44
|
+
Once initialized you can use librarian-chef, vagrant, and knife to work with cookbooks and build servers.
|
45
|
+
|
46
|
+
To create and provision a vagrant box, just run:
|
47
|
+
|
48
|
+
$ vagrant up
|
49
|
+
|
50
|
+
To launch an EC2 image, run:
|
51
|
+
|
52
|
+
$ bin/knife ec2 server create -T Name="bindle_server"
|
53
|
+
$ bin/knife solo prepare HOST_NAME_OF_CREATED_SERVER --run-list "role[base]"
|
54
|
+
$ bin/knife solo cook HOST_NAME_OF_CREATED_SERVER
|
55
|
+
|
56
|
+
To add cookbooks, update the Cheffile and run:
|
57
|
+
|
58
|
+
$ bin/librarian-chef install
|
59
|
+
|
60
|
+
To update installed cookbooks, run:
|
61
|
+
|
62
|
+
$ bin/librarian-chef update [cookbook_name]
|
63
|
+
|
64
|
+
Vagrant, Chef, Knife Solo, Knife EC2, and Librarian Chef have a lot more functionality. Follow these links to dig in some more:
|
65
|
+
|
66
|
+
[Vagrant](http://docs.vagrantup.com/v2)
|
67
|
+
[Chef](http://docs.opscode.com/)
|
68
|
+
[Knife Solo](https://github.com/matschaffer/knife-solo/blob/master/README.rdoc)
|
69
|
+
[Knife EC2](http://docs.opscode.com/plugin_knife_ec2.html)
|
70
|
+
[Librarian Chef](https://github.com/applicationsonline/librarian-chef)
|
71
|
+
|
72
|
+
## Copyright
|
73
|
+
|
74
|
+
Copyright (c) 2013 Scott Bader
|
75
|
+
|
76
|
+
## License
|
77
|
+
|
78
|
+
Bindle is released under the MIT License, see LICENSE.txt for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'bundler'
|
7
|
+
rescue LoadError => e
|
8
|
+
warn e.message
|
9
|
+
warn "Run `gem install bundler` to install Bundler."
|
10
|
+
exit -1
|
11
|
+
end
|
12
|
+
|
13
|
+
begin
|
14
|
+
Bundler.setup(:development)
|
15
|
+
rescue Bundler::BundlerError => e
|
16
|
+
warn e.message
|
17
|
+
warn "Run `bundle install` to install missing gems."
|
18
|
+
exit e.status_code
|
19
|
+
end
|
20
|
+
|
21
|
+
require 'rake'
|
22
|
+
|
23
|
+
require 'rake/testtask'
|
24
|
+
Rake::TestTask.new do |t|
|
25
|
+
t.libs << "test"
|
26
|
+
t.test_files = FileList['test/**/test*.rb']
|
27
|
+
t.verbose = true
|
28
|
+
end
|
29
|
+
|
30
|
+
require 'rubygems/tasks'
|
31
|
+
Gem::Tasks.new
|
32
|
+
|
33
|
+
require 'rdoc/task'
|
34
|
+
RDoc::Task.new do |rdoc|
|
35
|
+
rdoc.title = "bindle"
|
36
|
+
end
|
37
|
+
task :doc => :rdoc
|
38
|
+
|
39
|
+
task :default => :test
|
data/bin/bindle
ADDED
data/bindle.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require File.expand_path("../lib/bindle/version", __FILE__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "bindle"
|
7
|
+
gem.version = Bindle::VERSION::STRING
|
8
|
+
gem.summary = %q{bindle is a server and development environment provisioning tool}
|
9
|
+
gem.description = %q{bindle is a server and development environment provisioning tool. Using Chef, Vagrant, and Fog it organizes and simplifies the creation and management of your development environment and allows you to use the same provisioning tools on your production servers.}
|
10
|
+
gem.license = "MIT"
|
11
|
+
gem.authors = ["Scott Bader"]
|
12
|
+
gem.email = "sb@scottbader.org"
|
13
|
+
gem.homepage = "https://github.com/sbader/bindle#readme"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency "chef"
|
21
|
+
gem.add_dependency "librarian-chef"
|
22
|
+
gem.add_dependency "thor"
|
23
|
+
gem.add_dependency "activesupport"
|
24
|
+
|
25
|
+
gem.add_development_dependency "bundler"
|
26
|
+
gem.add_development_dependency "rake"
|
27
|
+
gem.add_development_dependency "rdoc"
|
28
|
+
gem.add_development_dependency "rubygems-tasks"
|
29
|
+
gem.add_development_dependency "pry"
|
30
|
+
gem.add_development_dependency "m", "~> 1.3.1"
|
31
|
+
end
|
data/lib/bindle.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bindle/version'
|
data/lib/bindle/cli.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'bindle/version'
|
2
|
+
require 'active_support/core_ext/string'
|
3
|
+
|
4
|
+
if ['--version', '-v'].include?(ARGV.first)
|
5
|
+
puts "Bindle #{Bindle::VERSION::STRING}"
|
6
|
+
exit(0)
|
7
|
+
end
|
8
|
+
|
9
|
+
ARGV << '--help' if ARGV.empty?
|
10
|
+
|
11
|
+
aliases = {
|
12
|
+
"i" => "init"
|
13
|
+
}
|
14
|
+
|
15
|
+
help_message = <<-EOT.strip_heredoc
|
16
|
+
Usage:
|
17
|
+
bindle COMMAND [ARGS]
|
18
|
+
|
19
|
+
Common commands are:
|
20
|
+
init Setup bindle in the current directory
|
21
|
+
EOT
|
22
|
+
|
23
|
+
command = ARGV.shift
|
24
|
+
command = aliases[command] || command
|
25
|
+
|
26
|
+
case command
|
27
|
+
when 'init'
|
28
|
+
require "bindle/commands/init"
|
29
|
+
klass = Object.const_get("Bindle::Commands::#{command.capitalize}")
|
30
|
+
klass.start(ARGV)
|
31
|
+
when '-h', '--help'
|
32
|
+
puts help_message
|
33
|
+
else
|
34
|
+
puts "Error: '#{command}' not recognized"
|
35
|
+
puts help_message
|
36
|
+
exit(1)
|
37
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
begin
|
2
|
+
require 'thor/group'
|
3
|
+
rescue LoadError
|
4
|
+
puts "Thor is not available.\nPlease make sure thor is installed and run again"
|
5
|
+
exit
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'active_support/core_ext/string/inflections'
|
9
|
+
|
10
|
+
module Bindle
|
11
|
+
module Commands
|
12
|
+
class Base < Thor::Group
|
13
|
+
include Thor::Actions
|
14
|
+
|
15
|
+
add_runtime_options!
|
16
|
+
strict_args_position!
|
17
|
+
|
18
|
+
class << self
|
19
|
+
def source_root
|
20
|
+
default_source_root
|
21
|
+
end
|
22
|
+
|
23
|
+
def default_command_root
|
24
|
+
File.dirname(__FILE__)
|
25
|
+
end
|
26
|
+
|
27
|
+
def default_source_root
|
28
|
+
File.join(default_command_root, "..", "templates")
|
29
|
+
end
|
30
|
+
|
31
|
+
def banner
|
32
|
+
banner = "bindle #{display_name}"
|
33
|
+
banner << " #{self.arguments.map(&:usage).join(' ')}" if self.arguments.length > 0
|
34
|
+
banner << " [options]"
|
35
|
+
end
|
36
|
+
|
37
|
+
def display_name
|
38
|
+
self.to_s.split("::")
|
39
|
+
.reject { |item| ["Bindle", "Commands"].include?(item) }
|
40
|
+
.map(&:underscore)
|
41
|
+
.join(" ")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'bindle/commands/base'
|
3
|
+
require 'librarian/action/resolve'
|
4
|
+
require 'librarian/action/install'
|
5
|
+
require 'librarian-chef'
|
6
|
+
|
7
|
+
module Bindle
|
8
|
+
module Commands
|
9
|
+
class Init < Base
|
10
|
+
argument :name, type: :string, required: false,
|
11
|
+
desc: "Name of the project to create (empty for current directory)"
|
12
|
+
|
13
|
+
def main
|
14
|
+
unless name.nil?
|
15
|
+
self.destination_root = project_name
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def kniferb
|
20
|
+
empty_directory ".chef"
|
21
|
+
template "knife.rb", ".chef/knife.rb"
|
22
|
+
end
|
23
|
+
|
24
|
+
def vagrantfile
|
25
|
+
template "Vagrantfile"
|
26
|
+
end
|
27
|
+
|
28
|
+
def cheffile
|
29
|
+
template "Cheffile"
|
30
|
+
end
|
31
|
+
|
32
|
+
def gemfile
|
33
|
+
template "Gemfile"
|
34
|
+
end
|
35
|
+
|
36
|
+
def librarian
|
37
|
+
directory "librarian", ".librarian"
|
38
|
+
end
|
39
|
+
|
40
|
+
def chef
|
41
|
+
empty_directory "chef"
|
42
|
+
|
43
|
+
inside "chef" do
|
44
|
+
directory "roles"
|
45
|
+
|
46
|
+
template "README.md"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def gitignore
|
51
|
+
if File.exists?(File.join(self.destination_root, ".git"))
|
52
|
+
append_to_file ".gitignore", <<-IGNORE.strip_heredoc
|
53
|
+
/chef/cookbooks
|
54
|
+
/chef/tmp
|
55
|
+
/chef/packages
|
56
|
+
/.vagrant
|
57
|
+
IGNORE
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# From railties: github.com/rails/rails/blob/f96478369e/railties/lib/rails/generators/app_base.rb#L253
|
62
|
+
def bundle_install
|
63
|
+
say_status :running, "bundle install"
|
64
|
+
|
65
|
+
_bundle_command = Gem.bin_path('bundler', 'bundle')
|
66
|
+
|
67
|
+
require 'bundler'
|
68
|
+
|
69
|
+
if !options[:pretend]
|
70
|
+
Bundler.with_clean_env do
|
71
|
+
print `"#{Gem.ruby}" "#{_bundle_command}" install --binstubs`
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def install_cookbooks
|
77
|
+
say_status :running, "librarian-chef install"
|
78
|
+
|
79
|
+
if !options[:pretend]
|
80
|
+
environment = Librarian::Chef::Environment.new({pwd: self.destination_root})
|
81
|
+
Librarian::Action::Resolve.new(environment).run
|
82
|
+
Librarian::Action::Install.new(environment).run
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
protected
|
87
|
+
|
88
|
+
def project_name
|
89
|
+
@project_name ||= begin
|
90
|
+
if name.nil?
|
91
|
+
File.basename(Dir.getwd).tr(".", "-")
|
92
|
+
else
|
93
|
+
name
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
Vagrant.configure("2") do |config|
|
5
|
+
config.vm.box = "quantal"
|
6
|
+
config.vm.box_url = "http://cloud-images.ubuntu.com/vagrant/quantal/current/quantal-server-cloudimg-amd64-vagrant-disk1.box"
|
7
|
+
|
8
|
+
config.vm.network :forwarded_port, guest: 80, host: 8080
|
9
|
+
|
10
|
+
config.vm.network :private_network, ip: "33.33.33.10"
|
11
|
+
|
12
|
+
config.vm.provision :chef_solo do |chef|
|
13
|
+
chef.cookbooks_path = "chef/cookbooks"
|
14
|
+
chef.roles_path = "chef/roles"
|
15
|
+
|
16
|
+
chef.add_role "base"
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Veewee::Config.run do |config|
|
2
|
+
|
3
|
+
# Initialize convenience vars
|
4
|
+
cwd = File.dirname(__FILE__)
|
5
|
+
env = config.veewee.env
|
6
|
+
|
7
|
+
# These env settings will override default settings
|
8
|
+
env.cwd = cwd
|
9
|
+
env.definition_dir = File.join(cwd, 'chef/definitions')
|
10
|
+
env.template_path = [File.join(cwd, 'chef/templates')]
|
11
|
+
env.iso_dir = File.join(cwd, 'chef/iso')
|
12
|
+
env.validation_dir = File.join(cwd, 'chef/validation')
|
13
|
+
end
|
File without changes
|
@@ -0,0 +1,12 @@
|
|
1
|
+
cookbook_path ["chef/cookbooks", "chef/site-cookbooks"]
|
2
|
+
node_path "chef/nodes"
|
3
|
+
role_path "chef/roles"
|
4
|
+
data_bag_path "chef/data_bags"
|
5
|
+
|
6
|
+
knife[:ssh_user] = ENV['AWS_SSH_USER'] || "ubuntu"
|
7
|
+
knife[:flavor] = ENV['AWS_DEFAULT_FLAVOR'] || "t1.micro"
|
8
|
+
knife[:image] = ENV['AWS_DEFAULT_AMI'] || "ami-8b0772e2"
|
9
|
+
knife[:aws_access_key_id] = ENV['AWS_ACCESS_KEY_ID']
|
10
|
+
knife[:aws_secret_access_key] = ENV['AWS_SECRET_ACCESS_KEY']
|
11
|
+
knife[:aws_ssh_key_id] = ENV['AWS_SECURITY_KEY_NAME']
|
12
|
+
knife[:identity_file] = ENV['AWS_IDENTITY_FILE']
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'bindle'
|
3
|
+
require 'bindle/commands/init'
|
4
|
+
|
5
|
+
module Bindle
|
6
|
+
module Commands
|
7
|
+
class TestInit < MiniTest::Unit::TestCase
|
8
|
+
|
9
|
+
def test_shows_help
|
10
|
+
output = capture(:stdout) do
|
11
|
+
system("#{binary} init --help")
|
12
|
+
end
|
13
|
+
|
14
|
+
assert_match /Usage:\n bindle init/, output
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_displays_creation_of_files
|
18
|
+
output = capture(:stdout) do
|
19
|
+
Init.start(['--pretend'], {destination_root: destination_root})
|
20
|
+
end
|
21
|
+
|
22
|
+
files = %w( Vagrantfile
|
23
|
+
Cheffile
|
24
|
+
Gemfile
|
25
|
+
.librarian
|
26
|
+
.librarian/chef/config
|
27
|
+
chef
|
28
|
+
chef/roles
|
29
|
+
chef/roles/base.rb
|
30
|
+
chef/README.md )
|
31
|
+
|
32
|
+
files.each do |file|
|
33
|
+
assert_match /create\s\s#{file}/, output
|
34
|
+
end
|
35
|
+
|
36
|
+
assert_match /librarian-chef\sinstall/, output
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
data/test/helper.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'bundler'
|
5
|
+
rescue LoadError => e
|
6
|
+
STDERR.puts e.message
|
7
|
+
STDERR.puts "Run `gem install bundler` to install Bundler."
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
|
11
|
+
begin
|
12
|
+
Bundler.setup(:default, :development, :test)
|
13
|
+
rescue Bundler::BundlerError => e
|
14
|
+
STDERR.puts e.message
|
15
|
+
STDERR.puts "Run `bundle install` to install missing gems."
|
16
|
+
exit e.status_code
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'active_support/concern'
|
20
|
+
require 'minitest/unit'
|
21
|
+
require 'pry'
|
22
|
+
|
23
|
+
ENV['THOR_SHELL'] = "Thor::Shell::Basic"
|
24
|
+
|
25
|
+
class MiniTest::Unit::TestCase
|
26
|
+
# The location of the command line binary
|
27
|
+
def binary
|
28
|
+
File.join(File.dirname(__FILE__), "../bin/bindle")
|
29
|
+
end
|
30
|
+
|
31
|
+
# Using until updated activesupport is stable
|
32
|
+
# Captures the given stream and returns it:
|
33
|
+
#
|
34
|
+
# stream = capture(:stdout) { puts 'notice' }
|
35
|
+
# stream # => "notice\n"
|
36
|
+
#
|
37
|
+
# stream = capture(:stderr) { warn 'error' }
|
38
|
+
# stream # => "error\n"
|
39
|
+
#
|
40
|
+
# even for subprocesses:
|
41
|
+
#
|
42
|
+
# stream = capture(:stdout) { system('echo notice') }
|
43
|
+
# stream # => "notice\n"
|
44
|
+
#
|
45
|
+
# stream = capture(:stderr) { system('echo error 1>&2') }
|
46
|
+
# stream # => "error\n"
|
47
|
+
def capture(stream)
|
48
|
+
stream = stream.to_s
|
49
|
+
captured_stream = Tempfile.new(stream)
|
50
|
+
stream_io = eval("$#{stream}")
|
51
|
+
origin_stream = stream_io.dup
|
52
|
+
stream_io.reopen(captured_stream)
|
53
|
+
|
54
|
+
yield
|
55
|
+
|
56
|
+
stream_io.rewind
|
57
|
+
return captured_stream.read
|
58
|
+
ensure
|
59
|
+
captured_stream.unlink
|
60
|
+
stream_io.reopen(origin_stream)
|
61
|
+
end
|
62
|
+
|
63
|
+
def destination_root
|
64
|
+
tmp_path 'test_tmp'
|
65
|
+
end
|
66
|
+
|
67
|
+
def tmp_path(*args)
|
68
|
+
@tmp_path ||= File.realpath(Dir.mktmpdir)
|
69
|
+
File.join(@tmp_path, *args)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
MiniTest::Unit.autorun
|
data/test/test_bindle.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'bindle'
|
3
|
+
|
4
|
+
module Bindle
|
5
|
+
class TestBindle < MiniTest::Unit::TestCase
|
6
|
+
def test_version
|
7
|
+
major = Bindle::VERSION.const_get('MAJOR')
|
8
|
+
minor = Bindle::VERSION.const_get('MINOR')
|
9
|
+
patch = Bindle::VERSION.const_get('PATCH')
|
10
|
+
|
11
|
+
assert(!major.nil?, 'should have a MAJOR constant')
|
12
|
+
assert(!minor.nil?, 'should have a MINOR constant')
|
13
|
+
assert(!patch.nil?, 'should have a PATCH constant')
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_version_string
|
17
|
+
version_string = Bindle::VERSION.const_get('STRING')
|
18
|
+
|
19
|
+
assert(!version_string.empty?, 'should have a VERSION STRING constant')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,215 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bindle
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Scott Bader
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-06-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: chef
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
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: librarian-chef
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: thor
|
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
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rdoc
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubygems-tasks
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: pry
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: m
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ~>
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 1.3.1
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ~>
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 1.3.1
|
153
|
+
description: bindle is a server and development environment provisioning tool. Using
|
154
|
+
Chef, Vagrant, and Fog it organizes and simplifies the creation and management of
|
155
|
+
your development environment and allows you to use the same provisioning tools on
|
156
|
+
your production servers.
|
157
|
+
email: sb@scottbader.org
|
158
|
+
executables:
|
159
|
+
- bindle
|
160
|
+
extensions: []
|
161
|
+
extra_rdoc_files: []
|
162
|
+
files:
|
163
|
+
- .gitignore
|
164
|
+
- Gemfile
|
165
|
+
- LICENSE.txt
|
166
|
+
- README.md
|
167
|
+
- Rakefile
|
168
|
+
- bin/bindle
|
169
|
+
- bindle.gemspec
|
170
|
+
- lib/bindle.rb
|
171
|
+
- lib/bindle/cli.rb
|
172
|
+
- lib/bindle/commands/base.rb
|
173
|
+
- lib/bindle/commands/init.rb
|
174
|
+
- lib/bindle/templates/Cheffile
|
175
|
+
- lib/bindle/templates/Gemfile
|
176
|
+
- lib/bindle/templates/Vagrantfile
|
177
|
+
- lib/bindle/templates/Veeweefile
|
178
|
+
- lib/bindle/templates/chef/README.md
|
179
|
+
- lib/bindle/templates/chef/roles/base.rb
|
180
|
+
- lib/bindle/templates/knife.rb
|
181
|
+
- lib/bindle/templates/librarian/chef/config
|
182
|
+
- lib/bindle/version.rb
|
183
|
+
- test/bindle/commands/test_init.rb
|
184
|
+
- test/bindle/test_cli.rb
|
185
|
+
- test/helper.rb
|
186
|
+
- test/test_bindle.rb
|
187
|
+
homepage: https://github.com/sbader/bindle#readme
|
188
|
+
licenses:
|
189
|
+
- MIT
|
190
|
+
metadata: {}
|
191
|
+
post_install_message:
|
192
|
+
rdoc_options: []
|
193
|
+
require_paths:
|
194
|
+
- lib
|
195
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
196
|
+
requirements:
|
197
|
+
- - '>='
|
198
|
+
- !ruby/object:Gem::Version
|
199
|
+
version: '0'
|
200
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
201
|
+
requirements:
|
202
|
+
- - '>='
|
203
|
+
- !ruby/object:Gem::Version
|
204
|
+
version: '0'
|
205
|
+
requirements: []
|
206
|
+
rubyforge_project:
|
207
|
+
rubygems_version: 2.0.0
|
208
|
+
signing_key:
|
209
|
+
specification_version: 4
|
210
|
+
summary: bindle is a server and development environment provisioning tool
|
211
|
+
test_files:
|
212
|
+
- test/bindle/commands/test_init.rb
|
213
|
+
- test/bindle/test_cli.rb
|
214
|
+
- test/helper.rb
|
215
|
+
- test/test_bindle.rb
|