debian-mirror-gitlab/lib/gitlab/import_export/reader.rb

37 lines
937 B
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
2016-06-22 15:30:34 +05:30
module Gitlab
module ImportExport
class Reader
2018-06-03 19:52:53 +05:30
attr_reader :tree, :attributes_finder
2016-06-22 15:30:34 +05:30
2019-12-26 22:10:19 +05:30
def initialize(shared:, config: ImportExport::Config.new.to_h)
@shared = shared
@config = config
@attributes_finder = Gitlab::ImportExport::AttributesFinder.new(config: @config)
2016-06-22 15:30:34 +05:30
end
# Outputs a hash in the format described here: http://api.rubyonrails.org/classes/ActiveModel/Serializers/JSON.html
# for outputting a project in JSON format, including its relations and sub relations.
def project_tree
2019-12-26 22:10:19 +05:30
tree_by_key(:project)
end
def group_tree
tree_by_key(:group)
2016-06-22 15:30:34 +05:30
end
2017-08-17 22:00:37 +05:30
def group_members_tree
2019-12-26 22:10:19 +05:30
tree_by_key(:group_members)
end
def tree_by_key(key)
attributes_finder.find_root(key)
rescue => e
@shared.error(e)
false
2016-06-22 15:30:34 +05:30
end
end
end
end