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) ⇒ Migrator
constructor
A new instance of Migrator.
- #migrate_where_necessary ⇒ Object
Constructor Details
#initialize(repo: raise, shell: raise) ⇒ Migrator
Returns a new instance of Migrator.
4 5 6 7 |
# File 'lib/migrator.rb', line 4 def initialize(repo: raise, shell: raise) @shell = shell @repo = repo 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
16 17 18 19 |
# File 'lib/migrator.rb', line 16 def directories_to_migrate migrate_dirs = repo.files_changed.select {|f| f.match("/migrate/") }.map {|f| File.dirname(f) }.uniq migrate_dirs.select {|d| in_rack_application?(d) }; end |
#migrate_where_necessary ⇒ Object
9 10 11 12 13 14 |
# File 'lib/migrator.rb', line 9 def migrate_where_necessary 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 |