rush3 3.0.0
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/Gemfile +15 -0
- data/Gemfile.lock +93 -0
- data/README.rdoc +124 -0
- data/Rakefile +58 -0
- data/VERSION +1 -0
- data/bin/rush +13 -0
- data/bin/rushd +7 -0
- data/lib/rush.rb +91 -0
- data/lib/rush/access.rb +121 -0
- data/lib/rush/array_ext.rb +16 -0
- data/lib/rush/box.rb +130 -0
- data/lib/rush/commands.rb +94 -0
- data/lib/rush/config.rb +147 -0
- data/lib/rush/dir.rb +159 -0
- data/lib/rush/embeddable_shell.rb +26 -0
- data/lib/rush/entry.rb +238 -0
- data/lib/rush/exceptions.rb +32 -0
- data/lib/rush/file.rb +100 -0
- data/lib/rush/find_by.rb +39 -0
- data/lib/rush/head_tail.rb +11 -0
- data/lib/rush/integer_ext.rb +18 -0
- data/lib/rush/local.rb +404 -0
- data/lib/rush/path.rb +9 -0
- data/lib/rush/process.rb +59 -0
- data/lib/rush/process_set.rb +62 -0
- data/lib/rush/search_results.rb +71 -0
- data/lib/rush/shell.rb +118 -0
- data/lib/rush/shell/completion.rb +108 -0
- data/lib/rush/string_ext.rb +33 -0
- data/spec/access_spec.rb +134 -0
- data/spec/array_ext_spec.rb +15 -0
- data/spec/base.rb +22 -0
- data/spec/box_spec.rb +76 -0
- data/spec/commands_spec.rb +47 -0
- data/spec/config_spec.rb +108 -0
- data/spec/dir_spec.rb +163 -0
- data/spec/embeddable_shell_spec.rb +17 -0
- data/spec/entry_spec.rb +162 -0
- data/spec/file_spec.rb +95 -0
- data/spec/find_by_spec.rb +58 -0
- data/spec/integer_ext_spec.rb +19 -0
- data/spec/local_spec.rb +363 -0
- data/spec/path_spec.rb +13 -0
- data/spec/process_set_spec.rb +50 -0
- data/spec/process_spec.rb +89 -0
- data/spec/rush_spec.rb +28 -0
- data/spec/search_results_spec.rb +44 -0
- data/spec/shell_spec.rb +39 -0
- data/spec/ssh_tunnel_spec.rb +122 -0
- data/spec/string_ext_spec.rb +23 -0
- metadata +228 -0
    
        data/spec/path_spec.rb
    ADDED
    
    | @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            require_relative 'base'
         | 
| 2 | 
            +
            require_relative '../lib/rush/path'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            describe Rush::Path do
         | 
| 5 | 
            +
              it 'works' do
         | 
| 6 | 
            +
                expect(Rush::Path.executables).to be_kind_of Array
         | 
| 7 | 
            +
              end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              it "doesn't fail with non-existent directories in PATH" do
         | 
| 10 | 
            +
                expect(ENV).to receive(:[]).with("PATH").and_return("/foobar")
         | 
| 11 | 
            +
                expect(Rush::Path.executables).to eq []
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
            end
         | 
| @@ -0,0 +1,50 @@ | |
| 1 | 
            +
            require_relative 'base'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Rush::ProcessSet do
         | 
| 4 | 
            +
              before do
         | 
| 5 | 
            +
                @process = double('process')
         | 
| 6 | 
            +
                @set = Rush::ProcessSet.new([ @process ])
         | 
| 7 | 
            +
              end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              it "is Enumerable" do
         | 
| 10 | 
            +
                expect(@set.select { |s| s == @process }).to eq [ @process ]
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              it "defines size" do
         | 
| 14 | 
            +
                expect(@set.size).to eq 1
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              it "defines first" do
         | 
| 18 | 
            +
                expect(@set.first).to eq @process
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              it "is equal to sets with the same contents" do
         | 
| 22 | 
            +
                expect(@set).to eq Rush::ProcessSet.new([ @process ])
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              it "is equal to arrays with the same contents" do
         | 
| 26 | 
            +
                expect(@set).to eq [ @process ]
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              it "kills all processes in the set" do
         | 
| 30 | 
            +
                expect(@process).to receive(:kill)
         | 
| 31 | 
            +
                @set.kill
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              it "checks the alive? state of all processes in the set" do
         | 
| 35 | 
            +
                expect(@process).to receive(:alive?).and_return(true)
         | 
| 36 | 
            +
                expect(@set.alive?).to eq [ true ]
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              it "filters the set from a conditions hash and returns the filtered set" do
         | 
| 40 | 
            +
                allow(@process).to receive(:pid).and_return(123)
         | 
