Class: BranchDb::Cleaner
- Inherits:
-
Object
- Object
- BranchDb::Cleaner
- Defined in:
- lib/branch_db/cleaner.rb
Constant Summary
Constants included from Logging
Constants included from PgUtils
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
-
#initialize(config, output: $stdout, input: $stdin, prefix: true, name: nil) ⇒ Cleaner
constructor
A new instance of Cleaner.
- #list_branch_databases ⇒ Object
- #prune(confirm: true) ⇒ Object
- #purge(confirm: true) ⇒ Object
Constructor Details
#initialize(config, output: $stdout, input: $stdin, prefix: true, name: nil) ⇒ Cleaner
Returns a new instance of Cleaner.
10 11 12 13 14 15 16 |
# File 'lib/branch_db/cleaner.rb', line 10 def initialize(config, output: $stdout, input: $stdin, prefix: true, name: nil) @config = config.is_a?(Hash) ? config : config.configuration_hash @output = output @input = input @prefix = prefix @name = name end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/branch_db/cleaner.rb', line 8 def config @config end |
#input ⇒ Object (readonly)
Returns the value of attribute input.
8 9 10 |
# File 'lib/branch_db/cleaner.rb', line 8 def input @input end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/branch_db/cleaner.rb', line 8 def name @name end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
8 9 10 |
# File 'lib/branch_db/cleaner.rb', line 8 def output @output end |
Instance Method Details
#list_branch_databases ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/branch_db/cleaner.rb', line 18 def list_branch_databases all_dbs = all_branch_databases if all_dbs.empty? log "No branch databases found#{db_label}." return [] end log "Found #{all_dbs.size} branch database(s)#{db_label}:" all_dbs.each { |db| log " - #{db}" } all_dbs end |
#prune(confirm: true) ⇒ Object
36 37 38 39 |
# File 'lib/branch_db/cleaner.rb', line 36 def prune(confirm: true) delete_databases(prunable_databases, empty_msg: "No stale branch databases to prune#{db_label}.", done_msg: "Prune complete#{db_label}!", confirm:) end |
#purge(confirm: true) ⇒ Object
31 32 33 34 |
# File 'lib/branch_db/cleaner.rb', line 31 def purge(confirm: true) delete_databases(deletable_databases, empty_msg: "No old branch databases to purge#{db_label}.", done_msg: "Purge complete#{db_label}!", confirm:) end |