Class: DBGet::Controller
- Inherits:
-
Object
- Object
- DBGet::Controller
- Defined in:
- lib/dbget/controller.rb
Class Method Summary collapse
Instance Method Summary collapse
- #finalize_dump ⇒ Object
-
#initialize(options) ⇒ Controller
constructor
A new instance of Controller.
- #load_dump ⇒ Object
- #run! ⇒ Object
- #status_report ⇒ Object
- #user_allowed? ⇒ Boolean
Constructor Details
#initialize(options) ⇒ Controller
Returns a new instance of Controller.
7 8 9 10 |
# File 'lib/dbget/controller.rb', line 7 def initialize() @dump = DBGet::Dump.new() @config = DBGet::Config.instance end |
Class Method Details
.boot(options) ⇒ Object
3 4 5 |
# File 'lib/dbget/controller.rb', line 3 def self.boot() self.new().run! end |
Instance Method Details
#finalize_dump ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/dbget/controller.rb', line 27 def finalize_dump if @dump.in_cache? @dump.cache_file = "Found cached file, no need to decrypt." else = "Decrypting #{@dump.encrypted_dump}..." end Utils.say_with_time do @dump.decrypted_dump = @dump.decrypt_dump end @dump.set_final_db end |
#load_dump ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/dbget/controller.rb', line 41 def load_dump Utils.say_with_time "Dumping, this may take a while" do case @dump.db_type when 'mysql' DBGet::Loaders::MySql.boot(@dump, @config).load! when 'mongo' DBGet::Loaders::Mongo.boot(@dump, @config).load! else raise "Dump is not supported!" end end end |
#run! ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/dbget/controller.rb', line 12 def run! user_allowed? @dump.prepare finalize_dump load_dump status_report end |
#status_report ⇒ Object
55 56 57 58 59 |
# File 'lib/dbget/controller.rb', line 55 def status_report Utils.say "Dump for #{@dump.db} done!" Utils.say "Source: #{@dump.decrypted_dump}" Utils.say "Target: #{@dump.target_db}" end |
#user_allowed? ⇒ Boolean
20 21 22 23 24 25 |
# File 'lib/dbget/controller.rb', line 20 def user_allowed? unless @config['users'].include?(@dump.user) raise "User not allowed to dump" exit 1 end end |