Class: Stash::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/stash/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#loggerObject

Returns the value of attribute logger.



6
7
8
# File 'lib/stash/server.rb', line 6

def logger
  @logger
end

#passwordObject

Returns the value of attribute password.



6
7
8
# File 'lib/stash/server.rb', line 6

def password
  @password
end

#root_uriObject

Returns the value of attribute root_uri.



6
7
8
# File 'lib/stash/server.rb', line 6

def root_uri
  @root_uri
end

#userObject

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