Class: Couchup::Commands::Compact

Inherits:
Object
  • Object
show all
Includes:
Couchup::CommandExtensions
Defined in:
lib/couchup/commands/compact.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Couchup::CommandExtensions

included, #needs_db!

Class Method Details

.describeObject



20
21
22
23
24
25
# File 'lib/couchup/commands/compact.rb', line 20

def self.describe
  {:description => "Compacts the current database or specified database. To preserve space.",
  :usage => "compact [db_name]",
  :examples =>[ "compact", "compact 'Riders/winners"]
  }
end

Instance Method Details

#run(*params) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/couchup/commands/compact.rb', line 5

def run(*params)
  db = params.shift
  if(db.nil?)
    needs_db!
    instance = Couchup.database
  else
    instance = Couchup.new_database(db)
  end
  if instance.nil?
    ap "Database not found."
  else
    instance.compact!
  end
  
end