Sha256: 9e357ba916e39959fd02dd34625aaea5554b8f0b0837de755bd51751b63878ba

Contents?: true

Size: 888 Bytes

Versions: 8

Compression:

Stored size: 888 Bytes

Contents

module Cardio
  class Migration
    class Import
      # executes the card import
      class Merger
        def initialize data_path, opts={}
          @data_path = data_path
          @output_path = File.join data_path, "unmerged"
          @data = ImportData.load @data_path, opts
        end

        def merge
          puts("nothing to merge") && return if @data.empty?

          Card::Mailer.perform_deliveries = false
          Card::Auth.as_bot do
            Card.merge_list @data, output_file: @output_path
          end

          update_import_data
        end

        private

        def update_import_data
          update_time = Time.zone.now.to_s
          ImportData.update(@data_path) do |import_data|
            @data.each do |card_data|
              import_data.merged card_data, update_time
            end
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
card-1.101.7 lib/cardio/migration/import/merger.rb
card-1.101.6 lib/cardio/migration/import/merger.rb
card-1.101.5 lib/cardio/migration/import/merger.rb
card-1.101.4 lib/cardio/migration/import/merger.rb
card-1.101.3 lib/cardio/migration/import/merger.rb
card-1.101.2 lib/cardio/migration/import/merger.rb
card-1.101.1 lib/cardio/migration/import/merger.rb
card-1.101.0 lib/cardio/migration/import/merger.rb