Class: SimpleProvision::Server
- Inherits:
-
Object
- Object
- SimpleProvision::Server
- Defined in:
- lib/simple_provision/server.rb
Constant Summary collapse
- ServerNotFound =
Class.new(StandardError)
- MissingDropletName =
Class.new(StandardError)
Instance Attribute Summary collapse
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
- #configure ⇒ Object
- #environment_exports ⇒ Object
-
#initialize(connection, options) ⇒ Server
constructor
A new instance of Server.
Constructor Details
#initialize(connection, options) ⇒ Server
Returns a new instance of Server.
10 11 12 |
# File 'lib/simple_provision/server.rb', line 10 def initialize(connection, ) @connection, @options = connection, end |
Instance Attribute Details
#server ⇒ Object (readonly)
Returns the value of attribute server.
8 9 10 |
# File 'lib/simple_provision/server.rb', line 8 def server @server end |
Instance Method Details
#configure ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/simple_provision/server.rb', line 14 def configure get([:droplet_name]) if server.nil? raise ServerNotFound, "Unable to find server with Droplet name #{[:droplet_name]}." if server.nil? SimpleProvision::SCP.new(server, ).to_server scripts = .fetch(:scripts).map do |script| "#{environment_exports} bash -c '#{script}'" end server.ssh(scripts) end |
#environment_exports ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/simple_provision/server.rb', line 25 def environment_exports @environment_exports ||= begin if [:env].nil? "" else [:env].map { |k, v| [k, Shellwords.escape(v)].join("=") }.join(" ") end end end |