tweemux 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -26,7 +26,10 @@ For starters:
26
26
 
27
27
  gem install tweemux
28
28
 
29
- Then, create the user on your machine (this varies. On decent Unices, it's `adduser` or `useradd`. On OS X you can either get an [adduser-like script](https://raw.github.com/sharpsaw/mac-dots/master/bin/adduser) or do it through the System Preferences GUI).
29
+ Then, create the user on your machine (this varies. On decent Unices, it's
30
+ `adduser` or `useradd`. On OS X you can either get an [adduser-like
31
+ script](https://raw.github.com/sharpsaw/mac-dots/master/bin/adduser) or do it
32
+ through the System Preferences GUI).
30
33
 
31
34
  Now, you can install the 'keyholes' for this user from Github. This means they
32
35
  will be able to get in without manually typing a password, just like when they
@@ -37,12 +40,8 @@ will be able to get in without manually typing a password, just like when they
37
40
  tweemux hubkey rking
38
41
 
39
42
  Now, they'll need a route to your sshd port. If you're on a machine behind a
40
- firewall, you have these options:
41
-
42
- * VPN. If you're on a business network with your pair, you probably can already `ping` each other's machines. Easy stuff, then.
43
- * Directly open a port, such as going to your router config (perhaps at http://10.0.0.1 ?) and setting it to pass the external IP (see `curl ifconfig.me` or http://whatismyip.com ) through to your local box. This is smpler once you get it set up, as long as your location is stable and you have control over the router.
44
- * Use a Virtual machine on the web, and you both ssh into that. Can work very well, and has other advantages (such as the ability to trash the machine all you want and just rebuild it later). The big downside is that you now have two lagged users rather than only one.
45
- * SSH port forward. This is my favorite, but the downside is that you have to have access to a shell account somewhere public. Tweemux provides a tool for this:
43
+ firewall, you have these options: Use a VPN, directly open a port, use a host
44
+ on the Internet, or SSH port forward. Tweemux provides a tool for this last one:
46
45
 
47
46
  In this example, sharpsaw.org is a machine that is not behind the firewall:
48
47
 
@@ -57,6 +56,14 @@ Then, after your pair can get to your SSHD socket, finally:
57
56
 
58
57
  It's also nice to share a windowing environment session as well. For example, the "Guest" can host a VNC that you, as the tweemux host, can then connect to. This allows you to "point" at things with the mouse, and to share web browsing, etc.
59
58
 
59
+ ## Details about "Route to your sshd port", above
60
+
61
+ Your options are:
62
+ * VPN. If you're on a business network with your pair, you probably can already `ping` each other's machines. Easy stuff, then.
63
+ * Directly open a port, such as going to your router config (perhaps at http://10.0.0.1 ?) and setting it to pass the external IP (see `curl ifconfig.me` or http://whatismyip.com ) through to your local box. This is smpler once you get it set up, as long as your location is stable and you have control over the router.
64
+ * Use a machine on the Internet, that you both ssh into that. Can work very well, but the big downside is that you now have two lagged users rather than only one.
65
+ * SSH port forward. This is my favorite, but the downside is that you have to have access to a shell account somewhere public.
66
+
60
67
  ## No Public Box?
61
68
 
62
69
  If you don't have a public SSH account (like the way I use sharpsaw.org, above), let me know ( i-am-stuck@sharpsaw.org ). We'll solve that.
data/lib/tweemux.rb CHANGED
@@ -9,11 +9,17 @@ class Tweemux
9
9
  action = understand args
10
10
  action.call
11
11
  rescue Tweemux::Action::NoRestartsException => e
12
- warn e.message.color :error
12
+ die e.message.color :error
13
+ end
14
+
15
+ def die msg
16
+ warn msg
13
17
  exit 1
14
18
  end
15
19
 
16
20
  def understand args
21
+ # dash args are out of fashion!
22
+ args = ['Help'] if args.empty? or args.first[/^-/]
17
23
  action = args.shift
18
24
  klass = Tweemux::Action.const_get action.capitalize
19
25
  klass.new args
@@ -0,0 +1,14 @@
1
+ class Tweemux::Action::Help < Tweemux::Action
2
+ def run _
3
+ five_dirs_up = (['..']*5).join '/'
4
+ readme_path =
5
+ File.expand_path 'lib/tweemux/action/help.rb'+five_dirs_up+'/README.md'
6
+ contents = File.read readme_path
7
+ contents.sub! /^.+(?=## Guest Usage)/m, ''
8
+ contents.sub! /## Going Further.*/m, ''
9
+ contents.sub! /For starters.+?gem install tweemux\n\n/mi, ''
10
+ contents.gsub! /^## (.+)/ do |m| m.color :heading end
11
+ contents.gsub! /^ .+/ do |m| m.color :command end
12
+ warn contents
13
+ end
14
+ end
@@ -2,8 +2,8 @@ class String
2
2
  # Pallete viewable from:
3
3
  # https://github.com/sharpsaw/tmux-dots/blob/master/bin/colortest
4
4
  COLORS = {
5
- :middle_blue => 69,
6
- :brighty_blue => 39,
5
+ :middle_blue => 69, :heading => 69,
6
+ :brighty_blue => 39, :command => 39,
7
7
  :gray245 => 245,
8
8
  :orange => 172,
9
9
  :pale_yellow => 180,
@@ -1,3 +1,3 @@
1
1
  class Tweemux
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -0,0 +1,33 @@
1
+ require_relative '../../action_test_helper'
2
+ class Tweemux::Action
3
+ class HelpTest < MiniTest::Unit::TestCase
4
+ include TweemuxActionHelper
5
+ def argv; %w'help' end
6
+ def expected_commands; [] end
7
+ def test_run
8
+ output = nil
9
+ out, err = capture_io do
10
+ assert_equal stubbed_run.to_yaml, expected_commands.to_yaml
11
+ end
12
+ assert_match /Guest Usage/i, err
13
+ assert_match /tweemux at/, err
14
+ assert_match /Host Usage/i, err
15
+ assert_match /tweemux host/, err
16
+ refute_match /Problem/i, err
17
+ refute_match /Going Further/i, err
18
+ refute_match /For starters.*gem install tweemux/m, err
19
+ end
20
+ end
21
+
22
+ class ImpliedHelp < HelpTest
23
+ def argv; [] end
24
+ end
25
+
26
+ class DashyHelp < HelpTest
27
+ def argv; ['--help'] end
28
+ end
29
+
30
+ class YouKnowWhatNoDashiesAtAll < HelpTest
31
+ def argv; ['--help'] end
32
+ end
33
+ end
@@ -3,7 +3,7 @@ require 'ostruct'
3
3
 
4
4
  class Tweemux::Action::HubkeyTest < MiniTest::Unit::TestCase
5
5
  include TweemuxActionHelper
6
- def argv; %w(bro hi HiOnGithub) end
6
+ def argv; %w(hubkey hi HiOnGithub) end
7
7
  def test_run
8
8
  commands_run = nil
9
9
  with_fake_expand_path expecting: '~hi', expanding_to: '/home/hi' do
@@ -20,17 +20,18 @@ class Tweemux::Action::HubkeyTest < MiniTest::Unit::TestCase
20
20
  end
21
21
 
22
22
  def test_run_will_not_clobber_auth_keys_file
23
+ warning = nil
23
24
  with_fake_expand_path expecting: '~hi', expanding_to: '/home/hi' do
24
25
  File.stub :exists?, -> path {
25
26
  assert_equal '/home/hi/.ssh/authorized_keys', path
26
27
  true
27
28
  } do
28
- stubbed_run
29
+ Tweemux.stub :die, -> msg { warning = msg } do
30
+ stubbed_run
31
+ end
29
32
  end
30
33
  end
31
- fail "Shouldn't get here"
32
- rescue Tweemux::Action::NoRestartsException => e
33
- assert_match /refusing to overwrite.*authorized_keys/i, e.message
34
+ assert_match /refusing to overwrite.*authorized_keys/i, warning
34
35
  end
35
36
 
36
37
  def with_fake_expand_path args
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tweemux
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -36,6 +36,7 @@ files:
36
36
  - lib/tweemux/action.rb
37
37
  - lib/tweemux/action/at.rb
38
38
  - lib/tweemux/action/forward.rb
39
+ - lib/tweemux/action/help.rb
39
40
  - lib/tweemux/action/host.rb
40
41
  - lib/tweemux/action/hubkey.rb
41
42
  - lib/tweemux/action/share.rb
@@ -46,6 +47,7 @@ files:
46
47
  - test/test_helper.rb
47
48
  - test/tweemux/action/at_test.rb
48
49
  - test/tweemux/action/forward_test.rb
50
+ - test/tweemux/action/help_test.rb
49
51
  - test/tweemux/action/host_test.rb
50
52
  - test/tweemux/action/hubkey_test.rb
51
53
  - test/tweemux/action/share_test.rb
@@ -82,6 +84,7 @@ test_files:
82
84
  - test/test_helper.rb
83
85
  - test/tweemux/action/at_test.rb
84
86
  - test/tweemux/action/forward_test.rb
87
+ - test/tweemux/action/help_test.rb
85
88
  - test/tweemux/action/host_test.rb
86
89
  - test/tweemux/action/hubkey_test.rb
87
90
  - test/tweemux/action/share_test.rb