Sha256: 28203e4625607b0b6321f3721b1355b30a51ca95fc2c955f64353b830959b05d

Contents?: true

Size: 1.51 KB

Versions: 40

Compression:

Stored size: 1.51 KB

Contents

require_relative 'parsing/helpers'
require_relative 'parsing/classifications'
module Eco::API::UseCases::GraphQL::Samples::Location::Service
  module TreeDiff
    module Convertible
      # Helpers for transform
      module Parsing
        include Helpers
        include Classifications

        private

        # Custom callback to some required convertions to the input file
        # provided that it fits to the required input format.
        def transform_input_csv(csv)
          row_transform = custom_input_row_transform_block
          csv_transform = custom_input_csv_transform_block

          csv = csv_transform.call(csv) if csv_transform

          msg  = "Expecting Eco::CSV::Table (i.e. from  'custom_input_csv_transform')."
          msg << "Given: #{csv.class}"
          raise ArgumentError, msg unless csv.is_a?(Eco::CSV::Table)

          csv.each do |row|
            row_transform&.call(row)
            transform_classifications(row)
          end
          csv
        end

        # The user define block for row transformation
        def custom_input_row_transform_block
          return nil unless respond_to?(:custom_input_row_transform, true)
          method(:custom_input_row_transform)
        end

        # The user define block for row transformation
        def custom_input_csv_transform_block
          return nil unless respond_to?(:custom_input_csv_transform, true)
          method(:custom_input_csv_transform)
        end
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
eco-helpers-3.0.21 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb
eco-helpers-3.0.20 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb
eco-helpers-3.0.19 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb
eco-helpers-3.0.18 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb
eco-helpers-3.0.17 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb
eco-helpers-3.0.16 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb
eco-helpers-3.0.15 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb
eco-helpers-3.0.14 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb
eco-helpers-3.0.13 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb
eco-helpers-3.0.12 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb
eco-helpers-3.0.11 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb
eco-helpers-3.0.10 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb
eco-helpers-3.0.9 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb
eco-helpers-3.0.8 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb
eco-helpers-3.0.7 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb
eco-helpers-3.0.6 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb
eco-helpers-3.0.5 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb
eco-helpers-3.0.4 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb
eco-helpers-3.0.3 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb
eco-helpers-3.0.2 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible/parsing.rb