Sha256: 4c1a1348f31e0ea392ac72405bf412f27c461e30f6115b4e3f149ecd5655f4c1

Contents?: true

Size: 1.11 KB

Versions: 5

Compression:

Stored size: 1.11 KB

Contents

module Milkshake
  module RailsExtentions
    module Migrator
      
      def self.included(base)
        base.module_eval do
          alias_method :migrations_without_milkshake, :migrations
          alias_method :migrations, :migrations_with_milkshake
        end
      end
      
      def migrations_with_milkshake
        return @migrations if @migrations
        all_migrations = []
        
        Milkshake.environment.gemspecs.each do |gemspec|
          migrations_path_for_gemspec = File.join(gemspec.full_gem_path, 'db', 'migrate')
          if File.directory?(migrations_path_for_gemspec)
            original_migrations_path    = @migrations_path
            @migrations                 = nil
            @migrations_path            = migrations_path_for_gemspec
            all_migrations.concat(migrations_without_milkshake)
            @migrations_path = original_migrations_path
          end
        end
        
        all_migrations = all_migrations.sort_by(&:version)
        down? ? all_migrations.reverse : all_migrations
        
        @migrations = all_migrations
      end
      
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
milkshake-0.1.3 lib/milkshake/rails_extentions/migrations.rb
milkshake-0.1.2 lib/milkshake/rails_extentions/migrations.rb
milkshake-0.1.1 lib/milkshake/rails_extentions/migrations.rb
milkshake-0.0.2 lib/milkshake/rails_extentions/migrations.rb
milkshake-0.0.1 lib/milkshake/rails_extentions/migrations.rb