mongo-util 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mongo/util.rb +13 -5
- data/lib/mongo/util/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f94f3651f20125bfe48640a9a4f98574701ebac4
|
4
|
+
data.tar.gz: 154ffce121464f14a5d58bae6fb392eb1dacb9ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 887e1f5f18150197502810755e8c36bacad29234a174270b3c614e04f9b9318a838a512338492d78c8af19badf0fbbe132afae969f12f328e3d8201a7bc149cb
|
7
|
+
data.tar.gz: bc973d8b57bb5b5e6e08b168ec1f7ff7979a18c63b3ded1715cae2fa2ac64b18b0b0c07793eb30e081bc847bea28c8034edc5f94d903f9944bafdb09216e98d4
|
data/lib/mongo/util.rb
CHANGED
@@ -37,7 +37,7 @@ module Mongo
|
|
37
37
|
# Append auth, if neccessary
|
38
38
|
cmd += Mongo::Util.authentication(@from)
|
39
39
|
|
40
|
-
|
40
|
+
self.exec(cmd)
|
41
41
|
end
|
42
42
|
|
43
43
|
# Restore contents of @dump_dr to @to{database}
|
@@ -50,7 +50,7 @@ module Mongo
|
|
50
50
|
# Append auth, if neccessary
|
51
51
|
cmd += Mongo::Util.authentication(@to)
|
52
52
|
|
53
|
-
|
53
|
+
self.exec(cmd)
|
54
54
|
end
|
55
55
|
|
56
56
|
# Removes all items / items which match options[:query]
|
@@ -65,7 +65,7 @@ module Mongo
|
|
65
65
|
cmd += Mongo::Util.authentication(@to)
|
66
66
|
cmd += " --eval 'db.#{collection}.remove(#{options[:query] ? options[:query].to_json : ""});'"
|
67
67
|
|
68
|
-
|
68
|
+
self.exec(cmd)
|
69
69
|
end
|
70
70
|
|
71
71
|
# Returns Array of all collection-names of @to{database}
|
@@ -78,12 +78,20 @@ module Mongo
|
|
78
78
|
# Append auth, if neccessary
|
79
79
|
cmd += Mongo::Util.authentication(@to)
|
80
80
|
|
81
|
-
|
81
|
+
collections = self.exec(cmd, return_output: true).rstrip.split(',')
|
82
|
+
# If we have a '{' in the output, Mongo has thrown an error
|
83
|
+
collections.each {|col| raise "Error while fetching collections: '#{collections.join()}'" if col.include?('{')}
|
82
84
|
end
|
83
85
|
|
84
86
|
# Deletes @dump_dir
|
85
87
|
def clean
|
86
|
-
|
88
|
+
self.exec("rm -rf #{@dump_dir}")
|
89
|
+
end
|
90
|
+
|
91
|
+
def exec(cmd, options={})
|
92
|
+
# Print commands for debugging
|
93
|
+
print "Executing: '#{cmd}'\n"
|
94
|
+
options[:return_output] ? `#{cmd}` : system(cmd)
|
87
95
|
end
|
88
96
|
|
89
97
|
# Enable auth if we set db_config contains user & password
|
data/lib/mongo/util/version.rb
CHANGED