class Bard::Server
Public Class Methods
define(project_name, key, &block)
click to toggle source
# 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)
click to toggle source
Calls superclass method
# 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
Public Instance Methods
copy_dir(path, to:, verbose: false)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# File lib/bard/server.rb, line 104 def exec! command, home: false Bard::Command.exec! command, on: self, home: end
path(*args)
click to toggle source
Calls superclass method
# File lib/bard/server.rb, line 51 def path(*args) if args.length == 1 self.path = args.first elsif args.length == 0 super() || project_name else raise ArgumentError end end
ping(*args)
click to toggle source
Calls superclass method
# File lib/bard/server.rb, line 29 def ping(*args) if args.length == 0 (super() || [nil]).map(&method(:normalize_ping)).flatten else self.ping = args end end
rsync_uri(file_path=nil)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# File lib/bard/server.rb, line 61 def ssh_uri which=:ssh value = send(which) URI("ssh://#{value}") end
to_sym()
click to toggle source
# File lib/bard/server.rb, line 92 def to_sym key end
with(attrs)
click to toggle source
# 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
Private Instance Methods
normalize_ping(value)
click to toggle source
# File lib/bard/server.rb, line 37 def normalize_ping value return [] if value == false normalized = "https://#{ssh_uri.host}" # default if none specified if value =~ %r{^/} normalized += value elsif value.to_s.length > 0 normalized = value end if normalized !~ /^http/ normalized = "https://#{normalized}" end normalized end