Class: Eco::API::UseCases::Default::Locations::TagtreeExtract

Inherits:
GraphQL::Samples::Location show all
Includes:
Data::Files
Defined in:
lib/eco/api/usecases/default/locations/tagtree_extract_case.rb,
lib/eco/api/usecases/default/locations/cli/tagtree_extract_cli.rb

Overview

Use case to export an org tree into some of the offered forms.

Defined Under Namespace

Classes: Cli

Constant Summary collapse

OUT_FOLDER =
"sftp"
OUT_TIME_FORMAT =
'%Y%m%dT%H%M%S'
OUT_FILENAME =
"live_tree"

Constants included from Data::Files

Data::Files::DEFAULT_TIMESTAMP_PATTERN

Constants included from Data::Files::Encoding

Data::Files::Encoding::BOM_BYTES

Constants included from GraphQL::Helpers::Location::Base

GraphQL::Helpers::Location::Base::TAGTREE_BACKUP

Instance Attribute Summary

Attributes included from Language::AuxiliarLogger

#logger

Attributes included from GraphQL::Helpers::Location::Base

#current_tree, #previous_tree

Attributes included from GraphQL::Helpers::Base::CaseEnv

#options, #session

Instance Method Summary collapse

Methods included from Data::Files::ClassMethods

#copy_file, #create_directory, #csv_files, #dir_exists?, #file_basename, #file_empty?, #file_exists?, #file_fullpath, #file_name, #file_path, #folder_files, #script_subfolder, #split, #timestamp_file

Methods included from Data::Files::Encoding

#encoding, #file_empty?, #file_exists?, #get_file_content_with_encoding, #has_bom?, #remove_bom, #scoped_encoding

Methods included from Language::AuxiliarLogger

#log

Methods included from Data::Files::InstanceMethods

#get_file_content, #read_with_tolerance

Methods included from GraphQL::Helpers::Location::Base

#backup_tree, #live_tree, #session_live_tree, #tagtree_id, #target_structure_id, #track_current_tree

Methods included from GraphQL::Helpers::Base

#backup, #exit_error, #graphql

Methods included from GraphQL::Helpers::Base::CaseEnv

#config, #simulate?

Methods inherited from GraphQL::Base

#main

Methods inherited from Common::Loaders::UseCase

cli, cli!, #cli_apply!, #initialize, #main, type, #type

Methods inherited from Common::Loaders::CaseBase

#name, name_only_once!

Methods inherited from Common::Loaders::Base

<=>, created_at, #initialize, set_created_at!

Methods included from Common::ClassHelpers

#class_resolver, #descendants, #descendants?, #inheritable_attrs, #inheritable_class_vars, #inherited, #instance_variable_name, #new_class, #resolve_class, #to_constant

Constructor Details

This class inherits a constructor from Eco::API::Common::Loaders::UseCase

Instance Method Details

#processObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/eco/api/usecases/default/locations/tagtree_extract_case.rb', line 15

def process
  case format
  when :excel_tree, :excel_nodes
    excel(output_filename) do |workbook|
      tag_trees.each do |tree|
        excel_sheet(workbook, compact_name(tree.name), header: format == :excel_nodes) do |sheet|
          tree_extract(tree).each_with_index do |row, idx|
            sheet.append_row(row)
          end
        end
      end
    end
  when :list, :nodes, :csv_tree, :json
    tag_trees.each do |tree|
      file(output_filename(compact_name(tree.name))) do |fd|
        fd << tree_extract(tree)
      end
    end
  else
    log(:error) { "Unknown selected output format '#{format}'. Abort..." }
    exit 1
  end
end