mongo-db-utils 0.1.2 → 0.1.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/README.md +7 -1
- data/lib/mongo-db-utils/models/db.rb +41 -23
- data/lib/mongo-db-utils/tools/commands.rb +1 -0
- data/lib/mongo-db-utils/version.rb +1 -1
- data/spec/models/db_spec.rb +0 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 157bf194faddd30339fdc925d52cc276b2768b53
|
4
|
+
data.tar.gz: 6c204abfa4cdc814c16522589168cde49fdcee3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e686c970b7322483d8c531ed1c72adf0dd756cfbb2bf6a5dac191465a3ff7c3a7c42217e6079f16526842ecbe84a1a6664988e97c8b8baafb6641cf9d5cc29c3
|
7
|
+
data.tar.gz: 8b2962a8d9bb220375da19da1592f08e69a6b9b3945b8662f4a4a6cb996c6a18ec5fb8971f378a5220cb25c47a33b5341c11715c3f2392a4fde30477bfa3d7f2
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
[](https://travis-ci.org/edeustace/mongo-db-utils)
|
4
4
|
|
5
5
|
|
6
|
-
### !Current version 0.1.
|
6
|
+
### !Current version 0.1.2 is in Beta - for a safer version use 0.0.9
|
7
7
|
|
8
8
|
A little gem that simplifies backing up and copying your mongo dbs.
|
9
9
|
|
@@ -55,6 +55,12 @@ When it does backups it stores them in ````~/.mongo-db-utils/backups/````. The n
|
|
55
55
|
|
56
56
|
|
57
57
|
## Release Notes
|
58
|
+
* 0.1.4 - Upcoming
|
59
|
+
- Changed db model so that it only persists the uri (smaller yml files)
|
60
|
+
|
61
|
+
* 0.1.3 - BETA
|
62
|
+
- Added :drop flag for Import tool
|
63
|
+
|
58
64
|
* 0.1.2 - BETA
|
59
65
|
- Added 'host' and 'port' getters to Db AND 'hosts' getter to ReplicaSetDb
|
60
66
|
|
@@ -24,26 +24,12 @@ module MongoDbUtils
|
|
24
24
|
URI_NO_USER = /mongodb:\/\/(.*)\/(.*$)/
|
25
25
|
URI_USER = /mongodb:\/\/(.*):(.*)@(.*)\/(.*$)/
|
26
26
|
|
27
|
-
|
27
|
+
attr_reader :username, :password, :name, :uri
|
28
28
|
|
29
29
|
def initialize(uri)
|
30
|
-
user,pwd,host_port,db = nil
|
31
|
-
|
32
|
-
if( uri.match(URI_USER))
|
33
|
-
match, user, pwd, host_port, name = *uri.match(URI_USER)
|
34
|
-
elsif(uri.match(URI_NO_USER))
|
35
|
-
match, host_port, name = *uri.match(URI_NO_USER)
|
36
|
-
user = ""
|
37
|
-
pwd = ""
|
38
|
-
end
|
39
|
-
|
40
|
-
raise "can't parse uri" if( host_port.nil? || name.nil? )
|
41
|
-
|
42
|
-
@host_port = host_port
|
43
|
-
@name = name
|
44
|
-
@username = user
|
45
|
-
@password = pwd
|
46
30
|
@uri = uri
|
31
|
+
|
32
|
+
host_port
|
47
33
|
end
|
48
34
|
|
49
35
|
def authentication_required?
|
@@ -58,14 +44,16 @@ module MongoDbUtils
|
|
58
44
|
host_and_port[:port]
|
59
45
|
end
|
60
46
|
|
47
|
+
|
48
|
+
|
61
49
|
# Return the host string in a format that is compatable with mongo binary tools
|
62
50
|
# See: http://docs.mongodb.org/manual/reference/program/mongodump/#cmdoption-mongodump--host
|
63
51
|
def to_host_s
|
64
|
-
"#{
|
52
|
+
"#{host_port}"
|
65
53
|
end
|
66
54
|
|
67
55
|
def to_s_simple
|
68
|
-
"#{
|
56
|
+
"#{name} on #{host_port} - (#{username}:#{password})"
|
69
57
|
end
|
70
58
|
|
71
59
|
def to_s
|
@@ -76,14 +64,44 @@ module MongoDbUtils
|
|
76
64
|
self.to_s <=> other.to_s
|
77
65
|
end
|
78
66
|
|
67
|
+
def host_port; bits[:host_port]; end
|
68
|
+
def name; bits[:name]; end
|
69
|
+
def username; bits[:username]; end
|
70
|
+
def password; bits[:password]; end
|
71
|
+
|
79
72
|
private
|
73
|
+
|
74
|
+
# extract the bits out of the uri
|
75
|
+
# @return a hash of the bits
|
76
|
+
def bits
|
77
|
+
user,pwd,host_port,db = nil
|
78
|
+
|
79
|
+
if( uri.match(URI_USER))
|
80
|
+
match, user, pwd, host_port, name = *uri.match(URI_USER)
|
81
|
+
elsif(uri.match(URI_NO_USER))
|
82
|
+
match, host_port, name = *uri.match(URI_NO_USER)
|
83
|
+
user = ""
|
84
|
+
pwd = ""
|
85
|
+
end
|
86
|
+
|
87
|
+
raise "can't parse uri" if( host_port.nil? || name.nil? )
|
88
|
+
|
89
|
+
{
|
90
|
+
:host_port => host_port,
|
91
|
+
:name => name,
|
92
|
+
:username => user,
|
93
|
+
:password => pwd
|
94
|
+
}
|
95
|
+
|
96
|
+
end
|
97
|
+
|
80
98
|
def has?(s)
|
81
99
|
!s.nil? && !s.empty?
|
82
100
|
end
|
83
101
|
|
84
102
|
|
85
103
|
def host_and_port
|
86
|
-
match, host,port =
|
104
|
+
match, host,port = *host_port.match(/(.*):(.*)/)
|
87
105
|
{ :host => host, :port => port }
|
88
106
|
end
|
89
107
|
end
|
@@ -100,7 +118,7 @@ module MongoDbUtils
|
|
100
118
|
|
101
119
|
# Return an array of host:port strings
|
102
120
|
def hosts
|
103
|
-
|
121
|
+
host_port.split(",")
|
104
122
|
end
|
105
123
|
|
106
124
|
# Block usage of this method from the super
|
@@ -115,11 +133,11 @@ module MongoDbUtils
|
|
115
133
|
|
116
134
|
# Note: we override this to provide a replica set format
|
117
135
|
def to_host_s
|
118
|
-
"#{@set_name}/#{
|
136
|
+
"#{@set_name}/#{host_port}"
|
119
137
|
end
|
120
138
|
|
121
139
|
def to_s
|
122
|
-
"[ReplicaSetDb-(#{to_host_s}/#{
|
140
|
+
"[ReplicaSetDb-(#{to_host_s}/#{name})]"
|
123
141
|
end
|
124
142
|
end
|
125
143
|
|
data/spec/models/db_spec.rb
CHANGED
@@ -16,7 +16,6 @@ describe MongoDbUtils::Model::Db do
|
|
16
16
|
db.host.should == "localhost"
|
17
17
|
db.port.should == "27017"
|
18
18
|
end
|
19
|
-
|
20
19
|
it "should construct - no user/pass" do
|
21
20
|
db = Db.new("mongodb://localhost:27017/db")
|
22
21
|
db.to_host_s.should == "localhost:27017"
|
@@ -58,5 +57,4 @@ describe MongoDbUtils::Model::Db do
|
|
58
57
|
db.password.should == "pass"
|
59
58
|
db.to_host_s.should == "rs-ds063347/ds063347-a0.mongolab.com:63347,ds063347-a1.mongolab.com:63347"
|
60
59
|
end
|
61
|
-
|
62
60
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongo-db-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- edeustace
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|