Class: Mountebank::Network
- Inherits:
-
Object
- Object
- Mountebank::Network
- Defined in:
- lib/mountebank/network.rb
Class Method Summary collapse
- .connection ⇒ Object
- .delete(uri) ⇒ Object
- .get(uri) ⇒ Object
- .mountebank_server ⇒ Object
- .mountebank_server_port ⇒ Object
- .mountebank_server_uri ⇒ Object
- .post(uri, data) ⇒ Object
- .put(uri, data) ⇒ Object
Class Method Details
.connection ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/mountebank/network.rb', line 6 def self.connection @conn ||= Faraday.new(url: mountebank_server_uri) do |conn| conn.request :json conn.response :symbolize_keys, :content_type => /\bjson$/ conn.response :json, :content_type => /\bjson$/ conn.adapter Faraday.default_adapter end end |
.delete(uri) ⇒ Object
33 34 35 36 37 |
# File 'lib/mountebank/network.rb', line 33 def self.delete(uri) connection.delete do |req| req.url uri end end |
.get(uri) ⇒ Object
15 16 17 |
# File 'lib/mountebank/network.rb', line 15 def self.get(uri) connection.get(uri) end |
.mountebank_server ⇒ Object
39 40 41 |
# File 'lib/mountebank/network.rb', line 39 def self.mountebank_server ENV['MOUNTEBANK_SERVER'] || 'localhost' end |
.mountebank_server_port ⇒ Object
43 44 45 |
# File 'lib/mountebank/network.rb', line 43 def self.mountebank_server_port ENV['MOUNTEBANK_PORT'] || '2525' end |
.mountebank_server_uri ⇒ Object
47 48 49 |
# File 'lib/mountebank/network.rb', line 47 def self.mountebank_server_uri "http://#{mountebank_server}:#{mountebank_server_port}" end |
.post(uri, data) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/mountebank/network.rb', line 19 def self.post(uri, data) connection.post do |req| req.url uri req.body = data end end |
.put(uri, data) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/mountebank/network.rb', line 26 def self.put(uri, data) connection.put do |req| req.url uri req.body = data end end |