Class: Remotely::Application
- Inherits:
-
Object
- Object
- Remotely::Application
- Defined in:
- lib/remotely/application.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#basic_auth(user = nil, password = nil) ⇒ Object
Set or get BasicAuth credentials.
-
#connection ⇒ Object
Connection to the application (with BasicAuth if it was set).
-
#initialize(name, &block) ⇒ Application
constructor
A new instance of Application.
-
#url(url = nil) ⇒ Object
Set or get the applications base url.
Constructor Details
#initialize(name, &block) ⇒ Application
Returns a new instance of Application.
5 6 7 8 |
# File 'lib/remotely/application.rb', line 5 def initialize(name, &block) @name = name instance_eval(&block) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/remotely/application.rb', line 3 def name @name end |
Instance Method Details
#basic_auth(user = nil, password = nil) ⇒ Object
Set or get BasicAuth credentials.
24 25 26 27 |
# File 'lib/remotely/application.rb', line 24 def basic_auth(user=nil, password=nil) return @basic_auth unless user && password @basic_auth = [user, password] end |
#connection ⇒ Object
Connection to the application (with BasicAuth if it was set).
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/remotely/application.rb', line 31 def connection return unless @url @connection ||= Faraday::Connection.new(@url) do |b| b.request :url_encoded b.adapter :net_http end @connection.basic_auth(*@basic_auth) if @basic_auth @connection end |
#url(url = nil) ⇒ Object
Set or get the applications base url.
14 15 16 17 |
# File 'lib/remotely/application.rb', line 14 def url(url=nil) return @url unless url @url = URI.parse(set_scheme(url)).to_s end |