Sha256: a6551d4efabea983d814d5030acd5b84eb387c718801e51dd11919db238249c5

Contents?: true

Size: 1 KB

Versions: 26

Compression:

Stored size: 1 KB

Contents

# frozen_string_literal: true

module DataMigrate
  ##
  # Provides the capability to write the current data schema version to
  # the data_schema file Based on ActiveRecord::SchemaDumper
  class SchemaDumper
    private_class_method :new

    class << self
      def dump(connection = ActiveRecord::Base.connection, stream = STDOUT)
        new(connection).dump(stream)
        stream
      end
    end

    def dump(stream)
      define_params = @version ? "version: #{@version}" : ""

      if stream.respond_to?(:external_encoding) && stream.external_encoding
        stream.puts "# encoding: #{stream.external_encoding.name}"
      end

      stream.puts "DataMigrate::Data.define(#{define_params})"

      stream
    end

    private

    def initialize(connection)
      @connection = connection
      all_versions =  DataSchemaMigration.normalized_versions

      @version = begin
                    all_versions.max
                  rescue StandardError
                    0
                  end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
data_migrate-7.0.1 lib/data_migrate/schema_dumper.rb
data_migrate-7.0.0 lib/data_migrate/schema_dumper.rb
data_migrate-6.8.0 lib/data_migrate/schema_dumper.rb
data_migrate-6.7.0 lib/data_migrate/schema_dumper.rb
data_migrate-6.6.2 lib/data_migrate/schema_dumper.rb
data_migrate-6.6.0 lib/data_migrate/schema_dumper.rb
data_migrate-6.5.0 lib/data_migrate/schema_dumper.rb
data_migrate-6.4.0 lib/data_migrate/schema_dumper.rb
data_migrate-6.3.0 lib/data_migrate/schema_dumper.rb
data_migrate-6.2.0 lib/data_migrate/schema_dumper.rb
data_migrate-6.1.0 lib/data_migrate/schema_dumper.rb
data_migrate-6.0.7 lib/data_migrate/schema_dumper.rb
data_migrate-6.0.6 lib/data_migrate/schema_dumper.rb
data_migrate-6.0.5 lib/data_migrate/schema_dumper.rb
data_migrate-6.0.4.beta lib/data_migrate/schema_dumper.rb
data_migrate-6.0.3.beta lib/data_migrate/schema_dumper.rb
data_migrate-6.0.1.beta lib/data_migrate/schema_dumper.rb
data_migrate-6.0.0.beta lib/data_migrate/schema_dumper.rb
data_migrate-5.3.2 lib/data_migrate/schema_dumper.rb
data_migrate-5.3.1 lib/data_migrate/schema_dumper.rb