Class: Gitlab::FogbugzImport::Importer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project) ⇒ Importer

Returns a new instance of Importer.



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

def initialize(project)
  @project = project

  import_data = project.import_data.try(:data)
  repo_data = import_data['repo'] if import_data
  if repo_data
    @repo = FogbugzImport::Repository.new(repo_data)
    @known_labels = Set.new
  else
    raise Projects::ImportService::Error, "Unable to find project import data credentials for project ID: #{@project.id}"
  end
end

Instance Attribute Details

#projectObject (readonly)

Returns the value of attribute project.



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

def project
  @project
end

#repoObject (readonly)

Returns the value of attribute repo.



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

def repo
  @repo
end

Instance Method Details

#executeObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/gitlab/fogbugz_import/importer.rb', line 21

def execute
  return true unless repo.valid?

  client = Gitlab::FogbugzImport::Client.new(token: fb_session[:token], uri: fb_session[:uri])

  @cases = client.cases(@repo.id.to_i)
  @categories = client.categories

  import_cases

  true
end