Class: GitDuplicator::Services::BitbucketRepository
- Inherits:
-
GitDuplicator::ServiceRepository
- Object
- Repository
- GitDuplicator::ServiceRepository
- GitDuplicator::Services::BitbucketRepository
- Defined in:
- lib/git_duplicator/services/bitbucket.rb
Overview
Bitbucket based repository
Constant Summary collapse
- BASE_URI =
'https://api.bitbucket.org/2.0'
Instance Attribute Summary collapse
-
#credentials ⇒ Object
Returns the value of attribute credentials.
-
#options ⇒ Object
Returns the value of attribute options.
Attributes inherited from GitDuplicator::ServiceRepository
Attributes inherited from Repository
Instance Method Summary collapse
-
#create ⇒ Object
Create the repositroy.
-
#delete ⇒ Object
Delete the repositroy.
-
#initialize(name, owner, credentials = {}, options = {}) ⇒ BitbucketRepository
constructor
Initializer.
-
#url ⇒ Object
URL of the repositroy.
Methods inherited from Repository
Constructor Details
#initialize(name, owner, credentials = {}, options = {}) ⇒ BitbucketRepository
Initializer
24 25 26 27 28 |
# File 'lib/git_duplicator/services/bitbucket.rb', line 24 def initialize(name, owner, credentials = {}, = {}) super(name, owner) self.credentials = credentials self. = end |
Instance Attribute Details
#credentials ⇒ Object
Returns the value of attribute credentials.
10 11 12 |
# File 'lib/git_duplicator/services/bitbucket.rb', line 10 def credentials @credentials end |
#options ⇒ Object
Returns the value of attribute options.
10 11 12 |
# File 'lib/git_duplicator/services/bitbucket.rb', line 10 def end |
Instance Method Details
#create ⇒ Object
Create the repositroy
37 38 39 40 41 42 43 |
# File 'lib/git_duplicator/services/bitbucket.rb', line 37 def create request_url = BASE_URI + "/repositories/#{owner}/#{name}" response = HTTP.with(headers(:post, request_url)) .post(request_url, json: ) code, body = response.code.to_i, response.body fail(RepositoryCreationError, body) unless 200 == code end |
#delete ⇒ Object
Delete the repositroy
47 48 49 50 51 52 |
# File 'lib/git_duplicator/services/bitbucket.rb', line 47 def delete request_url = BASE_URI + "/repositories/#{owner}/#{name}" response = HTTP.with(headers(:delete, request_url)).delete(request_url) code, body = response.code.to_i, response.body fail(RepositoryDeletionError, body) unless [204, 404].include?(code) end |
#url ⇒ Object
URL of the repositroy
31 32 33 |
# File 'lib/git_duplicator/services/bitbucket.rb', line 31 def url "[email protected]:#{owner}/#{name}.git" end |