| 41 | 
            +
                expect(@set.filter(:pid => 123).first).to eq @process
         | 
| 42 | 
            +
                expect(@set.filter(:pid => 456).size).to eq 0
         | 
| 43 | 
            +
              end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
              it "filters with regexps if provided in the conditions" do
         | 
| 46 | 
            +
                allow(@process).to receive(:command).and_return('foobaz')
         | 
| 47 | 
            +
                expect(@set.filter(:command => /baz/).first).to eq @process
         | 
| 48 | 
            +
                expect(@set.filter(:command => /blerg/).size).to eq 0
         | 
| 49 | 
            +
              end
         | 
| 50 | 
            +
            end
         | 
| @@ -0,0 +1,89 @@ | |
| 1 | 
            +
            require_relative 'base'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Rush::Process do
         | 
| 4 | 
            +
              let!(:pid_file) { "/tmp/rush_rspec_#{Process.pid}" }
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              before do
         | 
| 7 | 
            +
                @parent_pid = fork do
         | 
| 8 | 
            +
                  # OSX includes checking `ps` process into current Process#children
         | 
| 9 | 
            +
                  # as such isolate parent from the main thread
         | 
| 10 | 
            +
                  # but the instance_valriabes are unavailable since #fork - use fs
         | 
| 11 | 
            +
                  @pid = fork do
         | 
| 12 | 
            +
                    sleep 999
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
                  ::File.write(pid_file, @pid)
         | 
| 15 | 
            +
                  sleep 999
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                # wait parent to tell child's pid
         | 
| 19 | 
            +
                sleep 0.3
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                @pid = ::File.read(pid_file).to_i
         | 
| 22 | 
            +
                @process = Rush::Process.all.detect { |p| p.pid == @pid }
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              after do
         | 
| 26 | 
            +
                ::File.unlink(pid_file) if ::File.exists?(pid_file)
         | 
| 27 | 
            +
                system "kill -9 #{@pid}"
         | 
| 28 | 
            +
                system "kill -9 #{@parent_pid}"
         | 
| 29 | 
            +
              end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
              it 'knows all its child processes' do
         | 
| 32 | 
            +
                parent = Rush::Process.all.detect { |p| p.pid == @parent_pid }
         | 
| 33 | 
            +
                expect(parent.children).to eq [@process]
         | 
| 34 | 
            +
              end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
              it 'gets the list of all processes' do
         | 
| 37 | 
            +
                list = Rush::Process.all
         | 
| 38 | 
            +
                expect(list.size).to be > 5
         | 
| 39 | 
            +
                expect(list.first).to be_kind_of Rush::Process
         | 
| 40 | 
            +
              end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
              it 'knows the pid' do
         | 
| 43 | 
            +
                expect(@process.pid).to eq @pid
         | 
| 44 | 
            +
              end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
              it 'knows the uid' do
         | 
| 47 | 
            +
                expect(@process.uid).to eq ::Process.uid
         | 
| 48 | 
            +
              end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
              it 'knows the executed binary' do
         | 
| 51 | 
            +
                expect(@process.command).to match(/(ruby|rbx)/)
         | 
| 52 | 
            +
              end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
              it 'knows the command line' do
         | 
| 55 | 
            +
                expect(@process.cmdline).to match(/rspec/)
         | 
| 56 | 
            +
              end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
              it 'knows the memory used' do
         | 
| 59 | 
            +
                expect(@process.mem).to be > 0
         | 
| 60 | 
            +
              end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
              it 'knows the cpu used' do
         | 
| 63 | 
            +
                expect(@process.cpu).to be >= 0
         | 
| 64 | 
            +
              end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
              it 'knows the parent process pid' do
         | 
| 67 | 
            +
                expect(@process.parent_pid).to eq @parent_pid
         | 
| 68 | 
            +
              end
         | 
| 69 | 
            +
             | 
| 70 | 
            +
              it 'knows the parent process' do
         | 
| 71 | 
            +
                this = Rush::Box.new.processes
         | 
| 72 | 
            +
                  .select { |p| p.pid == @parent_pid }
         | 
| 73 | 
            +
                  .first
         | 
| 74 | 
            +
                expect(@process.parent).to eq this
         | 
| 75 | 
            +
              end
         | 
| 76 | 
            +
             | 
| 77 | 
            +
              it 'can kill itself' do
         | 
| 78 | 
            +
                process = Rush.bash('sleep 30', background: true)
         | 
| 79 | 
            +
                expect(process.alive?).to eq true
         | 
| 80 | 
            +
                process.kill
         | 
| 81 | 
            +
                sleep 0.1
         | 
| 82 | 
            +
                expect(process.alive?).to eq false
         | 
| 83 | 
            +
              end
         | 
| 84 | 
            +
             | 
