Class: Bard::Server
- Inherits:
-
Struct
- Object
- Struct
- Bard::Server
- Defined in:
- lib/bard/server.rb
Instance Attribute Summary collapse
-
#env ⇒ Object
Returns the value of attribute env.
-
#gateway ⇒ Object
Returns the value of attribute gateway.
-
#key ⇒ Object
Returns the value of attribute key.
-
#path(*args) ⇒ Object
Returns the value of attribute path.
-
#ping(*args) ⇒ Object
Returns the value of attribute ping.
-
#project_name ⇒ Object
Returns the value of attribute project_name.
-
#ssh ⇒ Object
Returns the value of attribute ssh.
-
#ssh_key ⇒ Object
Returns the value of attribute ssh_key.
Class Method Summary collapse
Instance Method Summary collapse
- #copy_dir(path, to:, verbose: false) ⇒ Object
- #copy_file(path, to:, verbose: false) ⇒ Object
- #exec!(command, home: false) ⇒ Object
- #rsync_uri(file_path = nil) ⇒ Object
- #run(command, home: false, verbose: false, quiet: false) ⇒ Object
- #run!(command, home: false, verbose: false, quiet: false) ⇒ Object
- #scp_uri(file_path = nil) ⇒ Object
- #ssh_uri(which = :ssh) ⇒ Object
- #to_sym ⇒ Object
- #with(attrs) ⇒ Object
Instance Attribute Details
#env ⇒ Object
Returns the value of attribute env
6 7 8 |
# File 'lib/bard/server.rb', line 6 def env @env end |
#gateway ⇒ Object
Returns the value of attribute gateway
6 7 8 |
# File 'lib/bard/server.rb', line 6 def gateway @gateway end |
#key ⇒ Object
Returns the value of attribute key
6 7 8 |
# File 'lib/bard/server.rb', line 6 def key @key end |
#path(*args) ⇒ Object
Returns the value of attribute path
6 7 8 |
# File 'lib/bard/server.rb', line 6 def path @path end |
#ping(*args) ⇒ Object
Returns the value of attribute ping
6 7 8 |
# File 'lib/bard/server.rb', line 6 def ping @ping end |
#project_name ⇒ Object
Returns the value of attribute project_name
6 7 8 |
# File 'lib/bard/server.rb', line 6 def project_name @project_name end |
#ssh ⇒ Object
Returns the value of attribute ssh
6 7 8 |
# File 'lib/bard/server.rb', line 6 def ssh @ssh end |
#ssh_key ⇒ Object
Returns the value of attribute ssh_key
6 7 8 |
# File 'lib/bard/server.rb', line 6 def ssh_key @ssh_key end |
Class Method Details
.define(project_name, key, &block) ⇒ Object
7 8 9 10 11 |
# File 'lib/bard/server.rb', line 7 def self.define project_name, key, &block new(project_name, key).tap do |server| server.instance_eval &block end end |
.setting(*fields) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bard/server.rb', line 13 def self.setting *fields fields.each do |field| define_method field do |*args| if args.length == 1 send :"#{field}=", args.first elsif args.length == 0 super() else raise ArgumentError end end end end |
Instance Method Details
#copy_dir(path, to:, verbose: false) ⇒ Object
112 113 114 |
# File 'lib/bard/server.rb', line 112 def copy_dir path, to:, verbose: false Bard::Copy.dir path, from: self, to:, verbose: end |
#copy_file(path, to:, verbose: false) ⇒ Object
108 109 110 |
# File 'lib/bard/server.rb', line 108 def copy_file path, to:, verbose: false Bard::Copy.file path, from: self, to:, verbose: end |
#exec!(command, home: false) ⇒ Object
104 105 106 |
# File 'lib/bard/server.rb', line 104 def exec! command, home: false Bard::Command.exec! command, on: self, home: end |
#rsync_uri(file_path = nil) ⇒ Object
74 75 76 77 78 79 80 81 82 |
# File 'lib/bard/server.rb', line 74 def rsync_uri file_path=nil str = ssh_uri.dup.tap do |uri| uri.scheme = nil uri.port = nil end.to_s[2..] str += ":#{path}" str += "/#{file_path}" if file_path str end |
#run(command, home: false, verbose: false, quiet: false) ⇒ Object
100 101 102 |
# File 'lib/bard/server.rb', line 100 def run command, home: false, verbose: false, quiet: false Bard::Command.run command, on: self, home:, verbose:, quiet: end |
#run!(command, home: false, verbose: false, quiet: false) ⇒ Object
96 97 98 |
# File 'lib/bard/server.rb', line 96 def run! command, home: false, verbose: false, quiet: false Bard::Command.run! command, on: self, home:, verbose:, quiet: end |
#scp_uri(file_path = nil) ⇒ Object
66 67 68 69 70 71 72 |
# File 'lib/bard/server.rb', line 66 def scp_uri file_path=nil ssh_uri.dup.tap do |uri| uri.scheme = "scp" uri.path = "/#{path}" uri.path += "/#{file_path}" if file_path end end |
#ssh_uri(which = :ssh) ⇒ Object
61 62 63 64 |
# File 'lib/bard/server.rb', line 61 def ssh_uri which=:ssh value = send(which) URI("ssh://#{value}") end |
#to_sym ⇒ Object
92 93 94 |
# File 'lib/bard/server.rb', line 92 def to_sym key end |
#with(attrs) ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/bard/server.rb', line 84 def with(attrs) dup.tap do |s| attrs.each do |key, value| s.send key, value end end end |