Class: Gitload::Sources::Bitbucket

Inherits:
Object
  • Object
show all
Includes:
Source
Defined in:
lib/gitload/sources/bitbucket.rb

Defined Under Namespace

Classes: Repo

Instance Method Summary collapse

Methods included from Source

included

Constructor Details

#initialize(config, options = {}) ⇒ Bitbucket

Returns a new instance of Bitbucket.



9
10
11
12
13
14
15
16
# File 'lib/gitload/sources/bitbucket.rb', line 9

def initialize config, options = {}

  @config = config

  @user = options.fetch :user, ENV['GITLOAD_BITBUCKET_USER']
  password = options.fetch :password, ENV['GITLOAD_BITBUCKET_TOKEN']
  @bitbucket_api = ::BitBucket.new basic_auth: "#{@user}:#{password}"
end

Instance Method Details

#reposObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gitload/sources/bitbucket.rb', line 18

def repos

  puts 'Loading BitBucket projects...'
  data = @config.load_or_cache_data 'bitbucket' do
    Utils.stringify_keys(@bitbucket_api.repos.list)
  end

  data = data.select{ |repo| repo['scm'] == 'git' }

  data.collect{ |d| Repo.new d }
end