| 85 | 
            +
              it 'if box and pid are the same, process is equal' do
         | 
| 86 | 
            +
                other = Rush::Process.new({ pid: @process.pid }, @process.box)
         | 
| 87 | 
            +
                expect(@process).to eq other
         | 
| 88 | 
            +
              end
         | 
| 89 | 
            +
            end
         | 
    
        data/spec/rush_spec.rb
    ADDED
    
    | @@ -0,0 +1,28 @@ | |
| 1 | 
            +
            require_relative 'base'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Rush do
         | 
| 4 | 
            +
              it 'fetches a local file path' do
         | 
| 5 | 
            +
                expect(Rush['/etc/hosts'].full_path).to eq('/etc/hosts')
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              it 'fetches the dir of __FILE__' do
         | 
| 9 | 
            +
                expect(Rush.dir(__FILE__).name).to eq('spec')
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              it 'fetches the launch dir (aka current working directory or pwd)' do
         | 
| 13 | 
            +
                allow(Dir).to receive(:pwd).and_return('/tmp')
         | 
| 14 | 
            +
                expect(Rush.launch_dir).to eq(Rush::Box.new['/tmp/'])
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              it 'runs a bash command' do
         | 
| 18 | 
            +
                expect(Rush.bash('echo hi')).to eq("hi\n")
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              it 'gets the list of local processes' do
         | 
| 22 | 
            +
                expect(Rush.processes).to be_kind_of(Rush::ProcessSet)
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              it 'gets my process' do
         | 
| 26 | 
            +
                expect(Rush.my_process.pid).to eq(Process.pid)
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
            end
         | 
| @@ -0,0 +1,44 @@ | |
| 1 | 
            +
            require_relative 'base'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Rush::SearchResults do
         | 
| 4 | 
            +
            	before do
         | 
| 5 | 
            +
            		@results = Rush::SearchResults.new(/pat/)
         | 
| 6 | 
            +
            		@file = Rush::File.new("file")
         | 
| 7 | 
            +
            	end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            	it "returns its list of entries" do
         | 
| 10 | 
            +
            		@results.add(@file, %w(a))
         | 
| 11 | 
            +
            		expect(@results.entries).to eq [ @file ]
         | 
| 12 | 
            +
            	end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            	it "only returns each entry once no matter how many line matches it has" do
         | 
| 15 | 
            +
            		@results.add(@file, %w(a b))
         | 
| 16 | 
            +
            		expect(@results.entries).to eq [ @file ]
         | 
| 17 | 
            +
            	end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            	it "returns its list of matched lines" do
         | 
| 20 | 
            +
            		@results.add(@file, %w(a b))
         | 
| 21 | 
            +
            		expect(@results.lines).to eq %w(a b)
         | 
| 22 | 
            +
            	end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            	it "returns all lines for each entry in a flattened form" do
         | 
| 25 | 
            +
            		file2 = Rush::File.new("another file")
         | 
| 26 | 
            +
            		@results.add(@file, %w(a b))
         | 
| 27 | 
            +
            		@results.add(file2, %w(c d))
         | 
| 28 | 
            +
            		expect(@results.lines).to eq %w(a b c d)
         | 
| 29 | 
            +
            	end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            	it "returns a hash of entries_with_lines" do
         | 
| 32 | 
            +
            		@results.add(@file, %w(a))
         | 
| 33 | 
            +
            		expect(@results.entries_with_lines).to eq({ @file => %w(a) })
         | 
| 34 | 
            +
            	end
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            	it "mixes in Commands to operate like a dir or entry array" do
         | 
| 37 | 
            +
            		expect(@results.methods.include?(:search)).to eq(true)
         | 
| 38 | 
            +
            	end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            	it "mixes in Enumerable to behave like an array" do
         | 
| 41 | 
            +
            		@results.add(@file, %w(a))
         | 
| 42 | 
            +
            		expect(@results.map { |e| e }).to eq [ @file ]
         | 
| 43 | 
            +
            	end
         | 
| 44 | 
            +
            end
         | 
    
        data/spec/shell_spec.rb
    ADDED
    
    | @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            require_relative 'base'
         | 
| 2 | 
            +
            require_relative '../lib/rush/shell'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            describe Rush::Shell do
         | 
| 5 | 
            +
            	before do
         | 
| 6 | 
            +
            		@shell = Rush::Shell.new
         | 
| 7 | 
            +
            	end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
             it 'Complete constants' do
         | 
| 10 | 
            +
               expect(@shell.complete('Obj')).to eq(["Object", "ObjectSpace"])
         | 
| 11 | 
            +
               expect(@shell.complete('Rush::Sh')).to eq(["Rush::Shell"])
         | 
| 12 | 
            +
             end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
             it 'Complete executables' do
         | 
