cap_vagrant 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/.rvmrc ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 1.9.2" > .rvmrc
9
+ environment_id="ruby-1.9.2-p318@cap_vagrant"
10
+
11
+ # Uncomment the following lines if you want to verify rvm version per project
12
+ # rvmrc_rvm_version="1.15.8 ()" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+
18
+ # First we attempt to load the desired environment directly from the environment
19
+ # file. This is very fast and efficient compared to running through the entire
20
+ # CLI and selector. If you want feedback on which environment was used then
21
+ # insert the word 'use' after --create as this triggers verbose mode.
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
+ then
25
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
+ [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
+ \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
+ else
29
+ # If the environment file has not yet been created, use the RVM CLI to select.
30
+ rvm --create "$environment_id" || {
31
+ echo "Failed to create RVM environment '${environment_id}'."
32
+ return 1
33
+ }
34
+ fi
data/CHANGELOG.rdoc ADDED
File without changes
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cap_vagrant.gemspec
4
+ gemspec
5
+
6
+ gem "capistrano"
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 TODO: Write your name
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.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # CapVagrant
2
+
3
+ Create a vagrant stage file for your capistrano deployment.
4
+
5
+ ## Requirements
6
+
7
+ * Capistrano
8
+ * Capistrano Multistage Extension
9
+ * Vagrant
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile in the same group as capistrano:
14
+
15
+ gem 'cap_vagrant'
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install cap_vagrant
24
+
25
+ ## Usage
26
+
27
+ Usage is pretty simple, just run `cap_vagrant` from the base directory of your project. It will create a config/deploy/vagrant.rb file with the current output of `vagrant ssh-config`. You can define the name of the stage by passing cap_vagrant a name option (EXE `cap_vagrant --name stage_name` or `cap_vagrant -n stage_name`)
28
+
29
+ You will have to add the stage to your deploy.rb file manually.
30
+
31
+ $ set :stages, %w(production staging vagrant)
32
+
33
+ Then run `cap vagrant deploy:setup` or whatever your setup process is.
34
+
35
+ NOTE: When you reload a vagrant instance you might need to run `cap_vagrant -u` to update the port inforamation.
36
+
37
+ ## Contributing
38
+
39
+ 1. Fork it
40
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
41
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
42
+ 4. Push to the branch (`git push origin my-new-feature`)
43
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/cap_vagrant ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require "cap_vagrant/app"
3
+
4
+ App.start
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cap_vagrant/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "cap_vagrant"
8
+ gem.version = CapVagrant::VERSION
9
+ gem.authors = ["Lloyd Philbrook"]
10
+ gem.email = ["lloyd@firebellydesign.com"]
11
+ gem.description = %q{Create a vagrant stage file for your capistrano deployment.}
12
+ gem.summary = %q{Create a vagrant stage file for your capistrano deployment.}
13
+ gem.homepage = "https://github.com/firebelly/cap_vagrant"
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 "thor"
21
+ end
@@ -0,0 +1,57 @@
1
+ require "cap_vagrant/version"
2
+ require 'thor'
3
+ require 'erb'
4
+
5
+ class App < Thor
6
+
7
+ desc "Setup a vagrant stage file.", "Create a vagrant stage file for your capistrano deployment."
8
+ method_option :name, :type => :string, :default => "vagrant", :aliases => "-n", :desc => "The name you want to give the stage."
9
+ method_option :update, :type => :boolean, :aliases => '-u', :desc => "If you ever restart your VM, it might change port info on you. This will just update the port value."
10
+ method_option :version, :type => :boolean
11
+ def setup
12
+ if options[:version]
13
+ puts CapVagrant::VERSION
14
+ exit
15
+ end
16
+ check_path?('Capfile', "Have you already setup Capistrano?")
17
+ check_path?('config/deploy', "Are you using the multistage extension?")
18
+ check_path?('Vagrantfile', "Have you already setup Vagrant?")
19
+
20
+ ssh_details = {'HostName' => 'host', 'User' => 'user', 'Port' => 'port', 'IdentityFile' => "keys"}
21
+ vars = {'name' => options[:name]}
22
+
23
+ ssh_config=`vagrant ssh-config`.split("\n ") ; result=$?.success?
24
+ abort "Calling vagrant ssh-config failed." unless result
25
+
26
+ ssh_config.each do |i|
27
+ k,v = i.split(" ")
28
+ vars[ssh_details[k]] = v if ssh_details[k]
29
+ end
30
+
31
+ stage_file = File.join('.', 'config', 'deploy', "#{options[:name]}.rb")
32
+ if options[:update]
33
+ check_path?(stage_file)
34
+ text = File.read(stage_file)
35
+ replace = text.gsub(/:port.*\n/, ":port] = #{vars['port']}\n")
36
+ File.open(stage_file, 'w') do |f|
37
+ f.puts replace
38
+ end
39
+ else
40
+ config = ERB.new(File.read(File.join(File.dirname(__FILE__), 'templates', 'stage.rb.erb')))
41
+ File.open(stage_file, 'w') do |f|
42
+ f.write config.result(binding)
43
+ end
44
+ end
45
+ end
46
+
47
+ default_task :setup
48
+
49
+ no_tasks do
50
+ def check_path?(path, message = '')
51
+ full_path = File.expand_path(path)
52
+ unless File.exists?(full_path)
53
+ abort "Could not find `#{full_path}`? #{message}"
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,8 @@
1
+ # config/deploy/<%= vars['name'] %>.rb
2
+ # Generated by cap_vagrant
3
+ server "<%= vars['host'] %>", :app, :web, :db, :primary => true
4
+ set :rails_env, "<%= vars['name'] %>"
5
+ default_environment["RAILS_ENV"] = "#{rails_env}"
6
+ set :user, "<%= vars['user'] %>"
7
+ ssh_options[:keys] = ['<%= vars['keys'] %>']
8
+ ssh_options[:port] = <%= vars['port'] %>
@@ -0,0 +1,3 @@
1
+ module CapVagrant
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cap_vagrant
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Lloyd Philbrook
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-02 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: thor
16
+ requirement: &16237200 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *16237200
25
+ description: Create a vagrant stage file for your capistrano deployment.
26
+ email:
27
+ - lloyd@firebellydesign.com
28
+ executables:
29
+ - cap_vagrant
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - .gitignore
34
+ - .rvmrc
35
+ - CHANGELOG.rdoc
36
+ - Gemfile
37
+ - LICENSE.txt
38
+ - README.md
39
+ - Rakefile
40
+ - bin/cap_vagrant
41
+ - cap_vagrant.gemspec
42
+ - lib/cap_vagrant/app.rb
43
+ - lib/cap_vagrant/templates/stage.rb.erb
44
+ - lib/cap_vagrant/version.rb
45
+ homepage: https://github.com/firebelly/cap_vagrant
46
+ licenses: []
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubyforge_project:
65
+ rubygems_version: 1.8.17
66
+ signing_key:
67
+ specification_version: 3
68
+ summary: Create a vagrant stage file for your capistrano deployment.
69
+ test_files: []