Class: Etna::Clients::Metis::WalkMetisWorkflow

Inherits:
Struct
  • Object
show all
Defined in:
lib/etna/clients/metis/workflows/walk_metis_workflow.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bucket_nameObject

Returns the value of attribute bucket_name

Returns:

  • (Object)

    the current value of bucket_name



4
5
6
# File 'lib/etna/clients/metis/workflows/walk_metis_workflow.rb', line 4

def bucket_name
  @bucket_name
end

#loggerObject

Returns the value of attribute logger

Returns:

  • (Object)

    the current value of logger



4
5
6
# File 'lib/etna/clients/metis/workflows/walk_metis_workflow.rb', line 4

def logger
  @logger
end

#metis_clientObject

Returns the value of attribute metis_client

Returns:

  • (Object)

    the current value of metis_client



4
5
6
# File 'lib/etna/clients/metis/workflows/walk_metis_workflow.rb', line 4

def metis_client
  @metis_client
end

#project_nameObject

Returns the value of attribute project_name

Returns:

  • (Object)

    the current value of project_name



4
5
6
# File 'lib/etna/clients/metis/workflows/walk_metis_workflow.rb', line 4

def project_name
  @project_name
end

#root_dirObject

Returns the value of attribute root_dir

Returns:

  • (Object)

    the current value of root_dir



4
5
6
# File 'lib/etna/clients/metis/workflows/walk_metis_workflow.rb', line 4

def root_dir
  @root_dir
end

Instance Method Details

#each(&block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/etna/clients/metis/workflows/walk_metis_workflow.rb', line 6

def each(&block)
  q = [self.root_dir]

  while (n = q.pop)
    req = Etna::Clients::Metis::ListFolderRequest.new(
      project_name: project_name,
      bucket_name: bucket_name,
      folder_path: n
    )
    next unless metis_client.folder_exists?(req)
    resp = metis_client.list_folder(req)

    resp.files.all.sort_by { |f| f.file_path[self.root_dir.length..-1] }.each do |file|
      yield [file, file.file_path[self.root_dir.length..-1]]
    end

    resp.folders.all.sort_by { |f| f.folder_path[self.root_dir.length..-1] }.each do |f|
      yield [f, f.folder_path[self.root_dir.length..-1]]
      q << f.folder_path
    end
  end
end