cap-pack 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -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/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cap-pack.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 John Bintz
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
+ # Cap::Pack
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'cap-pack'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install cap-pack
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 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/cap-pack/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["John Bintz"]
6
+ gem.email = ["john@coswellproductions.com"]
7
+ gem.description = %q{Things I do for Capistrano deploys.}
8
+ gem.summary = %q{Things I do for Capistrano deploys.}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "cap-pack"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Cap::Pack::VERSION
17
+ end
@@ -0,0 +1,36 @@
1
+ Capistrano::Configuration.instance.load do
2
+ _cset(:user_shell_method) { %{bash -l -c} }
3
+
4
+ def tty_ssh_command_in_current_host(command, hostname = current_host)
5
+ user_ssh_command = fetch(:user, nil) ? "-l #{fetch(:user)}" : ''
6
+
7
+ user_ssh_command << " #{ENV['SSH_OPTS']}" if ENV['SSH_OPTS']
8
+
9
+ exec %{ssh #{user_ssh_command} #{hostname} -t "#{user_shell_method} 'cd #{current_path} && #{command}'"}
10
+ end
11
+
12
+ def current_host
13
+ ENV['HOST'] || find_servers_for_task(current_task).first
14
+ end
15
+
16
+ def switch_user(new_user)
17
+ old_user = user
18
+ set :user, new_user
19
+ close_sessions
20
+ yield
21
+ set :user, old_user
22
+ close_sessions
23
+ end
24
+
25
+ def close_sessions
26
+ sessions.values.each { |session| session.close }
27
+ sessions.clear
28
+ end
29
+
30
+ def rake(cmd, env = {})
31
+ run "cd #{latest_release} && RAILS_ENV=#{rails_env} #{env.collect { |k, v| "#{k}=#{v}" }.join(' ')} bundle exec rake #{cmd}"
32
+ end
33
+
34
+ Dir[File.expand_path('../cap-pack/recipes/**/*.rb', __FILE__)].each { |f| load f }
35
+ end
36
+
@@ -0,0 +1,5 @@
1
+ desc "Connect via SSH and end up in the app's directory"
2
+ task :ssh do
3
+ tty_ssh_command_in_current_host("bash")
4
+ end
5
+
@@ -0,0 +1,7 @@
1
+ namespace :rails do
2
+ desc "Open the rails console on one of the remote servers"
3
+ task :console, :roles => :app do
4
+ tty_ssh_command_in_current_host("script/rails c #{rails_env}")
5
+ end
6
+ end
7
+
@@ -0,0 +1,9 @@
1
+ namespace :rails do
2
+ desc 'Migrate the database if db/schema.rb has changed since the last revision'
3
+ task :migrate_if_changed do
4
+ if !(result = %x{git log #{current_revision}..#{revision} db/schema.rb}.strip).empty?
5
+ top.deploy.migrate
6
+ end
7
+ end
8
+ end
9
+
@@ -0,0 +1,9 @@
1
+ desc "Tail all or a single remote file"
2
+ task :tail do
3
+ pattern = ENV["LOGFILE_PATTERN"] || "*.log"
4
+ run "tail -f #{shared_path}/log/#{pattern}" do |channel, stream, data|
5
+ puts "#{data}"
6
+ break if stream == :err
7
+ end
8
+ end
9
+
@@ -0,0 +1,5 @@
1
+ module Cap
2
+ module Pack
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,57 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cap-pack
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - John Bintz
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-22 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Things I do for Capistrano deploys.
15
+ email:
16
+ - john@coswellproductions.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE
24
+ - README.md
25
+ - Rakefile
26
+ - cap-pack.gemspec
27
+ - lib/cap-pack.rb
28
+ - lib/cap-pack/recipes/console.rb
29
+ - lib/cap-pack/recipes/rails/console.rb
30
+ - lib/cap-pack/recipes/rails/migrate_if_changed.rb
31
+ - lib/cap-pack/recipes/tail.rb
32
+ - lib/cap-pack/version.rb
33
+ homepage: ''
34
+ licenses: []
35
+ post_install_message:
36
+ rdoc_options: []
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ none: false
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ! '>='
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ none: false
51
+ requirements: []
52
+ rubyforge_project:
53
+ rubygems_version: 1.8.24
54
+ signing_key:
55
+ specification_version: 3
56
+ summary: Things I do for Capistrano deploys.
57
+ test_files: []