| 15 | 
            +
               expect(@shell.complete('rub')).to include 'ruby'
         | 
| 16 | 
            +
             end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
             it 'Complete global method names' do
         | 
| 19 | 
            +
               eval('def wakawaka; p "hi"; end', @shell.pure_binding)
         | 
| 20 | 
            +
               expect(@shell.complete('waka')).to eq ["wakawaka"]
         | 
| 21 | 
            +
             end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
             it 'Complete method names' do
         | 
| 24 | 
            +
               # rbx has additional Rush.method_table, Rush.method_table=
         | 
| 25 | 
            +
               expect(@shell.complete('Rush.meth')).
         | 
| 26 | 
            +
                 to include("Rush.method_part", "Rush.method_defined?", "Rush.methods", "Rush.method")
         | 
| 27 | 
            +
               expect(@shell.complete('Rush.methods.inc')).to include "Rush.methods.include?"
         | 
| 28 | 
            +
             end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
             it 'Complete paths' do
         | 
| 31 | 
            +
            	 # Updated: 9/11/2019 by @protolif
         | 
| 32 | 
            +
            	 # Details: Changed eq to include
         | 
| 33 | 
            +
            	 # Reason: 'bin/ba' matches more than 'bin/bash' on many systems
         | 
| 34 | 
            +
               expect(@shell.complete('root["bin/ba')).to  include "root[\"bin/bash"
         | 
| 35 | 
            +
               expect(@shell.complete('root[\'bin/ba')).to include "root['bin/bash"
         | 
| 36 | 
            +
               expect(@shell.complete('root/"bin/ba')).to  include "root/\"bin/bash"
         | 
| 37 | 
            +
               expect(@shell.complete('root/\'bin/ba')).to include "root/'bin/bash"
         | 
| 38 | 
            +
             end
         | 
| 39 | 
            +
            end
         | 
| @@ -0,0 +1,122 @@ | |
| 1 | 
            +
            # require_relative 'base'
         | 
| 2 | 
            +
            #
         | 
| 3 | 
            +
            # describe Rush::SshTunnel do
         | 
| 4 | 
            +
            # 	before do
         | 
| 5 | 
            +
            # 		@tunnel = Rush::SshTunnel.new('spec.example.com')
         | 
| 6 | 
            +
            # 		@tunnel.stub(:config).and_return(mock_config_start)
         | 
| 7 | 
            +
            # 		@tunnel.stub(:display)
         | 
| 8 | 
            +
            # 	end
         | 
| 9 | 
            +
            #
         | 
| 10 | 
            +
            # 	after do
         | 
| 11 | 
            +
            # 		mock_config_cleanup
         | 
| 12 | 
            +
            # 	end
         | 
| 13 | 
            +
            #
         | 
| 14 | 
            +
            # 	it "ensure_tunnel sets everything up for the tunnel when one does not already exist" do
         | 
| 15 | 
            +
            # 		@tunnel.should_receive(:push_credentials)
         | 
| 16 | 
            +
            # 		@tunnel.should_receive(:launch_rushd)
         | 
| 17 | 
            +
            # 		@tunnel.should_receive(:establish_tunnel)
         | 
| 18 | 
            +
            # 		@tunnel.ensure_tunnel
         | 
| 19 | 
            +
            # 	end
         | 
| 20 | 
            +
            #
         | 
| 21 | 
            +
            # 	it "ensure_tunnel uses the existing port as long as the tunnel is still alive" do
         | 
| 22 | 
            +
            # 		@tunnel.should_receive(:tunnel_alive?).and_return(true)
         | 
| 23 | 
            +
            # 		@tunnel.instance_eval("@port = 2345")
         | 
| 24 | 
            +
            # 		@tunnel.ensure_tunnel
         | 
| 25 | 
            +
            # 		@tunnel.port.should == 2345
         | 
| 26 | 
            +
            # 	end
         | 
| 27 | 
            +
            #
         | 
| 28 | 
            +
            # 	it "existing tunnel is used when it is specified in the tunnels file" do
         | 
| 29 | 
            +
            # 		@tunnel.config.tunnels_file.write "spec.example.com:4567\n"
         | 
| 30 | 
            +
            # 		@tunnel.should_receive(:tunnel_alive?).and_return(true)
         | 
| 31 | 
            +
            # 		@tunnel.should_not_receive(:setup_everything)
         | 
| 32 | 
            +
            # 		@tunnel.ensure_tunnel
         | 
| 33 | 
            +
            # 		@tunnel.port.should == 4567
         | 
| 34 | 
            +
            # 	end
         | 
| 35 | 
            +
            #
         | 
| 36 | 
            +
            # 	it "tunnel host is always local" do
         | 
| 37 | 
            +
            # 		@tunnel.host.should == 'localhost'
         | 
