mongo-db-utils 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ebe472c1c71790c06618838dac17a6da13db206
4
- data.tar.gz: e8a5fa1960f3a5c988818fdab24657f167adeaf6
3
+ metadata.gz: 157bf194faddd30339fdc925d52cc276b2768b53
4
+ data.tar.gz: 6c204abfa4cdc814c16522589168cde49fdcee3f
5
5
  SHA512:
6
- metadata.gz: 825c9dd5b70b4729afaea862888d5cd308c36ed9edf004dd60aa5e66e4b8f31d17fc3b1cffcfe2dc4761151dd60aa770208c104c0cd53996fea9c25d24338dd5
7
- data.tar.gz: ac3a00ea228736521b54495d38ad0bae15b1bda24993cf93bc94c08d8fc44e8ae0c7d9d65030e77d44de3f08095a88598df0d9766deabceb2851e9cc1e016878
6
+ metadata.gz: e686c970b7322483d8c531ed1c72adf0dd756cfbb2bf6a5dac191465a3ff7c3a7c42217e6079f16526842ecbe84a1a6664988e97c8b8baafb6641cf9d5cc29c3
7
+ data.tar.gz: 8b2962a8d9bb220375da19da1592f08e69a6b9b3945b8662f4a4a6cb996c6a18ec5fb8971f378a5220cb25c47a33b5341c11715c3f2392a4fde30477bfa3d7f2
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![Build Status](https://travis-ci.org/edeustace/mongo-db-utils.png)](https://travis-ci.org/edeustace/mongo-db-utils)
4
4
 
5
5
 
6
- ### !Current version 0.1.1 is in Beta - for a safer version use 0.0.9
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
- attr_accessor :username, :password, :name, :uri
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
- "#{@host_port}"
52
+ "#{host_port}"
65
53
  end
66
54
 
67
55
  def to_s_simple
68
- "#{@name} on #{@host_port} - (#{@username}:#{@password})"
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 = *@host_port.match(/(.*):(.*)/)
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
- @host_port.split(",")
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}/#{@host_port}"
136
+ "#{@set_name}/#{host_port}"
119
137
  end
120
138
 
121
139
  def to_s
122
- "[ReplicaSetDb-(#{to_host_s}/#{@name})]"
140
+ "[ReplicaSetDb-(#{to_host_s}/#{name})]"
123
141
  end
124
142
  end
125
143
 
@@ -77,6 +77,7 @@ module MongoDbUtils
77
77
  @options << o("-c", collection)
78
78
  @options << o("--file", file)
79
79
  @options << "--jsonArray" if opts[:json_array]
80
+ @options << "--drop" if opts[:drop]
80
81
  end
81
82
  end
82
83
 
@@ -1,4 +1,4 @@
1
1
  module MongoDbUtils
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  READY_FOR_USE = "(Beta version)"
4
4
  end
@@ -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.2
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-05 00:00:00.000000000 Z
11
+ date: 2013-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec