Class: Gitlab::ImportExport::Reader
- Inherits:
-
Object
- Object
- Gitlab::ImportExport::Reader
- Defined in:
- lib/gitlab/import_export/reader.rb
Instance Attribute Summary collapse
-
#attributes_finder ⇒ Object
readonly
Returns the value of attribute attributes_finder.
-
#tree ⇒ Object
readonly
Returns the value of attribute tree.
Instance Method Summary collapse
- #group_members_tree ⇒ Object
- #group_relation_names ⇒ Object
- #group_tree ⇒ Object
-
#initialize(shared:, config: ImportExport::Config.new.to_h) ⇒ Reader
constructor
A new instance of Reader.
- #project_relation_names ⇒ Object
-
#project_tree ⇒ Object
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.
- #tree_by_key(key) ⇒ Object
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_finder ⇒ Object (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 |
#tree ⇒ Object (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_tree ⇒ Object
32 33 34 |
# File 'lib/gitlab/import_export/reader.rb', line 32 def group_members_tree tree_by_key(:group_members) end |
#group_relation_names ⇒ Object
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_tree ⇒ Object
24 25 26 |
# File 'lib/gitlab/import_export/reader.rb', line 24 def group_tree tree_by_key(:group) end |
#project_relation_names ⇒ Object
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_tree ⇒ Object
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 |