mongodb_clone 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ ## 0.1.0 - November 07, 2012
2
+
3
+ ### Improvements
4
+
5
+ * Drop database before restore
6
+
7
+ * Accept symbol in dump and restore.
8
+
9
+ ``` ruby
10
+ dump(:staging).restore(:development, :backup)
11
+ ```
12
+
13
+ ## 0.0.1 - October 31, 2012
14
+
15
+ Initial release.
@@ -1,3 +1,3 @@
1
1
  module MongodbClone
2
- VERSION = '0.0.1'
2
+ VERSION = '0.1.0'
3
3
  end
data/lib/mongodb_clone.rb CHANGED
@@ -11,7 +11,7 @@ module MongodbClone
11
11
  end
12
12
 
13
13
  def dump(environment = 'production', session = 'default')
14
- config = base_config[environment]['sessions'][session]
14
+ config = base_config[environment.to_s]['sessions'][session.to_s]
15
15
 
16
16
  params = {
17
17
  h: config['hosts'][0],
@@ -21,7 +21,7 @@ module MongodbClone
21
21
  o: "/tmp/#{ config['database'] }/#{ @id }"
22
22
  }
23
23
 
24
- a = params.collect { |key, value| "-#{ key } #{ value }" }.join(' ')
24
+ a = params.collect { |key, value| "-#{ key } #{ value }" if value }.compact.join(' ')
25
25
 
26
26
  command = "mongodump #{ a }"
27
27
 
@@ -33,7 +33,7 @@ module MongodbClone
33
33
  end
34
34
 
35
35
  def restore(environment = 'development', session = 'default')
36
- config = base_config[environment]['sessions'][session]
36
+ config = base_config[environment.to_s]['sessions'][session.to_s]
37
37
 
38
38
  params = {
39
39
  h: config['hosts'][0],
@@ -44,7 +44,7 @@ module MongodbClone
44
44
 
45
45
  a = params.collect { |key, value| "-#{ key } #{ value }" if value }.compact.join(' ')
46
46
 
47
- command = "mongorestore #{ a } #{ @path }"
47
+ command = "mongorestore --drop #{ a } #{ @path }"
48
48
 
49
49
  execute(command)
50
50
  end
@@ -12,6 +12,15 @@ describe MongodbClone::MongodbReplication do
12
12
 
13
13
  subject.dump
14
14
  end
15
+
16
+ context 'when dump the development database' do
17
+ it 'should dump the selected database' do
18
+ subject.id = '201210231843100200'
19
+ subject.should_receive(:execute).with('mongodump -h localhost:27017 -d mongodb_clone_development -o /tmp/mongodb_clone_development/201210231843100200')
20
+
21
+ subject.dump(:development)
22
+ end
23
+ end
15
24
  end
16
25
 
17
26
  describe '#restore' do
@@ -19,7 +28,7 @@ describe MongodbClone::MongodbReplication do
19
28
  subject.id = '201210231843100200'
20
29
  subject.path = '/tmp/mongodb_clone_production/201210231843100200/mongodb_clone_production'
21
30
  subject.should_receive(:execute).with('mongodump -h mongodb_clone.example.com:27017 -d mongodb_clone_production -u mongodb_clone -p 12345678 -o /tmp/mongodb_clone_production/201210231843100200')
22
- subject.should_receive(:execute).with('mongorestore -h localhost:27017 -d mongodb_clone_development /tmp/mongodb_clone_production/201210231843100200/mongodb_clone_production')
31
+ subject.should_receive(:execute).with('mongorestore --drop -h localhost:27017 -d mongodb_clone_development /tmp/mongodb_clone_production/201210231843100200/mongodb_clone_production')
23
32
 
24
33
  subject.dump.restore
25
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongodb_clone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-31 00:00:00.000000000 Z
12
+ date: 2012-11-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -52,6 +52,7 @@ extra_rdoc_files: []
52
52
  files:
53
53
  - .gitignore
54
54
  - .rspec
55
+ - CHANGELOG.md
55
56
  - Gemfile
56
57
  - LICENSE.txt
57
58
  - README.md
@@ -78,7 +79,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
78
79
  version: '0'
79
80
  segments:
80
81
  - 0
81
- hash: -3149178088274054404
82
+ hash: -2152426396032657639
82
83
  required_rubygems_version: !ruby/object:Gem::Requirement
83
84
  none: false
84
85
  requirements:
@@ -87,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
88
  version: '0'
88
89
  segments:
89
90
  - 0
90
- hash: -3149178088274054404
91
+ hash: -2152426396032657639
91
92
  requirements: []
92
93
  rubyforge_project:
93
94
  rubygems_version: 1.8.24