Sha256: d179c78a2bb64c86c3674b32684495f135f14a32c120462db63375f9bed3101f

Contents?: true

Size: 1.07 KB

Versions: 25

Compression:

Stored size: 1.07 KB

Contents

require_relative 'convertible/heading'
require_relative 'convertible/parsing'
require_relative 'convertible/inputable'
module Eco::API::UseCases::GraphQL::Samples::Location::Service
  module TreeDiff
    # Offers a way to convert the values and keys/headers
    # of the input csv file/rows
    module Convertible
      class << self
        def included(base)
          super(base)
          base.send :include, Inputable
        end
      end

      include Parsing
      include Heading

      private

      def input_csv
        @input_csv ||= Eco::CSV.read(input_file, encoding: input_encoding).then do |csv|
          next csv unless header_maps&.any?

          csv.transform_headers do |name|
            next name unless header_maps.key?(name)
            header_maps[name]
          end
        end.then do |csv|
          transform_input_csv(csv).tap do |res|
            next if res.is_a?(Eco::CSV::Table)
            raise ArgumentError, "Expecting and Eco::CSV::Table. Given: #{res.class}"
          end
        end
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
eco-helpers-3.0.6 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb
eco-helpers-3.0.5 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb
eco-helpers-3.0.4 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb
eco-helpers-3.0.3 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb
eco-helpers-3.0.2 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb
eco-helpers-3.0.1 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb
eco-helpers-3.0.0 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb
eco-helpers-2.7.25 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb
eco-helpers-2.7.24 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb
eco-helpers-2.7.23 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb
eco-helpers-2.7.22 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb
eco-helpers-2.7.21 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb
eco-helpers-2.7.20 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb
eco-helpers-2.7.19 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb
eco-helpers-2.7.18 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb
eco-helpers-2.7.17 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb
eco-helpers-2.7.16 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb
eco-helpers-2.7.15 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb
eco-helpers-2.7.14 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb
eco-helpers-2.7.13 lib/eco/api/usecases/graphql/samples/location/service/tree_diff/convertible.rb