Class: Gitlab::FogbugzImport::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/fogbugz_import/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client


8
9
10
11
12
13
14
15
16
# File 'lib/gitlab/fogbugz_import/client.rb', line 8

def initialize(options = {})
  if options[:uri] && options[:token]
    @api = ::Fogbugz::Interface.new(options)
  elsif options[:uri] && options[:email] && options[:password]
    @api = ::Fogbugz::Interface.new(options)
    @api.authenticate
    @api
  end
end

Instance Attribute Details

#apiObject (readonly)

Returns the value of attribute api


6
7
8
# File 'lib/gitlab/fogbugz_import/client.rb', line 6

def api
  @api
end

Instance Method Details

#cases(project_id) ⇒ Object


44
45
46
47
48
49
# File 'lib/gitlab/fogbugz_import/client.rb', line 44

def cases(project_id)
  project_name = repo(project_id).name
  res = @api.command(:search, q: "project:'#{project_name}'", cols: 'ixPersonAssignedTo,ixPersonOpenedBy,ixPersonClosedBy,sStatus,sPriority,sCategory,fOpen,sTitle,sLatestTextSummary,dtOpened,dtClosed,dtResolved,dtLastUpdated,events')
  return [] unless res['cases']['count'].to_i > 0
  res['cases']['case']
end

#categoriesObject


51
52
53
# File 'lib/gitlab/fogbugz_import/client.rb', line 51

def categories
  @api.command(:listCategories)
end

#get_tokenObject


18
19
20
# File 'lib/gitlab/fogbugz_import/client.rb', line 18

def get_token
  @api.token
end

#repo(id) ⇒ Object


40
41
42
# File 'lib/gitlab/fogbugz_import/client.rb', line 40

def repo(id)
  repos.find { |r| r.id.to_s == id.to_s }
end

#reposObject


35
36
37
38
# File 'lib/gitlab/fogbugz_import/client.rb', line 35

def repos
  res = @api.command(:listProjects)
  @repos ||= res['projects']['project'].map { |proj| FogbugzImport::Repository.new(proj) }
end

#user_mapObject


26
27
28
29
30
31
32
33
# File 'lib/gitlab/fogbugz_import/client.rb', line 26

def user_map
  users = {}
  res = @api.command(:listPeople)
  [res['people']['person']].flatten.each do |user|
    users[user['ixPerson']] = { name: user['sFullName'], email: user['sEmail'] }
  end
  users
end

#valid?Boolean

Returns:

  • (Boolean)

22
23
24
# File 'lib/gitlab/fogbugz_import/client.rb', line 22

def valid?
  !get_token.blank?
end