| 38 | 
            +
            # 	end
         | 
| 39 | 
            +
            #
         | 
| 40 | 
            +
            # 	it "picks the first port number when there are no tunnels yet" do
         | 
| 41 | 
            +
            # 		@tunnel.next_available_port.should == 7771
         | 
| 42 | 
            +
            # 	end
         | 
| 43 | 
            +
            #
         | 
| 44 | 
            +
            # 	it "picks the next port number when there is already a tunnel" do
         | 
| 45 | 
            +
            # 		@tunnel.config.tunnels_file.write("#{@tunnel.host}:7771")
         | 
| 46 | 
            +
            # 		@tunnel.next_available_port.should == 7772
         | 
| 47 | 
            +
            # 	end
         | 
| 48 | 
            +
            #
         | 
| 49 | 
            +
            # 	it "establishes a tunnel and saves it to ~/.rush/tunnels" do
         | 
| 50 | 
            +
            # 		@tunnel.should_receive(:make_ssh_tunnel)
         | 
| 51 | 
            +
            # 		@tunnel.should_receive(:port).exactly(0).times
         | 
| 52 | 
            +
            # 		@tunnel.establish_tunnel
         | 
| 53 | 
            +
            # 		@tunnel.config.tunnels_file.contents.should == "spec.example.com:7771\n"
         | 
| 54 | 
            +
            # 	end
         | 
| 55 | 
            +
            #
         | 
| 56 | 
            +
            # 	it "converts instance vars to options hash for ssh_tunnel_command" do
         | 
| 57 | 
            +
            # 		@tunnel.instance_eval("@port = 1234")
         | 
| 58 | 
            +
            # 		@tunnel.tunnel_options.should == {
         | 
| 59 | 
            +
            # 			:local_port => 1234,
         | 
| 60 | 
            +
            # 			:remote_port => 7770,
         | 
| 61 | 
            +
            # 			:ssh_host => 'spec.example.com'
         | 
| 62 | 
            +
            # 		}
         | 
| 63 | 
            +
            # 	end
         | 
| 64 | 
            +
            #
         | 
| 65 | 
            +
            # 	it "ssh_stall_command uses an infinite loop for :timeout => :infinite" do
         | 
| 66 | 
            +
            # 		@tunnel.ssh_stall_command(:timeout => :infinite).should match(/while .* sleep .* done/)
         | 
| 67 | 
            +
            # 	end
         | 
| 68 | 
            +
            #
         | 
| 69 | 
            +
            # 	it "ssh_stall_command sleeps for the number of seconds given as the :timeout option" do
         | 
| 70 | 
            +
            # 		@tunnel.ssh_stall_command(:timeout => 123).should == "sleep 123"
         | 
| 71 | 
            +
            # 	end
         | 
| 72 | 
            +
            #
         | 
| 73 | 
            +
            # 	it "ssh_stall_command uses the default timeout when no options are given" do
         | 
| 74 | 
            +
            # 		@tunnel.ssh_stall_command.should == "sleep 9000"
         | 
| 75 | 
            +
            # 	end
         | 
| 76 | 
            +
            #
         | 
| 77 | 
            +
            # 	it "constructs the ssh tunnel command (everything but stall) from the options hash" do
         | 
| 78 | 
            +
            # 		@tunnel.should_receive(:tunnel_options).at_least(:once).and_return(
         | 
| 79 | 
            +
            # 			:local_port => 123,
         | 
| 80 | 
            +
            # 			:remote_port => 456,
         | 
| 81 | 
            +
            # 			:ssh_host => 'example.com'
         | 
| 82 | 
            +
            # 		)
         | 
| 83 | 
            +
            # 		@tunnel.ssh_tunnel_command_without_stall.should == "ssh -f -L 123:127.0.0.1:456 example.com"
         | 
| 84 | 
            +
            # 	end
         | 
| 85 | 
            +
            #
         | 
| 86 | 
            +
            # 	it "combines the tunnel command without stall and the stall command into the final command" do
         | 
| 87 | 
            +
            # 		@tunnel.should_receive(:ssh_tunnel_command_without_stall).and_return('ssh command')
         | 
| 88 | 
            +
            # 		@tunnel.should_receive(:ssh_stall_command).and_return('sleep 123')
         | 
| 89 | 
            +
            # 		@tunnel.ssh_tunnel_command.should == 'ssh command "sleep 123"'
         | 
| 90 | 
            +
            # 	end
         | 
| 91 | 
            +
            #
         | 
| 92 | 
            +
            # 	it "ssh_tunnel_command request that the port be set" do
         | 
| 93 | 
            +
            # 		@tunnel.should_receive(:tunnel_options).at_least(:once).and_return(:local_port => nil)
         | 
