Class: Bucket::Client
- Inherits:
-
Object
- Object
- Bucket::Client
- Defined in:
- lib/bucket/client.rb
Constant Summary collapse
- GIT_URL =
"[email protected]"
Instance Method Summary collapse
-
#create_repo(name, options = {}) ⇒ Object
Returns the created repository scm url.
-
#initialize(credentials) ⇒ Client
constructor
A new instance of Client.
-
#repo_full_name(repo) ⇒ Object
A repository full name is of the style of [USER]/.
-
#repo_url(name) ⇒ Object
Full url for the given repository The repository name must be of the style [USER]/ or [REPOSITORY] in which case the name of the current user will be used as owner.
- #repos_list ⇒ Object
Constructor Details
#initialize(credentials) ⇒ Client
Returns a new instance of Client.
5 6 7 8 |
# File 'lib/bucket/client.rb', line 5 def initialize(credentials) @connection = BitBucket.new(basic_auth: "#{credentials["username"]}:#{credentials["password"]}") @user = credentials["username"] end |
Instance Method Details
#create_repo(name, options = {}) ⇒ Object
Returns the created repository scm url
38 39 40 41 42 |
# File 'lib/bucket/client.rb', line 38 def create_repo(name, ={}) = .merge(is_private: ![:public]) @connection.repos.create(.merge(name: name)) end |
#repo_full_name(repo) ⇒ Object
A repository full name is of the style of [USER]/
33 34 35 |
# File 'lib/bucket/client.rb', line 33 def repo_full_name(repo) "#{repo[:owner]}/#{repo[:slug]}" end |
#repo_url(name) ⇒ Object
Full url for the given repository The repository name must be of the style [USER]/ or
- REPOSITORY
-
in which case the name of the current user
will be used as owner
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/bucket/client.rb', line 18 def repo_url(name) split_name = name.split "/" if split_name.size == 1 user = @user slug = split_name[0] else user = split_name[0] slug = split_name[1] end "#{GIT_URL}:#{user}/#{slug}.git" end |
#repos_list ⇒ Object
10 11 12 |
# File 'lib/bucket/client.rb', line 10 def repos_list @connection.repos.list end |