Class: Lobstr::Base
- Inherits:
-
Object
- Object
- Lobstr::Base
- Defined in:
- lib/lobstr/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#branch ⇒ Object
Returns the value of attribute branch.
-
#config ⇒ Object
Returns the value of attribute config.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#ssh ⇒ Object
Returns the value of attribute ssh.
Instance Method Summary collapse
- #connect(&block) ⇒ Object
- #local_task(cmd) ⇒ Object
- #parse_target(target) ⇒ Object
- #remote_task(cmd) ⇒ Object
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
4 5 6 |
# File 'lib/lobstr/base.rb', line 4 def app @app end |
#branch ⇒ Object
Returns the value of attribute branch.
4 5 6 |
# File 'lib/lobstr/base.rb', line 4 def branch @branch end |
#config ⇒ Object
Returns the value of attribute config.
4 5 6 |
# File 'lib/lobstr/base.rb', line 4 def config @config end |
#environment ⇒ Object
Returns the value of attribute environment.
4 5 6 |
# File 'lib/lobstr/base.rb', line 4 def environment @environment end |
#ssh ⇒ Object
Returns the value of attribute ssh.
4 5 6 |
# File 'lib/lobstr/base.rb', line 4 def ssh @ssh end |
Instance Method Details
#connect(&block) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/lobstr/base.rb', line 18 def connect(&block) @ssh = ::Net::SSH.start(@config['ssh_host'], @config['ssh_user'], :keys => [@config['ssh_key']], :auth_methods => %w{ publickey }) instance_eval(&block) if block_given? end |
#local_task(cmd) ⇒ Object
30 31 32 |
# File 'lib/lobstr/base.rb', line 30 def local_task(cmd) `#{cmd}` end |
#parse_target(target) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/lobstr/base.rb', line 5 def parse_target(target) branch,environment = target.split('@', 2) if environment.nil? # e.g. production environment = branch branch = 'master' end branch = "master" if branch.empty? # e.g. @production environment = "production" if environment.empty? # e.g. master@ [branch,environment] end |
#remote_task(cmd) ⇒ Object
26 27 28 |
# File 'lib/lobstr/base.rb', line 26 def remote_task(cmd) @ssh.exec! cmd end |