Class: Veksel::Commands::Clean
- Inherits:
-
Object
- Object
- Veksel::Commands::Clean
- Defined in:
- lib/veksel/commands/clean.rb
Instance Method Summary collapse
-
#initialize(db, dry_run: false) ⇒ Clean
constructor
A new instance of Clean.
- #perform ⇒ Object
Constructor Details
#initialize(db, dry_run: false) ⇒ Clean
Returns a new instance of Clean.
4 5 6 7 |
# File 'lib/veksel/commands/clean.rb', line 4 def initialize(db, dry_run: false) @adapter = Veksel.adapter_for(db.configuration_hash) @dry_run = dry_run end |
Instance Method Details
#perform ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/veksel/commands/clean.rb', line 9 def perform all_databases = @adapter.forked_databases active_branches = Veksel.active_branches stale_databases = all_databases.filter do |database| active_branches.none? { |branch| database.branch == branch } end stale_databases.each do |database| @adapter.drop_database(database.name, dry_run: @dry_run) end end |