debian-mirror-gitlab/lib/gitlab/legacy_github_import/base_formatter.rb

31 lines
773 B
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
module Gitlab
2018-03-17 18:26:18 +05:30
module LegacyGithubImport
class BaseFormatter
2017-08-17 22:00:37 +05:30
attr_reader :client, :formatter, :project, :raw_data
2017-08-17 22:00:37 +05:30
def initialize(project, raw_data, client = nil)
@project = project
@raw_data = raw_data
2017-08-17 22:00:37 +05:30
@client = client
@formatter = Gitlab::ImportFormatter.new
end
2018-12-05 23:21:45 +05:30
# rubocop: disable CodeReuse/ActiveRecord
def create!
2018-03-17 18:26:18 +05:30
association = project.public_send(project_association) # rubocop:disable GitlabSecurity/PublicSend
association.find_or_create_by!(find_condition) do |record|
2016-11-03 12:29:30 +05:30
record.attributes = attributes
end
end
2018-12-05 23:21:45 +05:30
# rubocop: enable CodeReuse/ActiveRecord
2017-08-17 22:00:37 +05:30
def url
raw_data.url || ''
2016-09-29 09:46:39 +05:30
end
end
end
end