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.
-
#github_pages ⇒ Object
Returns the value of attribute github_pages.
-
#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
- .define(project_name, key, &block) ⇒ Object
- .setting(*fields) ⇒ Object
- .setting_with_deprecation(*fields, message:) ⇒ Object
Instance Method Summary collapse
- #copy_dir(path, to:, verbose: false) ⇒ Object
- #copy_file(path, to:, verbose: false) ⇒ Object
- #exec!(command, home: false) ⇒ Object
- #option(key, value) ⇒ Object
- #port ⇒ Object
- #rsync_uri(file_path = nil) ⇒ Object
- #run(command, home: false, verbose: false, quiet: false) ⇒ Object
- #run!(command, home: false, verbose: false, quiet: false, capture: false) ⇒ Object
- #scp_uri(file_path = nil) ⇒ Object
- #ssh_uri(which = :ssh) ⇒ Object
- #strategy(name) ⇒ Object
- #strategy_name ⇒ Object
- #strategy_options ⇒ Object
- #to_sym ⇒ Object
- #with(attrs) ⇒ Object
Instance Attribute Details
#env ⇒ Object
Returns the value of attribute env
7 8 9 |
# File 'lib/bard/server.rb', line 7 def env @env end |
#gateway ⇒ Object
Returns the value of attribute gateway
7 8 9 |
# File 'lib/bard/server.rb', line 7 def gateway @gateway end |
#github_pages ⇒ Object
Returns the value of attribute github_pages
7 8 9 |
# File 'lib/bard/server.rb', line 7 def github_pages @github_pages end |
#key ⇒ Object
Returns the value of attribute key
7 8 9 |
# File 'lib/bard/server.rb', line 7 def key @key end |
#path(*args) ⇒ Object
Returns the value of attribute path
7 8 9 |
# File 'lib/bard/server.rb', line 7 def path @path end |
#ping(*args) ⇒ Object
Returns the value of attribute ping
7 8 9 |
# File 'lib/bard/server.rb', line 7 def ping @ping end |
#project_name ⇒ Object
Returns the value of attribute project_name
7 8 9 |
# File 'lib/bard/server.rb', line 7 def project_name @project_name end |
#ssh ⇒ Object
Returns the value of attribute ssh
7 8 9 |
# File 'lib/bard/server.rb', line 7 def ssh @ssh end |
#ssh_key ⇒ Object
Returns the value of attribute ssh_key
7 8 9 |
# File 'lib/bard/server.rb', line 7 def ssh_key @ssh_key end |
Class Method Details
.define(project_name, key, &block) ⇒ Object
8 9 10 11 12 |
# File 'lib/bard/server.rb', line 8 def self.define project_name, key, &block new(project_name, key).tap do |server| server.instance_eval &block end end |
.setting(*fields) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/bard/server.rb', line 14 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 |
.setting_with_deprecation(*fields, message:) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/bard/server.rb', line 28 def self.setting_with_deprecation *fields, message: fields.each do |field| define_method field do |*args| if args.length == 1 Deprecation.warn 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
155 156 157 |
# File 'lib/bard/server.rb', line 155 def copy_dir path, to:, verbose: false Bard::Copy.dir path, from: self, to:, verbose: end |
#copy_file(path, to:, verbose: false) ⇒ Object
151 152 153 |
# File 'lib/bard/server.rb', line 151 def copy_file path, to:, verbose: false Bard::Copy.file path, from: self, to:, verbose: end |
#exec!(command, home: false) ⇒ Object
147 148 149 |
# File 'lib/bard/server.rb', line 147 def exec! command, home: false Bard::Command.exec! command, on: self, home: end |
#option(key, value) ⇒ Object
85 86 87 88 89 |
# File 'lib/bard/server.rb', line 85 def option(key, value) Deprecation.warn "`option` is deprecated; pass options as keyword arguments to the strategy method, e.g., `jets \"url\", run_tests: true` (will be removed in v2.0)" @options ||= {} @options[key] = value end |
#port ⇒ Object
104 105 106 |
# File 'lib/bard/server.rb', line 104 def port ssh_uri.port || 22 end |
#rsync_uri(file_path = nil) ⇒ Object
116 117 118 119 120 121 122 123 124 |
# File 'lib/bard/server.rb', line 116 def rsync_uri file_path=nil str = ssh_uri.dup.tap do |uri| uri.send :set_scheme, nil uri.send :set_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
143 144 145 |
# File 'lib/bard/server.rb', line 143 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, capture: false) ⇒ Object
138 139 140 141 |
# File 'lib/bard/server.rb', line 138 def run! command, home: false, verbose: false, quiet: false, capture: false result = Bard::Command.run!(command, on: self, home:, verbose:, quiet:) result if capture end |
#scp_uri(file_path = nil) ⇒ Object
108 109 110 111 112 113 114 |
# File 'lib/bard/server.rb', line 108 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
99 100 101 102 |
# File 'lib/bard/server.rb', line 99 def ssh_uri which=:ssh value = send(which) URI("ssh://#{value}") end |
#strategy(name) ⇒ Object
80 81 82 83 |
# File 'lib/bard/server.rb', line 80 def strategy(name) Deprecation.warn "`strategy` is deprecated; use the strategy method directly, e.g., `jets \"url\"` instead of `strategy :jets` (will be removed in v2.0)" @strategy = name end |
#strategy_name ⇒ Object
91 92 93 |
# File 'lib/bard/server.rb', line 91 def strategy_name @strategy end |
#strategy_options ⇒ Object
95 96 97 |
# File 'lib/bard/server.rb', line 95 def @options || {} end |
#to_sym ⇒ Object
134 135 136 |
# File 'lib/bard/server.rb', line 134 def to_sym key end |
#with(attrs) ⇒ Object
126 127 128 129 130 131 132 |
# File 'lib/bard/server.rb', line 126 def with(attrs) dup.tap do |s| attrs.each do |key, value| s.send key, value end end end |