| 94 | 
            +
            # 		lambda { @tunnel.ssh_tunnel_command }.should raise_error(Rush::SshTunnel::NoPortSelectedYet)
         | 
| 95 | 
            +
            # 	end
         | 
| 96 | 
            +
            #
         | 
| 97 | 
            +
            #
         | 
| 98 | 
            +
            # 	it "push_credentials uses ssh to append to remote host's passwords file" do
         | 
| 99 | 
            +
            # 		@tunnel.should_receive(:ssh_append_to_credentials).and_return(true)
         | 
| 100 | 
            +
            # 		@tunnel.push_credentials
         | 
| 101 | 
            +
            # 	end
         | 
| 102 | 
            +
            #
         | 
| 103 | 
            +
            # 	it "launches rushd on the remote host via ssh" do
         | 
| 104 | 
            +
            # 		@tunnel.should_receive(:ssh) do |cmd|
         | 
| 105 | 
            +
            # 			cmd.should match(/rushd/)
         | 
| 106 | 
            +
            # 		end
         | 
| 107 | 
            +
            # 		@tunnel.launch_rushd
         | 
| 108 | 
            +
            # 	end
         | 
| 109 | 
            +
            #
         | 
| 110 | 
            +
            # 	it "tunnel_alive? checks whether a tunnel is still up" do
         | 
| 111 | 
            +
            # 		@tunnel.should_receive(:tunnel_count_command).and_return("echo 1")
         | 
| 112 | 
            +
            # 		@tunnel.tunnel_alive?.should be_true
         | 
| 113 | 
            +
            # 	end
         | 
| 114 | 
            +
            #
         | 
| 115 | 
            +
            # 	it "tunnel_count_command greps ps to find the ssh tunnel" do
         | 
| 116 | 
            +
            # 		@tunnel.should_receive(:ssh_tunnel_command_without_stall).and_return('ssh command')
         | 
| 117 | 
            +
            # 		command = @tunnel.tunnel_count_command
         | 
| 118 | 
            +
            # 		command.should match(/ps/)
         | 
| 119 | 
            +
            # 		command.should match(/grep/)
         | 
| 120 | 
            +
            # 		command.should match(/ssh command/)
         | 
| 121 | 
            +
            # 	end
         | 
| 122 | 
            +
            # end
         | 
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            require_relative 'base'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe String do
         | 
| 4 | 
            +
            	before do
         | 
| 5 | 
            +
            		@string = "abc"
         | 
| 6 | 
            +
            	end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            	it "heads from the front of the string" do
         | 
| 9 | 
            +
            		expect(@string.head(1)).to eq 'a'
         | 
| 10 | 
            +
            	end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            	it "tails from the back of the string" do
         | 
| 13 | 
            +
            		expect(@string.tail(1)).to eq 'c'
         | 
| 14 | 
            +
            	end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            	it "gives the whole string when head exceeds length" do
         | 
| 17 | 
            +
            		expect(@string.head(999)).to eq @string
         | 
| 18 | 
            +
            	end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            	it "gives the whole string when tail exceeds length" do
         | 
| 21 | 
            +
            		expect(@string.tail(999)).to eq @string
         | 
| 22 | 
            +
            	end
         | 
| 23 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,228 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: rush3
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 3.0.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Adam Wiggins
         | 
| 8 | 
            +
            - Sergei Smagin
         | 
| 9 | 
            +
            - James Dunn
         | 
| 10 | 
            +
            autorequire: 
         | 
| 11 | 
            +
            bindir: bin
         | 
| 12 | 
            +
            cert_chain: []
         | 
| 13 | 
            +
            date: 2019-09-11 00:00:00.000000000 Z
         | 
| 14 | 
            +
            dependencies:
         | 
| 15 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 16 | 
            +
              name: session
         | 
| 17 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 18 | 
            +
                requirements:
         | 
| 19 | 
            +
                - - "~>"
         | 
| 20 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 21 | 
            +
                    version: '3.2'
         | 
| 22 | 
            +
              type: :runtime
         | 
| 23 | 
            +
              prerelease: false
         | 
| 24 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 25 | 
            +
                requirements:
         | 
| 26 | 
            +
                - - "~>"
         | 
| 27 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 28 | 
            +
                    version: '3.2'
         | 
| 29 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 30 | 
            +
              name: coolline
         | 
| 31 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 32 | 
            +
                requirements:
         | 
| 33 | 
            +
                - - "~>"
         | 
| 34 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 35 | 
            +
                    version: 0.5.0
         | 
| 36 | 
            +
              type: :runtime
         | 
| 37 | 
            +
              prerelease: false
         | 
| 38 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 39 | 
            +
                requirements:
         | 
| 40 | 
            +
                - - "~>"
         | 
