debian-mirror-gitlab/lib/gitlab/import_sources.rb

44 lines
1.4 KiB
Ruby
Raw Normal View History

2015-09-25 12:07:36 +05:30
# Gitlab::ImportSources module
#
# Define import sources that can be used
# during the creation of new project
#
module Gitlab
module ImportSources
2017-08-17 22:00:37 +05:30
ImportSource = Struct.new(:name, :title, :importer)
ImportTable = [
2017-09-10 17:25:29 +05:30
ImportSource.new('github', 'GitHub', Github::Import),
2017-08-17 22:00:37 +05:30
ImportSource.new('bitbucket', 'Bitbucket', Gitlab::BitbucketImport::Importer),
ImportSource.new('gitlab', 'GitLab.com', Gitlab::GitlabImport::Importer),
ImportSource.new('google_code', 'Google Code', Gitlab::GoogleCodeImport::Importer),
ImportSource.new('fogbugz', 'FogBugz', Gitlab::FogbugzImport::Importer),
ImportSource.new('git', 'Repo by URL', nil),
ImportSource.new('gitlab_project', 'GitLab export', Gitlab::ImportExport::Importer),
ImportSource.new('gitea', 'Gitea', Gitlab::GithubImport::Importer)
].freeze
2015-09-25 12:07:36 +05:30
class << self
2017-08-17 22:00:37 +05:30
def options
@options ||= Hash[ImportTable.map { |importer| [importer.title, importer.name] }]
end
2015-09-25 12:07:36 +05:30
def values
2017-08-17 22:00:37 +05:30
@values ||= ImportTable.map(&:name)
2015-09-25 12:07:36 +05:30
end
2017-08-17 22:00:37 +05:30
def importer_names
@importer_names ||= ImportTable.select(&:importer).map(&:name)
end
def importer(name)
ImportTable.find { |import_source| import_source.name == name }.importer
end
def title(name)
options.key(name)
2015-09-25 12:07:36 +05:30
end
end
end
end