Sha256: 7709d2ab6fdc305a94c43235ced51dbdb33d889f7d36e370d612aae7f5fdfbf8

Contents?: true

Size: 725 Bytes

Versions: 3

Compression:

Stored size: 725 Bytes

Contents

# encoding: UTF-8
module BusinessCatalyst
  module CSV

    class CatalogTransformer < Transformer
      def normalized_input
        # ensure at least a 1D array
        normalized_input = input.kind_of?(Array) ? input : [input]

        # now convert to 2D array
        unless normalized_input.first.kind_of?(Array)
          normalized_input = [normalized_input]
        end

        normalized_input
      end

      def transform
        normalized_input.map { |path|
          if path.any?
            sanitized_names = path.map { |name|
              BusinessCatalyst.sanitize_catalog_name(name)
            }
            "/" + sanitized_names.join("/")
          end
        }.join(";")
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
business_catalyst-0.1.2 lib/business_catalyst/csv/transformers/catalog_transformer.rb
business_catalyst-0.1.1 lib/business_catalyst/csv/transformers/catalog_transformer.rb
business_catalyst-0.1.0 lib/business_catalyst/csv/transformers/catalog_transformer.rb