Class: Stash::Server
- Inherits:
-
Object
- Object
- Stash::Server
- Defined in:
- lib/stash/server.rb
Defined Under Namespace
Classes: CommunicationError
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#password ⇒ Object
Returns the value of attribute password.
-
#root_uri ⇒ Object
Returns the value of attribute root_uri.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #get(path) ⇒ Object
-
#initialize(root_uri, user, password, logger = nil) ⇒ Server
constructor
A new instance of Server.
- #post(path, data) ⇒ Object
- #repository(project_key, repository_slug) ⇒ Object
Constructor Details
#initialize(root_uri, user, password, logger = nil) ⇒ Server
Returns a new instance of Server.
10 11 12 13 14 15 |
# File 'lib/stash/server.rb', line 10 def initialize(root_uri, user, password, logger = nil) self.root_uri = root_uri self.user = user self.password = password self.logger = logger end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
8 9 10 |
# File 'lib/stash/server.rb', line 8 def logger @logger end |
#password ⇒ Object
Returns the value of attribute password.
8 9 10 |
# File 'lib/stash/server.rb', line 8 def password @password end |
#root_uri ⇒ Object
Returns the value of attribute root_uri.
8 9 10 |
# File 'lib/stash/server.rb', line 8 def root_uri @root_uri end |
#user ⇒ Object
Returns the value of attribute user.
8 9 10 |
# File 'lib/stash/server.rb', line 8 def user @user end |
Instance Method Details
#get(path) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/stash/server.rb', line 23 def get(path) with_error_handling do logged('Response') do HTTParty.get(endpoint + path, auth.merge(logging)) end end end |
#post(path, data) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/stash/server.rb', line 31 def post(path, data) with_error_handling do logged('Response') do HTTParty.post(endpoint + path, auth.merge(content_type).merge(body: data.to_json).merge(logging)) end end end |
#repository(project_key, repository_slug) ⇒ Object
17 18 19 20 21 |
# File 'lib/stash/server.rb', line 17 def repository(project_key, repository_slug) key = "#{project_key}/#{repository_slug}" @repositories ||= {} @repositories[key] ||= Repository.new(self, project_key, repository_slug) end |