Class: Migrator
- Inherits:
-
Object
- Object
- Migrator
- Defined in:
- lib/migrator.rb
Instance Attribute Summary collapse
-
#repo ⇒ Object
Returns the value of attribute repo.
-
#shell ⇒ Object
Returns the value of attribute shell.
Instance Method Summary collapse
- #directories_to_migrate ⇒ Object
-
#initialize(repo: raise, shell: raise, migrate_engines: raise) ⇒ Migrator
constructor
hack: move engines flag into another object that decides.
- #migrate_where_necessary ⇒ Object
Constructor Details
#initialize(repo: raise, shell: raise, migrate_engines: raise) ⇒ Migrator
hack: move engines flag into another object that decides
6 7 8 9 10 |
# File 'lib/migrator.rb', line 6 def initialize(repo: raise, shell: raise, migrate_engines: raise) @shell = shell @repo = repo @migrate_engines = migrate_engines end |
Instance Attribute Details
#repo ⇒ Object
Returns the value of attribute repo.
2 3 4 |
# File 'lib/migrator.rb', line 2 def repo @repo end |
#shell ⇒ Object
Returns the value of attribute shell.
2 3 4 |
# File 'lib/migrator.rb', line 2 def shell @shell end |
Instance Method Details
#directories_to_migrate ⇒ Object
20 21 22 23 |
# File 'lib/migrator.rb', line 20 def directories_to_migrate migrate_dirs = repo.files_changed.select {|f| f.match("/migrate/") }.map {|f| File.dirname(f) }.map {|dir| dir.gsub(/\/db\/migrate$/, '')}.uniq migrate_dirs.select {|d| in_rack_application?(d) }; end |
#migrate_where_necessary ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/migrator.rb', line 12 def migrate_where_necessary shell.notify "\nMigrating:" directories_to_migrate.each do |dir| shell.run "bundle exec rake db:migrate", dir: dir shell.run "RAILS_ENV=test bundle exec rake db:migrate", dir: dir end end |