Module: MigrationReporter
- Defined in:
- lib/migration_reporter.rb,
lib/migration_reporter/railtie.rb,
lib/migration_reporter/version.rb
Defined Under Namespace
Classes: Railtie
Constant Summary collapse
- VERSION =
"0.0.2"
Class Method Summary collapse
- .migrated_versions ⇒ Object
- .report_migration(url, migration, contents) ⇒ Object
- .report_migrations(url, limit = nil) ⇒ Object
Class Method Details
.migrated_versions ⇒ Object
30 31 32 |
# File 'lib/migration_reporter.rb', line 30 def migrated_versions @all_versions ||= ActiveRecord::Migrator.get_all_versions end |
.report_migration(url, migration, contents) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# 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) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# 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 |