Class: Stash::Server
- Inherits:
-
Object
- Object
- Stash::Server
- Defined in:
- lib/stash/server.rb
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
8 9 10 11 12 13 |
# File 'lib/stash/server.rb', line 8 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.
6 7 8 |
# File 'lib/stash/server.rb', line 6 def logger @logger end |
#password ⇒ Object
Returns the value of attribute password.
6 7 8 |
# File 'lib/stash/server.rb', line 6 def password @password end |
#root_uri ⇒ Object
Returns the value of attribute root_uri.
6 7 8 |
# File 'lib/stash/server.rb', line 6 def root_uri @root_uri end |
#user ⇒ Object
Returns the value of attribute user.
6 7 8 |
# File 'lib/stash/server.rb', line 6 def user @user end |
Instance Method Details
#get(path) ⇒ Object
21 22 23 24 25 |
# File 'lib/stash/server.rb', line 21 def get(path) logged('Response') do HTTParty.get(endpoint + path, auth.merge(logging)) end end |
#post(path, data) ⇒ Object
27 28 29 30 31 |
# File 'lib/stash/server.rb', line 27 def post(path, data) logged('Response') do HTTParty.post(endpoint + path, auth.merge(content_type).merge(body: data.to_json).merge(logging)) end end |
#repository(project_key, repository_slug) ⇒ Object
15 16 17 18 19 |
# File 'lib/stash/server.rb', line 15 def repository(project_key, repository_slug) key = "#{project_key}/#{repository_slug}" @repositories ||= {} @repositories[key] ||= Repository.new(self, project_key, repository_slug) end |