Class: EtnaApp::Administrate::Models::Attributes::CreateFileLinkingCsv

Inherits:
Etna::Command
  • Object
show all
Includes:
WithEtnaClients
Defined in:
lib/commands.rb

Instance Attribute Summary

Attributes inherited from Etna::Command

#parent

Instance Method Summary collapse

Methods included from WithEtnaClients

#environment, #exit, exit, #janus_client, #magma_client, #metis_client, #polyphemus_client, #token

Methods inherited from Etna::Command

#completions, #fill_in_missing_params, #find_command, #initialize, parent_scope, #setup

Methods included from Etna::CommandOrExecutor

#command_name, #completions_for, #desc, #flag_argspec, #flag_as_parameter, included, #parse_flags, #program_name, #usage

Constructor Details

This class inherits a constructor from Etna::Command

Instance Method Details

#execute(project_name, bucket_name, attribute_name, extension, collection: false, regex: "**/*/(?<identifier>.+)\\.#{extension}$", folder: "", file: "#{project_name}_#{attribute_name}.csv") ⇒ Object



311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
# File 'lib/commands.rb', line 311

def execute(project_name, bucket_name, attribute_name, extension, collection: false, regex: "**/*/(?<identifier>.+)\\.#{extension}$", folder: "", file: "#{project_name}_#{attribute_name}.csv")
  if folder.start_with?("/")
    folder = folder.slice(1..-1)
  end

  regex = Regexp.new(regex)

  workflow = Etna::Clients::Magma::SimpleFileLinkingWorkflow.new(
      metis_client: metis_client,
      project_name: project_name,
      bucket_name: bucket_name,
      folder: folder,
      extension: extension,
      attribute_name: attribute_name,
      regex: regex,
      file_collection: collection,
  )

  workflow.write_csv_io(filename: file)
end