module MigrationReporter
Constants
- VERSION
Public Class Methods
migrated_versions()
click to toggle source
# File lib/migration_reporter.rb, line 30 def migrated_versions @all_versions ||= ActiveRecord::Migrator.get_all_versions end
report_migration(url, migration, contents)
click to toggle source
# File lib/migration_reporter.rb, line 17 def report_migration(url, migration, contents) headers = { 'Content-Type' => 'application/json' } body = { :name => migration.name, :version => migration.version, :filename => migration.filename, :status => migrated_versions.include?(migration.version) ? "up" : "down", :contents => contents }.to_json HTTParty.post(url, :headers => headers, :body => body) end
report_migrations(url, limit=nil)
click to toggle source
# File lib/migration_reporter.rb, line 6 def report_migrations(url, limit=nil) paths = ActiveRecord::Migrator.migrations_paths migrations = ActiveRecord::Migrator.migrations(paths) migrations = migrations.last(limit.to_i) if limit migrations.each do |migration| contents = File.read(migration.filename) report_migration(url, migration, contents) end end