Module: MongoSync
- Defined in:
- lib/mongo_sync.rb,
lib/mongo_sync/config.rb,
lib/mongo_sync/railtie.rb,
lib/mongo_sync/version.rb,
lib/rails/generators/mongo_sync/config/config_generator.rb
Defined Under Namespace
Modules: Configuration, Generators
Classes: Railtie, SystemCommandFailure
Constant Summary
collapse
- VERSION =
"0.1.2"
Class Method Summary
collapse
Class Method Details
.pull(config = nil) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/mongo_sync.rb', line 6
def self.pull(config = nil)
configs = MongoSync::Configuration.parse(config)
tmpdir = new_tmp_dir
puts "Dumping Remote DB to #{tmpdir}..."
system_run "mongodump \
-h #{configs['remote']['host']['url']}:#{configs['remote']['host']['port']} \
-d #{configs['remote']['db']} \
-u #{configs['remote']['access']['username']} \
-p #{configs['remote']['access']['password']} \
-o #{tmpdir} > /dev/null"
puts "Overwriting Local DB..."
system_run "mongorestore \
-d #{configs['local']['db']} \
#{tmpdir}/#{configs['remote']['db']} \
--drop > /dev/null"
clean_up(tmpdir)
done_msg
end
|
.push(config = nil) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/mongo_sync.rb', line 28
def self.push(config = nil)
configs = MongoSync::Configuration.parse(config)
tmpdir = new_tmp_dir
puts "Dumping Local DB to #{tmpdir}..."
system_run "mongodump \
-d #{configs['local']['db']} \
-o #{tmpdir} > /dev/null"
puts "Overwriting Remote DB with Dump..."
system_run "mongorestore \
-h #{configs['remote']['host']['url']}:#{configs['remote']['host']['port']} \
-d #{configs['remote']['db']} \
-u #{configs['remote']['access']['username']} \
-p #{configs['remote']['access']['password']} \
#{tmpdir}/#{configs['remote']['db']} \
--drop > /dev/null"
clean_up(tmpdir)
done_msg
end
|