| 41 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 42 | 
            +
                    version: 0.5.0
         | 
| 43 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 44 | 
            +
              name: coderay
         | 
| 45 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 46 | 
            +
                requirements:
         | 
| 47 | 
            +
                - - "~>"
         | 
| 48 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 49 | 
            +
                    version: '1.1'
         | 
| 50 | 
            +
                - - ">="
         | 
| 51 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 52 | 
            +
                    version: 1.1.2
         | 
| 53 | 
            +
              type: :runtime
         | 
| 54 | 
            +
              prerelease: false
         | 
| 55 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 56 | 
            +
                requirements:
         | 
| 57 | 
            +
                - - "~>"
         | 
| 58 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 59 | 
            +
                    version: '1.1'
         | 
| 60 | 
            +
                - - ">="
         | 
| 61 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 62 | 
            +
                    version: 1.1.2
         | 
| 63 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 64 | 
            +
              name: net-ssh
         | 
| 65 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 66 | 
            +
                requirements:
         | 
| 67 | 
            +
                - - "~>"
         | 
| 68 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 69 | 
            +
                    version: '5.2'
         | 
| 70 | 
            +
              type: :runtime
         | 
| 71 | 
            +
              prerelease: false
         | 
| 72 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 73 | 
            +
                requirements:
         | 
| 74 | 
            +
                - - "~>"
         | 
| 75 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 76 | 
            +
                    version: '5.2'
         | 
| 77 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 78 | 
            +
              name: pry
         | 
| 79 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 80 | 
            +
                requirements:
         | 
| 81 | 
            +
                - - "~>"
         | 
| 82 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 83 | 
            +
                    version: 0.12.2
         | 
| 84 | 
            +
              type: :development
         | 
| 85 | 
            +
              prerelease: false
         | 
| 86 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 87 | 
            +
                requirements:
         | 
| 88 | 
            +
                - - "~>"
         | 
| 89 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 90 | 
            +
                    version: 0.12.2
         | 
| 91 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 92 | 
            +
              name: rake
         | 
| 93 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 94 | 
            +
                requirements:
         | 
| 95 | 
            +
                - - "~>"
         | 
| 96 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 97 | 
            +
                    version: '12.3'
         | 
| 98 | 
            +
                - - ">="
         | 
| 99 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 100 | 
            +
                    version: 12.3.3
         | 
| 101 | 
            +
              type: :development
         | 
| 102 | 
            +
              prerelease: false
         | 
| 103 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 104 | 
            +
                requirements:
         | 
| 105 | 
            +
                - - "~>"
         | 
| 106 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 107 | 
            +
                    version: '12.3'
         | 
| 108 | 
            +
                - - ">="
         | 
| 109 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 110 | 
            +
                    version: 12.3.3
         | 
| 111 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 112 | 
            +
              name: jeweler
         | 
| 113 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 114 | 
            +
                requirements:
         | 
| 115 | 
            +
                - - "~>"
         | 
| 116 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 117 | 
            +
                    version: '2.3'
         | 
| 118 | 
            +
                - - ">="
         | 
| 119 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 120 | 
            +
                    version: 2.3.9
         | 
| 121 | 
            +
              type: :development
         | 
| 122 | 
            +
              prerelease: false
         | 
| 123 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 124 | 
            +
                requirements:
         | 
| 125 | 
            +
                - - "~>"
         | 
| 126 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 127 | 
            +
                    version: '2.3'
         | 
| 128 | 
            +
                - - ">="
         | 
| 129 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 130 | 
            +
                    version: 2.3.9
         | 
| 131 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 132 | 
            +
              name: rspec
         | 
| 133 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 134 | 
            +
                requirements:
         | 
| 135 | 
            +
                - - "~>"
         | 
| 136 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 137 | 
            +
                    version: '3.8'
         | 
| 138 | 
            +
              type: :development
         | 
| 139 | 
            +
              prerelease: false
         | 
| 140 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 141 | 
            +
                requirements:
         | 
| 142 | 
            +
                - - "~>"
         | 
| 143 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 144 | 
            +
                    version: '3.8'
         | 
| 145 | 
            +
            description: A Ruby replacement for bash+ssh, providing both an interactive shell
         | 
| 146 | 
            +
              and a library.  Manage both local and remote unix systems from a single client.
         | 
| 147 | 
            +
            email: jamesldunnjr@gmail.com
         | 
| 148 | 
            +
            executables:
         | 
| 149 | 
            +
            - rush
         | 
| 150 | 
            +
            - rushd
         | 
| 151 | 
            +
            extensions: []
         | 
| 152 | 
            +
            extra_rdoc_files:
         | 
| 153 | 
            +
            - README.rdoc
         | 
| 154 | 
            +
            files:
         | 
| 155 | 
            +
            - Gemfile
         | 
