Module: Eco::API::UseCases::GraphQL::Samples::Location::Command::DSL

Includes:
Helpers::Location::Command, Results
Included in:
Eco::API::UseCases::GraphQL::Samples::Location::Command
Defined in:
lib/eco/api/usecases/graphql/samples/location/command/dsl.rb

Constant Summary

Constants included from Helpers::Location::Base

Helpers::Location::Base::TAGTREE_BACKUP

Constants included from Helpers::Location::Command

Helpers::Location::Command::COMMANDS_PER_PAGE, Helpers::Location::Command::FORCE_CONTINUE

Instance Attribute Summary

Attributes included from Results

#error, #exception, #tags_remap_csv_file

Attributes included from Helpers::Location::Base

#current_tree, #previous_tree

Attributes included from Helpers::Base

#options, #session

Attributes included from Language::AuxiliarLogger

#logger

Instance Method Summary collapse

Methods included from Results

#generate_tags_remap_csv, #page_errors?, #request_results_class, #rescued, #results, #tags_remap_table, #timestamp_file, #update_tags_remap_table

Methods included from Helpers::Location::Base

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

Methods included from Helpers::Base

#backup, #config, #exit_error, #graphql, #simulate?

Methods included from Language::AuxiliarLogger

#log

Methods included from Helpers::Location::Command

#commands_per_page, #force_continue?, #input, #sliced_batches, #with_sliced_input

Instance Method Details

#inputs(*args, force_continue: force_continue?, , **kargs, &block) ⇒ Object

Examples:

of implementation:

def inputs(command_types, force_continue: force_continue?)
  {}.tap do |sequence|
    command_types.commands do |comms, stage|
      sequence[stage] = input(comms, force_continue: force_continue)
    end
  end.tap do |sequence|
    sequence.each do |stage, input|
      yield(input, stage) if block_given?
    end
  end
end

Raises:



18
19
20
21
22
# File 'lib/eco/api/usecases/graphql/samples/location/command/dsl.rb', line 18

def inputs(*args, force_continue: force_continue?, **kargs, &block)
  msg  = "You should implement this method in your child class.\n"
  msg << "Which should yield the input Hash and the stage or descriptor."
  raise Eco::API::UseCases::GraphQL::Base::NotImplementedMethod, msg
end

#processObject

Main processor



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/eco/api/usecases/graphql/samples/location/command/dsl.rb', line 25

def process
  begin
    super if defined?(super)
  rescue Eco::API::UseCases::GraphQL::Base::NotImplementedMethod
  end

  self.error = false
  # this triggers a backup of the tagtree

  self.current_tree ||= live_tree

  inputs(force_continue: force_continue?) do |input, stage|
    results[stage] ||= []
    sliced_batches(input, desc: stage) do |sliced_input, response, page, pages, done, total|
      track_current_tree(response&.structure)
      page_results = nil
      results[stage] << (page_results = request_results_class.new(sliced_input, response))
      update_tags_remap_table(page_results, stage)
      break if self.error = page_errors?(page_results, page, pages, done, total, stage: stage)
    end

    break if error
  end
rescue StandardError => e
  log(:error) { self.exception ||= e.patch_full_message }
  raise
ensure
  rescued { self.tags_remap_csv_file = generate_tags_remap_csv }
end