Navigation Menu

Skip to content

stevenosloan/here_or_there

Repository files navigation

Unified interface for ssh or local commands.

Build Status Code Climate

Use

For running local commands it is very much like using the Open3 standard lib, only it returns the same response object as ssh commands.

require 'here_or_there'
include HereOrThere

command = 'whoami'
resp = run_local( command )
resp.stdout
# => "user\n"
resp.stderr
# => ""
resp.success?
# => true

Remote processes are very similar, except that you also pass the information required to establish the remote connection.

require 'here_or_there'
include HereOrThere

command = 'whoami'
resp = run_remote( command, hostname: 'your_remote', username: 'user', password: 'password' )
resp.stdout
# => "user\n"
resp.stderr
# => ""
resp.success?
# => true

# if you have .ssh/config setup, hostname is all that is required

resp = run_remote( command, hostname: 'your_remote' )
resp.stdout
# => "ssh_user\n"
resp.stderr
# => ""
resp.success?
# => true

Response Object

Response objects respond as you expect they would to stdout and stderr giving you those values. It also has a success? method that will retun a bolean of whether the command exited 0 or not.

Ruby Support

Here or There is tested against and supports:

  • 2.0.0
  • 1.9.3
  • rubinius 2.0

If you have experience with and could help out adding jruby support that would be greatly appreciated.

Testing

Tests are run using rspec. Net::SSH sessions are stubbed to prevent needing an actual connection for the suite to run.

$ rspec

Contributing

If there is any thing you'd like to contribute or fix, please:

  • Fork the repo
  • Add tests for any new functionality
  • Make your changes
  • Verify all new & existing tests pass
  • Make a pull request

License

The here_or_there gem is distributed under the MIT License.

About

Unified wrapper for running local or ssh commands

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages