Class: Trent
- Inherits:
-
Object
- Object
- Trent
- Defined in:
- lib/trent.rb
Overview
Communicate with all of the Trent library with this class.
Instance Method Summary collapse
-
#config_github(api_key) ⇒ Object
Configure how to communicate with GitHub.
-
#config_ssh(username, host, password = nil) ⇒ Object
Configure how to run remote SSH commmands on server.
-
#github ⇒ Object
Get instance of GitHub class to run commands against GitHub.
-
#initialize(color = :blue) ⇒ Trent
constructor
A new instance of Trent.
-
#sh(command, fail_non_success = true) ⇒ Object
Run local bash command.
-
#ssh(command, fail_non_success = true) ⇒ Object
Run ssh command.
Constructor Details
Instance Method Details
#config_github(api_key) ⇒ Object
Configure how to communicate with GitHub
22 23 24 |
# File 'lib/trent.rb', line 22 def config_github(api_key) @github = GitHub.new(api_key) end |
#config_ssh(username, host, password = nil) ⇒ Object
Configure how to run remote SSH commmands on server.
17 18 19 |
# File 'lib/trent.rb', line 17 def config_ssh(username, host, password = nil) @ssh = SSH.new(username, host, password: password) end |
#github ⇒ Object
Get instance of GitHub class to run commands against GitHub
56 57 58 59 |
# File 'lib/trent.rb', line 56 def github Log.fatal('You did not configure GitHub yet.') unless @github @github end |
#sh(command, fail_non_success = true) ⇒ Object
Run local bash command
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/trent.rb', line 39 def sh(command, fail_non_success = true) puts command.colorize(@color) result = @sh.run(command) unless result[:result] if fail_non_success Log.fatal('Command failed with a non 0 exit status.') else Log.warning('Command failed with a non 0 exit status.') end end result end |
#ssh(command, fail_non_success = true) ⇒ Object
Run ssh command
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/trent.rb', line 27 def ssh(command, fail_non_success = true) Log.fatal('You did not configure SSH yet.') unless @ssh puts command.colorize(@color) result = @ssh.run(command) Log.fatal('Command failed with a non 0 exit status.') if !result[:result] && fail_non_success result end |