Sha256: 7209f07abb2a595847d96594aa7faa588b3552113f42409b63e1853ffc1e49c2

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

module Eco::API::UseCases::GraphQL::Samples
  module Location::Service
    # Service to transform (CONVERT or PARSE) an input locations structure into a list
    # of hash nodes.
    # @note it can have multiple usages
    #   1. Live locations tree structure into a nodes list file (nodeId, parendId, name,...)
    #   2. A locations tree built from an input csv into a nodes list hash
    #   3. Change the keys of the hash nodes
    #   4. Parse the values
    # @note this use case can be inherited from to provision **parsed** input to other
    #   use cases.
    # @note it allows to define `custom_node_parser` and `custom_node_parser_after`
    #   methods (param: `node_hash`), to allow custom parsing.
    #   - It has a generic parser that validates the `classifications`
    # As this format allows to easily compare what has changed in the locations structure.
    # @example
    #     class Custom::UseCase::TagtreeToList < Eco::API::UseCases::GraphQL::Samples::Location
    #       name 'tagtree-to-list'
    #       type :other
    #
    #       include Eco::API::UseCases::GraphQL::Samples::Location::Service::TreeToList
    #
    #     end
    module TreeToList
      include Eco::API::UseCases::GraphQL::Samples::Location::DSL

      require_relative 'tree_to_list/output'
      require_relative 'tree_to_list/converter'

      include Output
      include Converter

      def process
        as_nodes_json(input_tagtree).tap do |list|
          next generate_live_nodes_file(list) unless list.empty?
          log(:error) { "There are no location nodes!" }
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
eco-helpers-2.7.2 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list.rb
eco-helpers-2.7.1 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list.rb
eco-helpers-2.7.0 lib/eco/api/usecases/graphql/samples/location/service/tree_to_list.rb