| 156 | 
            +
            - Gemfile.lock
         | 
| 157 | 
            +
            - README.rdoc
         | 
| 158 | 
            +
            - Rakefile
         | 
| 159 | 
            +
            - VERSION
         | 
| 160 | 
            +
            - bin/rush
         | 
| 161 | 
            +
            - bin/rushd
         | 
| 162 | 
            +
            - lib/rush.rb
         | 
| 163 | 
            +
            - lib/rush/access.rb
         | 
| 164 | 
            +
            - lib/rush/array_ext.rb
         | 
| 165 | 
            +
            - lib/rush/box.rb
         | 
| 166 | 
            +
            - lib/rush/commands.rb
         | 
| 167 | 
            +
            - lib/rush/config.rb
         | 
| 168 | 
            +
            - lib/rush/dir.rb
         | 
| 169 | 
            +
            - lib/rush/embeddable_shell.rb
         | 
| 170 | 
            +
            - lib/rush/entry.rb
         | 
| 171 | 
            +
            - lib/rush/exceptions.rb
         | 
| 172 | 
            +
            - lib/rush/file.rb
         | 
| 173 | 
            +
            - lib/rush/find_by.rb
         | 
| 174 | 
            +
            - lib/rush/head_tail.rb
         | 
| 175 | 
            +
            - lib/rush/integer_ext.rb
         | 
| 176 | 
            +
            - lib/rush/local.rb
         | 
| 177 | 
            +
            - lib/rush/path.rb
         | 
| 178 | 
            +
            - lib/rush/process.rb
         | 
| 179 | 
            +
            - lib/rush/process_set.rb
         | 
| 180 | 
            +
            - lib/rush/search_results.rb
         | 
| 181 | 
            +
            - lib/rush/shell.rb
         | 
| 182 | 
            +
            - lib/rush/shell/completion.rb
         | 
| 183 | 
            +
            - lib/rush/string_ext.rb
         | 
| 184 | 
            +
            - spec/access_spec.rb
         | 
| 185 | 
            +
            - spec/array_ext_spec.rb
         | 
| 186 | 
            +
            - spec/base.rb
         | 
| 187 | 
            +
            - spec/box_spec.rb
         | 
| 188 | 
            +
            - spec/commands_spec.rb
         | 
| 189 | 
            +
            - spec/config_spec.rb
         | 
| 190 | 
            +
            - spec/dir_spec.rb
         | 
| 191 | 
            +
            - spec/embeddable_shell_spec.rb
         | 
| 192 | 
            +
            - spec/entry_spec.rb
         | 
| 193 | 
            +
            - spec/file_spec.rb
         | 
| 194 | 
            +
            - spec/find_by_spec.rb
         | 
| 195 | 
            +
            - spec/integer_ext_spec.rb
         | 
| 196 | 
            +
            - spec/local_spec.rb
         | 
| 197 | 
            +
            - spec/path_spec.rb
         | 
| 198 | 
            +
            - spec/process_set_spec.rb
         | 
| 199 | 
            +
            - spec/process_spec.rb
         | 
| 200 | 
            +
            - spec/rush_spec.rb
         | 
| 201 | 
            +
            - spec/search_results_spec.rb
         | 
| 202 | 
            +
            - spec/shell_spec.rb
         | 
| 203 | 
            +
            - spec/ssh_tunnel_spec.rb
         | 
| 204 | 
            +
            - spec/string_ext_spec.rb
         | 
| 205 | 
            +
            homepage: https://github.com/protolif/rush
         | 
| 206 | 
            +
            licenses:
         | 
| 207 | 
            +
            - MIT
         | 
| 208 | 
            +
            metadata: {}
         | 
| 209 | 
            +
            post_install_message: 
         | 
| 210 | 
            +
            rdoc_options: []
         | 
| 211 | 
            +
            require_paths:
         | 
| 212 | 
            +
            - lib
         | 
| 213 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 214 | 
            +
              requirements:
         | 
| 215 | 
            +
              - - ">="
         | 
| 216 | 
            +
                - !ruby/object:Gem::Version
         | 
| 217 | 
            +
                  version: '0'
         | 
| 218 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 219 | 
            +
              requirements:
         | 
| 220 | 
            +
              - - ">="
         | 
| 221 | 
            +
                - !ruby/object:Gem::Version
         | 
| 222 | 
            +
                  version: '0'
         | 
| 223 | 
            +
            requirements: []
         | 
| 224 | 
            +
            rubygems_version: 3.0.2
         | 
| 225 | 
            +
            signing_key: 
         | 
| 226 | 
            +
            specification_version: 4
         | 
| 227 | 
            +
            summary: A Ruby replacement for bash+ssh.
         | 
| 228 | 
            +
            test_files: []
         |