Class: Gitlab::ImportExport::Json::NdjsonWriter
- Inherits:
-
Object
- Object
- Gitlab::ImportExport::Json::NdjsonWriter
show all
- Includes:
- CommandLineUtil
- Defined in:
- lib/gitlab/import_export/json/ndjson_writer.rb
Constant Summary
CommandLineUtil::CLEAN_DIR_IGNORE_FILE_NAMES, CommandLineUtil::CommandLineUtilError, CommandLineUtil::DEFAULT_DIR_MODE, CommandLineUtil::FileOversizedError, CommandLineUtil::HardLinkError, CommandLineUtil::UNTAR_MASK
Instance Method Summary
collapse
#gunzip, #gzip, #gzip_with_options, #mkdir_p, #tar_cf, #tar_czf, #untar_xf, #untar_zxf
Constructor Details
Returns a new instance of NdjsonWriter.
9
10
11
|
# File 'lib/gitlab/import_export/json/ndjson_writer.rb', line 9
def initialize(dir_path)
@dir_path = dir_path
end
|
Instance Method Details
#close ⇒ Object
13
14
|
# File 'lib/gitlab/import_export/json/ndjson_writer.rb', line 13
def close
end
|
#write_attributes(exportable_path, hash) ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/gitlab/import_export/json/ndjson_writer.rb', line 16
def write_attributes(exportable_path, hash)
with_file("#{exportable_path}.json") do |file|
file.write(hash.to_json)
end
end
|
#write_relation(exportable_path, relation, value) ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/gitlab/import_export/json/ndjson_writer.rb', line 24
def write_relation(exportable_path, relation, value)
with_file(exportable_path, "#{relation}.ndjson") do |file|
file.write(value.to_json)
end
end
|
#write_relation_array(exportable_path, relation, items) ⇒ Object
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/gitlab/import_export/json/ndjson_writer.rb', line 32
def write_relation_array(exportable_path, relation, items)
with_file(exportable_path, "#{relation}.ndjson") do |file|
items.each do |item|
file.write(item.to_json)
file.write("\n")
end
end
end
|