Class: Gitlab::ImportExport::Reader

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/import_export/reader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(shared:, config: ImportExport::Config.new.to_h) ⇒ Reader

Returns a new instance of Reader.



8
9
10
11
12
# File 'lib/gitlab/import_export/reader.rb', line 8

def initialize(shared:, config: ImportExport::Config.new.to_h)
  @shared            = shared
  @config            = config
  @attributes_finder = Gitlab::ImportExport::AttributesFinder.new(config: @config)
end

Instance Attribute Details

#attributes_finderObject (readonly)

Returns the value of attribute attributes_finder.



6
7
8
# File 'lib/gitlab/import_export/reader.rb', line 6

def attributes_finder
  @attributes_finder
end

#treeObject (readonly)

Returns the value of attribute tree.



6
7
8
# File 'lib/gitlab/import_export/reader.rb', line 6

def tree
  @tree
end

Instance Method Details

#group_members_treeObject



32
33
34
# File 'lib/gitlab/import_export/reader.rb', line 32

def group_members_tree
  tree_by_key(:group_members)
end

#group_relation_namesObject



28
29
30
# File 'lib/gitlab/import_export/reader.rb', line 28

def group_relation_names
  attributes_finder.find_relations_tree(:group).keys
end

#group_treeObject



24
25
26
# File 'lib/gitlab/import_export/reader.rb', line 24

def group_tree
  tree_by_key(:group)
end

#project_relation_namesObject



20
21
22
# File 'lib/gitlab/import_export/reader.rb', line 20

def project_relation_names
  attributes_finder.find_relations_tree(:project).keys
end

#project_treeObject

Outputs a hash in the format described here: api.rubyonrails.org/classes/ActiveModel/Serializers/JSON.html for outputting a project in JSON format, including its relations and sub relations.



16
17
18
# File 'lib/gitlab/import_export/reader.rb', line 16

def project_tree
  tree_by_key(:project)
end

#tree_by_key(key) ⇒ Object



36
37
38
39
40
41
# File 'lib/gitlab/import_export/reader.rb', line 36

def tree_by_key(key)
  attributes_finder.find_root(key)
rescue StandardError => e
  @shared.error(e)
  false
end