wemux-pair 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.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/.ruby-gemset.template +1 -0
- data/.ruby-version.template +1 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +55 -0
- data/Rakefile +6 -0
- data/bin/pair +5 -0
- data/etc/sample_config.yml +4 -0
- data/lib/wemux-pair.rb +1 -0
- data/lib/wemux/pair.rb +14 -0
- data/lib/wemux/pair/client_tunnel.rb +15 -0
- data/lib/wemux/pair/clipboard.rb +12 -0
- data/lib/wemux/pair/commands/check_for_pair_user.rb +18 -0
- data/lib/wemux/pair/commands/check_for_wemux.rb +27 -0
- data/lib/wemux/pair/commands/command.rb +22 -0
- data/lib/wemux/pair/commands/create_sample_config.rb +44 -0
- data/lib/wemux/pair/commands/print_usage.rb +16 -0
- data/lib/wemux/pair/commands/set_pow_host.rb +40 -0
- data/lib/wemux/pair/commands/start_client_session.rb +31 -0
- data/lib/wemux/pair/commands/start_host_session.rb +33 -0
- data/lib/wemux/pair/commands/stop_session.rb +14 -0
- data/lib/wemux/pair/configuration.rb +24 -0
- data/lib/wemux/pair/host_tunnel.rb +15 -0
- data/lib/wemux/pair/pair_connection.rb +33 -0
- data/lib/wemux/pair/runner.rb +47 -0
- data/lib/wemux/pair/ssh_tunnel.rb +56 -0
- data/lib/wemux/pair/version.rb +5 -0
- data/spec/fixtures/test_config.yml +4 -0
- data/spec/spec_helper.rb +22 -0
- data/spec/wemux/pair/commands/command_spec.rb +34 -0
- data/spec/wemux/pair/configuration_spec.rb +55 -0
- data/wemux-pair.gemspec +27 -0
- metadata +155 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8ac2bde0e45704ab82faa8b05bf44ead4308bae7
|
4
|
+
data.tar.gz: 38f0262531884f4c63711682b3b8208e97acb34e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9e7965846cd2aae34d9210840b4eef1a0dd622cbdb7ce5d8409154e19c0039833ebfd78757549ed2f1956e8386c9b0de7b27bf995fd7e25318b916652cc82d3e
|
7
|
+
data.tar.gz: bc71162c6fa814c58a00747926507f69df88c8be2afb6d69557302cd6d7d74a2fe7bc91af009e3fa10637893ed34902f0a31969b250d1e41bc32478491c4785e
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
wepair
|
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.1.1
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Shaun Dern
|
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,55 @@
|
|
1
|
+
[](https://travis-ci.org/substantial/wemux-pair)
|
2
|
+
|
3
|
+
# Wemux::Pair
|
4
|
+
|
5
|
+
Firewall-punching remote pairing with wemux made easy
|
6
|
+
|
7
|
+
## Requirements
|
8
|
+
|
9
|
+
Have a box that is accessible to both users via ssh.
|
10
|
+
|
11
|
+
First time set up for hosts (assuming OSX):
|
12
|
+
|
13
|
+
1. Create a <pairprogramming> user.
|
14
|
+
2. Give that user remote login access via System Preferences>Sharing>Remote Login
|
15
|
+
3. Add client's ssh keys to ~<pairprogramming>/.ssh/authorized_keys
|
16
|
+
4. In ~<pairprogramming>/.bash_profile should be: "wemux attach; exit"
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
Add this line to your application's Gemfile:
|
21
|
+
|
22
|
+
gem 'wemux-pair'
|
23
|
+
|
24
|
+
And then execute:
|
25
|
+
|
26
|
+
$ bundle
|
27
|
+
|
28
|
+
Or install it yourself as:
|
29
|
+
|
30
|
+
$ gem install wemux-pair
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
|
35
|
+
Generate `.pair.yml` configuration, run `$pair --init`
|
36
|
+
|
37
|
+
Print Usage: `$ pair --help`
|
38
|
+
|
39
|
+
Host:
|
40
|
+
Start a [wemux](https://github.com/zolrath/wemux) session
|
41
|
+
|
42
|
+
Then run `$ pair host`
|
43
|
+
|
44
|
+
Client:
|
45
|
+
Ensure you're not in a wemux/tmux session
|
46
|
+
|
47
|
+
Run `$ pair <host port>`
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
1. Fork it
|
52
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
53
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
54
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
55
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/pair
ADDED
data/lib/wemux-pair.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require_relative "wemux/pair"
|
data/lib/wemux/pair.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative 'command'
|
2
|
+
|
3
|
+
module Wemux
|
4
|
+
module Pair
|
5
|
+
module Commands
|
6
|
+
class CheckForPairUser < Command
|
7
|
+
def execute
|
8
|
+
return if system("id -u #{pair_user} > /dev/null 2>&1")
|
9
|
+
puts "There is some setup to do before this will work."
|
10
|
+
puts "1. Create a user named \"#{pair_user}\""
|
11
|
+
puts "2. Put team's ssh public keys in ~/#{pair_user}/.ssh/authorized_keys (make sure it is owned by #{pair_user} and chmod 600)."
|
12
|
+
|
13
|
+
exit 1
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative 'command'
|
2
|
+
|
3
|
+
module Wemux
|
4
|
+
module Pair
|
5
|
+
module Commands
|
6
|
+
class CheckForWemux < Command
|
7
|
+
def execute
|
8
|
+
return if in_wemux?
|
9
|
+
|
10
|
+
if system("command -v wemux > /dev/null 2>&1")
|
11
|
+
puts "Please run from within wemux"
|
12
|
+
else
|
13
|
+
puts "Please install wemux and run from within it: https://github.com/zolrath/wemux"
|
14
|
+
end
|
15
|
+
|
16
|
+
exit 1
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def in_wemux?
|
22
|
+
ENV['TMUX'] =~ /wemux/
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Wemux
|
2
|
+
module Pair
|
3
|
+
module Commands
|
4
|
+
class Command
|
5
|
+
def self.run(attrs={})
|
6
|
+
new(attrs).execute
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(attrs={})
|
10
|
+
attrs.each do |attr, value|
|
11
|
+
self.class.__send__(:attr_reader, attr)
|
12
|
+
instance_variable_set("@#{attr}", value)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def execute
|
17
|
+
raise NotImplementedError
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require_relative 'command'
|
2
|
+
require_relative '../configuration'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
module Wemux
|
6
|
+
module Pair
|
7
|
+
module Commands
|
8
|
+
class CreateSampleConfig < Command
|
9
|
+
def execute
|
10
|
+
return warn_config_exists if config_exist?
|
11
|
+
copy_file(config_template, config_path)
|
12
|
+
puts "Generated file at #{config_path}"
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def copy_file(src, dest)
|
18
|
+
FileUtils.cp(src, dest)
|
19
|
+
end
|
20
|
+
|
21
|
+
def config_template
|
22
|
+
File.join(Wemux::Pair.root, 'etc', 'sample_config.yml')
|
23
|
+
end
|
24
|
+
|
25
|
+
def config_file
|
26
|
+
Wemux::Pair::Configuration::PAIR_CONFIG
|
27
|
+
end
|
28
|
+
|
29
|
+
def config_path
|
30
|
+
File.absolute_path(config_file)
|
31
|
+
end
|
32
|
+
|
33
|
+
def config_exist?
|
34
|
+
File.exist? config_file
|
35
|
+
end
|
36
|
+
|
37
|
+
def warn_config_exists
|
38
|
+
puts "Skipped: config file already exists at #{config_path}"
|
39
|
+
false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require_relative 'command'
|
2
|
+
|
3
|
+
module Wemux
|
4
|
+
module Pair
|
5
|
+
module Commands
|
6
|
+
class PrintUsage < Command
|
7
|
+
def execute
|
8
|
+
puts "pair host"
|
9
|
+
puts "pair stop"
|
10
|
+
puts "pair <number>"
|
11
|
+
puts "pair --init # Create a sample .pair.yml file."
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative 'command'
|
2
|
+
|
3
|
+
module Wemux
|
4
|
+
module Pair
|
5
|
+
module Commands
|
6
|
+
class SetPowHost < Command
|
7
|
+
def execute
|
8
|
+
return unless pow_host
|
9
|
+
return unless pow_installed?
|
10
|
+
write_pow_host
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def pow_installed?
|
16
|
+
if Dir.exists?(pow_directory)
|
17
|
+
true
|
18
|
+
else
|
19
|
+
puts "Couldn't find #{pow_directory}, you can get it at http://pow.cx/"
|
20
|
+
false
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def write_pow_host
|
25
|
+
File.open(pow_config, 'w+') do |f|
|
26
|
+
f.puts(server_port)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def pow_directory
|
31
|
+
File.expand_path(File.join("~", ".pow"))
|
32
|
+
end
|
33
|
+
|
34
|
+
def pow_config
|
35
|
+
File.expand_path(File.join(pow_directory, pow_host))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require_relative 'command'
|
2
|
+
require_relative '../client_tunnel'
|
3
|
+
require_relative '../pair_connection'
|
4
|
+
|
5
|
+
module Wemux
|
6
|
+
module Pair
|
7
|
+
module Commands
|
8
|
+
class StartClientSession < Command
|
9
|
+
def execute
|
10
|
+
if in_tmux?
|
11
|
+
puts "Please do not run from within tmux or wemux"
|
12
|
+
exit 1
|
13
|
+
end
|
14
|
+
|
15
|
+
tunnel = ClientTunnel.new(port_offset)
|
16
|
+
if tunnel.open
|
17
|
+
connection = PairConnection.new(tunnel)
|
18
|
+
connection.connect
|
19
|
+
else
|
20
|
+
ClientTunnel.tunnel_failure!
|
21
|
+
end
|
22
|
+
end
|
23
|
+
private
|
24
|
+
|
25
|
+
def in_tmux?
|
26
|
+
ENV['TMUX']
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative 'command'
|
2
|
+
require_relative '../clipboard'
|
3
|
+
require_relative '../host_tunnel'
|
4
|
+
|
5
|
+
module Wemux
|
6
|
+
module Pair
|
7
|
+
module Commands
|
8
|
+
class StartHostSession < Command
|
9
|
+
def execute
|
10
|
+
tunnel = HostTunnel.new(offset)
|
11
|
+
|
12
|
+
if tunnel.open
|
13
|
+
command = "pair #{offset}"
|
14
|
+
Clipboard.copy command
|
15
|
+
puts ""
|
16
|
+
puts "Host tunnel is set up, client should run (this has been copied to your clipboard):"
|
17
|
+
puts "$ #{command}"
|
18
|
+
puts ""
|
19
|
+
puts "Once connected, they can use http://localhost:#{3000 + offset}/"
|
20
|
+
else
|
21
|
+
HostTunnel.tunnel_failure!
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def offset
|
28
|
+
@offset ||= 1 + rand(999)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Wemux
|
4
|
+
module Pair
|
5
|
+
class Configuration
|
6
|
+
PAIR_CONFIG = '.pair.yml'
|
7
|
+
|
8
|
+
def self.load
|
9
|
+
new(YAML.load_file(PAIR_CONFIG))
|
10
|
+
rescue Errno::ENOENT
|
11
|
+
raise "#{PAIR_CONFIG} configuration not found"
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader :ssh_host, :ssh_user, :pair_user, :pow_host
|
15
|
+
|
16
|
+
def initialize(config)
|
17
|
+
@ssh_host = config.fetch('ssh_host')
|
18
|
+
@ssh_user = config.fetch('ssh_user')
|
19
|
+
@pair_user = config.fetch('pair_user')
|
20
|
+
@pow_host = config.fetch('pow_host') { nil }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Wemux
|
2
|
+
module Pair
|
3
|
+
class PairConnection
|
4
|
+
attr_reader :tunnel
|
5
|
+
def initialize(tunnel)
|
6
|
+
@tunnel = tunnel
|
7
|
+
end
|
8
|
+
|
9
|
+
def port_offset
|
10
|
+
tunnel.port_offset
|
11
|
+
end
|
12
|
+
|
13
|
+
def client_port
|
14
|
+
tunnel.client_port
|
15
|
+
end
|
16
|
+
|
17
|
+
def rails_server_port
|
18
|
+
3000 + port_offset
|
19
|
+
end
|
20
|
+
|
21
|
+
def ssh_options
|
22
|
+
[
|
23
|
+
"StrictHostKeyChecking no",
|
24
|
+
"UserKnownHostsFile /dev/null",
|
25
|
+
].map { |o| "-o \"#{o}\""}.join(" ")
|
26
|
+
end
|
27
|
+
|
28
|
+
def connect
|
29
|
+
system "ssh #{ssh_options} -L #{rails_server_port}:localhost:3000 -p #{client_port} #{::Pair.config.pair_user}@localhost"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'highline/import'
|
2
|
+
|
3
|
+
require_relative 'commands/print_usage'
|
4
|
+
require_relative 'commands/stop_session'
|
5
|
+
require_relative 'commands/start_host_session'
|
6
|
+
require_relative 'commands/start_client_session'
|
7
|
+
require_relative 'commands/check_for_wemux'
|
8
|
+
require_relative 'commands/check_for_pair_user'
|
9
|
+
require_relative 'commands/create_sample_config'
|
10
|
+
require_relative 'commands/set_pow_host'
|
11
|
+
require_relative '../pair'
|
12
|
+
|
13
|
+
module Wemux
|
14
|
+
module Pair
|
15
|
+
class Runner
|
16
|
+
def self.run(params)
|
17
|
+
new(params).execute
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_reader :param
|
21
|
+
def initialize(param)
|
22
|
+
@param = param.to_s.strip
|
23
|
+
end
|
24
|
+
|
25
|
+
def execute
|
26
|
+
case param
|
27
|
+
when "host"
|
28
|
+
Commands::CheckForPairUser.run(pair_user: Wemux::Pair.config.pair_user)
|
29
|
+
Commands::CheckForWemux.run
|
30
|
+
Commands::StartHostSession.run
|
31
|
+
when "stop"
|
32
|
+
Commands::StopSession.run
|
33
|
+
when ->(param) { param.to_i > 0 }
|
34
|
+
port_offset = param.to_i
|
35
|
+
Commands::SetPowHost.run(
|
36
|
+
pow_host: Wemux::Pair.config.pow_host,
|
37
|
+
server_port: port_offset + 3000)
|
38
|
+
Commands::StartClientSession.run(port_offset: port_offset)
|
39
|
+
when "--init"
|
40
|
+
Commands::CreateSampleConfig.run
|
41
|
+
else
|
42
|
+
Commands::PrintUsage.run
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require_relative "../pair"
|
2
|
+
|
3
|
+
module Wemux
|
4
|
+
module Pair
|
5
|
+
class SshTunnel
|
6
|
+
attr_reader :port_offset
|
7
|
+
|
8
|
+
def initialize(port_offset)
|
9
|
+
@port_offset = port_offset
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.tunnel_failure!
|
13
|
+
puts "The tunnel failed to open, the port was probably in use, try again."
|
14
|
+
exit 1
|
15
|
+
end
|
16
|
+
|
17
|
+
def host_port
|
18
|
+
1230 + port_offset
|
19
|
+
end
|
20
|
+
|
21
|
+
def client_port
|
22
|
+
9990 + port_offset
|
23
|
+
end
|
24
|
+
|
25
|
+
def open
|
26
|
+
close_tunnels
|
27
|
+
puts "Opening tunnel..."
|
28
|
+
system "ssh #{ssh_options} -f -N #{ssh_forwards} #{ssh_user}@#{ssh_host}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def ssh_options
|
32
|
+
[
|
33
|
+
"ExitOnForwardFailure yes",
|
34
|
+
"ControlPersist yes",
|
35
|
+
"ControlPath #{control_path}",
|
36
|
+
"ControlMaster auto",
|
37
|
+
].map { |o| "-o \"#{o}\""}.join(" ")
|
38
|
+
end
|
39
|
+
|
40
|
+
def close_tunnels
|
41
|
+
puts "Closing existing tunnels..."
|
42
|
+
system "ssh #{ssh_options} -O exit #{ssh_user}@#{ssh_host}" until $? && !$?.success?
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def ssh_user
|
48
|
+
Wemux::Pair.config.ssh_user
|
49
|
+
end
|
50
|
+
|
51
|
+
def ssh_host
|
52
|
+
Wemux::Pair.config.ssh_host
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run :focus
|
11
|
+
|
12
|
+
# Run specs in random order to surface order dependencies. If you find an
|
13
|
+
# order dependency and want to debug it, you can fix the order by providing
|
14
|
+
# the seed, which is printed after each run.
|
15
|
+
# --seed 1234
|
16
|
+
config.order = 'random'
|
17
|
+
end
|
18
|
+
|
19
|
+
require 'pry'
|
20
|
+
Dir['./spec/support/**/*.rb'].map {|f| require f}
|
21
|
+
|
22
|
+
SPEC_ROOT = File.expand_path(File.dirname(__FILE__))
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'wemux/pair/commands/command'
|
4
|
+
|
5
|
+
module Wemux::Pair
|
6
|
+
describe Commands::Command do
|
7
|
+
it "should assigns key/values passed in as attributes" do
|
8
|
+
base = Commands::Command.new(foo: 'bar', baz: 'qux')
|
9
|
+
base.foo.should eq 'bar'
|
10
|
+
base.baz.should eq 'qux'
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#execute' do
|
14
|
+
subject { Commands::Command.new }
|
15
|
+
it 'should throws NotImplementedError' do
|
16
|
+
expect{ subject.execute }.to raise_error(NotImplementedError)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#run' do
|
21
|
+
subject { Commands::Command.run(foo: 'bar')}
|
22
|
+
|
23
|
+
it 'should assign attributes and call execute' do
|
24
|
+
base = double :base_command
|
25
|
+
Commands::Command.stub(:new).and_return(base)
|
26
|
+
|
27
|
+
Commands::Command.should_receive(:new).with(foo: 'bar')
|
28
|
+
base.should_receive(:execute)
|
29
|
+
|
30
|
+
subject
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'wemux/pair/configuration'
|
4
|
+
|
5
|
+
module Wemux::Pair
|
6
|
+
describe Configuration do
|
7
|
+
let(:config_options) do
|
8
|
+
{
|
9
|
+
'ssh_host' => 'test_ssh_host',
|
10
|
+
'ssh_user' => 'test_ssh_user',
|
11
|
+
'pair_user' => 'test_pairprogramming'
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '.load' do
|
16
|
+
it "raises error if .pair.yml isn't found" do
|
17
|
+
expect { Configuration.load }.to raise_error('.pair.yml configuration not found')
|
18
|
+
end
|
19
|
+
|
20
|
+
it "returns a configuration if .pair.yml exists" do
|
21
|
+
use_test_config
|
22
|
+
|
23
|
+
Configuration.load.should be_an_instance_of Configuration
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should set ssh configuration" do
|
27
|
+
use_test_config
|
28
|
+
|
29
|
+
config = Configuration.load
|
30
|
+
config.ssh_host.should eq 'test_ssh_host'
|
31
|
+
config.ssh_user.should eq 'test_ssh_user'
|
32
|
+
config.pair_user.should eq 'test_pairprogramming'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should throw an error if config is missing ssh property" do
|
37
|
+
expect { Configuration.new({}) }.to raise_error KeyError
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#pow_host' do
|
41
|
+
it "is set from config" do
|
42
|
+
Configuration.new(config_options.merge('pow_host' => 'foo')).pow_host.should eq 'foo'
|
43
|
+
end
|
44
|
+
|
45
|
+
it "is nil by default" do
|
46
|
+
Configuration.new(config_options).pow_host.should be_false
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def use_test_config
|
51
|
+
test_config_yaml = File.join(SPEC_ROOT, 'fixtures', 'test_config.yml')
|
52
|
+
stub_const('Wemux::Pair::Configuration::PAIR_CONFIG', test_config_yaml)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
data/wemux-pair.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'wemux/pair/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "wemux-pair"
|
8
|
+
spec.version = Wemux::Pair::VERSION
|
9
|
+
spec.authors = ["Aaron Jensen", "Beau Beveridge", "Shaun Dern"]
|
10
|
+
spec.email = ["tchdevs@substantial.com"]
|
11
|
+
spec.description = %q{Firewall punching remote pairing with wemux made easy}
|
12
|
+
spec.summary = spec.description
|
13
|
+
spec.homepage = "https://github.com/substantial/wemux-pair"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.1"
|
23
|
+
spec.add_development_dependency "pry", "~> 0.9"
|
24
|
+
spec.add_development_dependency "rspec", "~> 2.14"
|
25
|
+
|
26
|
+
spec.add_dependency "highline", "~> 1.6"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wemux-pair
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aaron Jensen
|
8
|
+
- Beau Beveridge
|
9
|
+
- Shaun Dern
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2014-03-10 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: bundler
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '1.3'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: rake
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '10.1'
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '10.1'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: pry
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0.9'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0.9'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: rspec
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - "~>"
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '2.14'
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - "~>"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '2.14'
|
71
|
+
- !ruby/object:Gem::Dependency
|
72
|
+
name: highline
|
73
|
+
requirement: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '1.6'
|
78
|
+
type: :runtime
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - "~>"
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '1.6'
|
85
|
+
description: Firewall punching remote pairing with wemux made easy
|
86
|
+
email:
|
87
|
+
- tchdevs@substantial.com
|
88
|
+
executables:
|
89
|
+
- pair
|
90
|
+
extensions: []
|
91
|
+
extra_rdoc_files: []
|
92
|
+
files:
|
93
|
+
- ".gitignore"
|
94
|
+
- ".ruby-gemset.template"
|
95
|
+
- ".ruby-version.template"
|
96
|
+
- ".travis.yml"
|
97
|
+
- Gemfile
|
98
|
+
- LICENSE.txt
|
99
|
+
- README.md
|
100
|
+
- Rakefile
|
101
|
+
- bin/pair
|
102
|
+
- etc/sample_config.yml
|
103
|
+
- lib/wemux-pair.rb
|
104
|
+
- lib/wemux/pair.rb
|
105
|
+
- lib/wemux/pair/client_tunnel.rb
|
106
|
+
- lib/wemux/pair/clipboard.rb
|
107
|
+
- lib/wemux/pair/commands/check_for_pair_user.rb
|
108
|
+
- lib/wemux/pair/commands/check_for_wemux.rb
|
109
|
+
- lib/wemux/pair/commands/command.rb
|
110
|
+
- lib/wemux/pair/commands/create_sample_config.rb
|
111
|
+
- lib/wemux/pair/commands/print_usage.rb
|
112
|
+
- lib/wemux/pair/commands/set_pow_host.rb
|
113
|
+
- lib/wemux/pair/commands/start_client_session.rb
|
114
|
+
- lib/wemux/pair/commands/start_host_session.rb
|
115
|
+
- lib/wemux/pair/commands/stop_session.rb
|
116
|
+
- lib/wemux/pair/configuration.rb
|
117
|
+
- lib/wemux/pair/host_tunnel.rb
|
118
|
+
- lib/wemux/pair/pair_connection.rb
|
119
|
+
- lib/wemux/pair/runner.rb
|
120
|
+
- lib/wemux/pair/ssh_tunnel.rb
|
121
|
+
- lib/wemux/pair/version.rb
|
122
|
+
- spec/fixtures/test_config.yml
|
123
|
+
- spec/spec_helper.rb
|
124
|
+
- spec/wemux/pair/commands/command_spec.rb
|
125
|
+
- spec/wemux/pair/configuration_spec.rb
|
126
|
+
- wemux-pair.gemspec
|
127
|
+
homepage: https://github.com/substantial/wemux-pair
|
128
|
+
licenses:
|
129
|
+
- MIT
|
130
|
+
metadata: {}
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options: []
|
133
|
+
require_paths:
|
134
|
+
- lib
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
requirements: []
|
146
|
+
rubyforge_project:
|
147
|
+
rubygems_version: 2.2.2
|
148
|
+
signing_key:
|
149
|
+
specification_version: 4
|
150
|
+
summary: Firewall punching remote pairing with wemux made easy
|
151
|
+
test_files:
|
152
|
+
- spec/fixtures/test_config.yml
|
153
|
+
- spec/spec_helper.rb
|
154
|
+
- spec/wemux/pair/commands/command_spec.rb
|
155
|
+
- spec/wemux/pair/configuration_spec.rb
|