cap-ssh 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cap-ssh.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Alex Gibbons
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
+ # Cap::SSH
2
+
3
+ Initiate an SSH session from your Capistrano configured servers.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'cap-ssh'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install cap-ssh
18
+
19
+ ## Usage
20
+
21
+ Require the gem in your deployment script:
22
+
23
+ # config/deploy.rb
24
+ require 'cap-ssh'
25
+
26
+ To start an ssh session to your configured app server:
27
+
28
+ cap ssh
29
+
30
+
31
+ To connect to a server in a different role:
32
+
33
+ cap ssh ROLE=web
34
+
35
+ If you have multiple servers for a role you will be presented with a list of servers to choose from.
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/cap-ssh.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cap-ssh/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "cap-ssh"
8
+ gem.version = Cap::SSH::VERSION
9
+ gem.authors = ["Alex Gibbons"]
10
+ gem.email = ["alex.gibbons@gmail.com"]
11
+ gem.description = %q{Initiate an SSH session from your Capistrano configured servers.}
12
+ gem.summary = %q{Capistrano recipe to connect to servers over SSH}
13
+ gem.homepage = ""
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
+ end
@@ -0,0 +1,5 @@
1
+ module Cap
2
+ module SSH
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
data/lib/cap-ssh.rb ADDED
@@ -0,0 +1,61 @@
1
+ require "cap-ssh/version"
2
+
3
+
4
+ Capistrano::Configuration.instance(true).load do
5
+
6
+ namespace :ssh do
7
+
8
+ desc <<-DESC
9
+ Start an ssh session to your servers.\
10
+ By default will choose a server from your 'app' role. Use the 'ROLE'\
11
+ enivornment variable to choose a different role. If more than one\
12
+ server exists for a given role then you will be prompted to choose\
13
+ the server from a list.
14
+ DESC
15
+ task :default do
16
+ start
17
+ end
18
+
19
+ task :start do
20
+ role = (ENV['ROLE'] || :app).to_sym
21
+ servers = roles[role].servers
22
+
23
+ # pick server from a list
24
+ if servers.size > 1
25
+ puts "Pick a server to connect to:"
26
+ servers.each_with_index do |server, i|
27
+ puts "\t#{i + 1}: #{server.host}"
28
+ end
29
+ default = 1
30
+ selected = Capistrano::CLI.ui.ask("Enter number (#{default})")
31
+ selected = default if selected.empty?
32
+ server = servers[selected.to_i - 1]
33
+ else
34
+ server = servers.first
35
+ end
36
+
37
+ logger.info "Deploy Directory: #{deploy_to}"
38
+
39
+ Capistrano::SSH.connection_strategy(server, self) do |host, user, connection_options|
40
+ start_session(host, user, connection_options)
41
+ end
42
+ end
43
+
44
+
45
+
46
+ def start_session(*args)
47
+ Kernel.exec connect_command(*args)
48
+ end
49
+
50
+ def connect_command(host, user, connection_options)
51
+ [
52
+ 'ssh ',
53
+ user ? "#{user}@" : nil,
54
+ host,
55
+ connection_options[:port] ? ":#{connection_options[:port]}" : nil,
56
+ connection_options[:forward_agent] ? " -a" : nil
57
+ ].reject(&:nil?).join('')
58
+ end
59
+
60
+ end
61
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cap-ssh
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Alex Gibbons
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-15 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Initiate an SSH session from your Capistrano configured servers.
15
+ email:
16
+ - alex.gibbons@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE.txt
24
+ - README.md
25
+ - Rakefile
26
+ - cap-ssh.gemspec
27
+ - lib/cap-ssh.rb
28
+ - lib/cap-ssh/version.rb
29
+ homepage: ''
30
+ licenses: []
31
+ post_install_message:
32
+ rdoc_options: []
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubyforge_project:
49
+ rubygems_version: 1.8.24
50
+ signing_key:
51
+ specification_version: 3
52
+ summary: Capistrano recipe to connect to servers over SSH
53
+ test_files: []