gomon 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.
- data/.travis.yml +1 -0
- data/Gemfile.lock +7 -1
- data/README.md +8 -4
- data/gomon.gemspec +1 -0
- data/lib/gomon/base.rb +5 -1
- data/lib/gomon/options.rb +2 -0
- data/lib/gomon/uri.rb +5 -5
- data/lib/gomon/version.rb +1 -1
- data/spec/base_spec.rb +3 -3
- data/spec/dump_spec.rb +4 -2
- data/spec/options_spec.rb +2 -2
- data/spec/restore_spec.rb +4 -2
- metadata +17 -1
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gomon (0.0.
|
4
|
+
gomon (0.0.3)
|
5
|
+
activesupport
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: http://rubygems.org/
|
8
9
|
specs:
|
10
|
+
activesupport (3.2.11)
|
11
|
+
i18n (~> 0.6)
|
12
|
+
multi_json (~> 1.0)
|
9
13
|
diff-lcs (1.1.3)
|
14
|
+
i18n (0.6.1)
|
15
|
+
multi_json (1.5.0)
|
10
16
|
rake (10.0.3)
|
11
17
|
rspec (2.12.0)
|
12
18
|
rspec-core (~> 2.12.0)
|
data/README.md
CHANGED
@@ -6,14 +6,17 @@ Ruby wrappers around mongodb cli tools.
|
|
6
6
|
|
7
7
|
[](https://travis-ci.org/novelys/gomon)
|
8
8
|
|
9
|
-
This gem depends on no other gems. Ruby 1.9
|
9
|
+
This gem depends on no other gems. Ruby 1.8 & 1.9.
|
10
|
+
|
10
11
|
It assumes the presence of `mongorestore` and `mongodump` commands.
|
11
|
-
It was built around the latest tools at the moment of this writing, meaning version 2.2.2.
|
12
|
+
It was built around the latest mongodb tools at the moment of this writing, meaning version 2.2.2.
|
13
|
+
Therefore, it is possible that arguments format and/or names have changed from previous versions, making them potentially not compatible with Gomon.
|
12
14
|
|
13
15
|
## Installation
|
14
16
|
|
15
|
-
Directly : `gem install gomon
|
16
|
-
|
17
|
+
Directly : `gem install gomon`
|
18
|
+
|
19
|
+
Gemfile : `gem 'gomon'`
|
17
20
|
|
18
21
|
## Usage
|
19
22
|
|
@@ -59,5 +62,6 @@ If you want to set options once the object is already created, you can use `add_
|
|
59
62
|
|
60
63
|
## Changelog
|
61
64
|
|
65
|
+
* `0.3`: Ruby 1.8 support
|
62
66
|
* `0.2`: Test coverage.
|
63
67
|
* `0.1`: First version. Provices basic functionnality for `Gomon::Dump` & `Gomon::Restore`
|
data/gomon.gemspec
CHANGED
data/lib/gomon/base.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'active_support/ordered_hash'
|
1
2
|
require 'gomon/options'
|
2
3
|
require 'gomon/uri'
|
3
4
|
|
@@ -10,7 +11,10 @@ module Gomon
|
|
10
11
|
@tool = 'mongodump'
|
11
12
|
|
12
13
|
# Default options
|
13
|
-
@options =
|
14
|
+
@options = ActiveSupport::OrderedHash.new
|
15
|
+
@options[:host] = 'localhost'
|
16
|
+
@options[:port] = '27017'
|
17
|
+
|
14
18
|
@singular_options = opts.delete(:other)
|
15
19
|
|
16
20
|
# Extract uri into options
|
data/lib/gomon/options.rb
CHANGED
data/lib/gomon/uri.rb
CHANGED
@@ -5,11 +5,11 @@ module Gomon
|
|
5
5
|
matches = uri.match /mongodb:\/\/([^:]*):([^@]*)@([^:]*):(\d*)\/(.*)/i
|
6
6
|
|
7
7
|
{
|
8
|
-
username
|
9
|
-
password
|
10
|
-
host
|
11
|
-
port
|
12
|
-
db
|
8
|
+
:username => matches[1],
|
9
|
+
:password => matches[2],
|
10
|
+
:host => matches[3],
|
11
|
+
:port => matches[4],
|
12
|
+
:db => matches[5]
|
13
13
|
}
|
14
14
|
end
|
15
15
|
end
|
data/lib/gomon/version.rb
CHANGED
data/spec/base_spec.rb
CHANGED
@@ -15,7 +15,7 @@ describe "Base" do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
context 'initialized with uri' do
|
18
|
-
subject { Gomon::Base.new uri
|
18
|
+
subject { Gomon::Base.new :uri => "mongodb://john:wayne@marlon.bran.do:23042/dark_side_of_the_moon" }
|
19
19
|
let(:options) { subject.instance_variable_get :@options }
|
20
20
|
|
21
21
|
it 'should not have uri' do
|
@@ -44,7 +44,7 @@ describe "Base" do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
context 'initialized with other' do
|
47
|
-
subject { Gomon::Base.new other
|
47
|
+
subject { Gomon::Base.new :other => "--first --third" }
|
48
48
|
let(:options) { subject.instance_variable_get :@singular_options }
|
49
49
|
|
50
50
|
it 'should have singular options' do
|
@@ -53,7 +53,7 @@ describe "Base" do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
context 'initialized with options' do
|
56
|
-
subject { Gomon::Base.new host
|
56
|
+
subject { Gomon::Base.new :host => 'john', :username => 'wayne', :out => 'side' }
|
57
57
|
let(:options) { subject.instance_variable_get :@options }
|
58
58
|
|
59
59
|
it 'should have options set' do
|
data/spec/dump_spec.rb
CHANGED
@@ -2,15 +2,17 @@ require 'gomon/dump'
|
|
2
2
|
|
3
3
|
describe "Dump" do
|
4
4
|
|
5
|
-
subject { Gomon::Dump.new username
|
5
|
+
subject { Gomon::Dump.new :username => 'john', :password => 'mcclane', :db => 'die_hard'}
|
6
6
|
let(:tool) { subject.instance_variable_get :@tool }
|
7
|
+
let(:options) { subject.instance_variable_get :@options }
|
7
8
|
|
8
9
|
it 'should have a toolname' do
|
9
10
|
expect(tool).to eq 'mongodump'
|
10
11
|
end
|
11
12
|
|
12
13
|
it 'should have a command string' do
|
13
|
-
cmd = "mongodump
|
14
|
+
cmd = "mongodump"
|
15
|
+
options.each { |k, v| cmd += " --#{k} '#{v}'" }
|
14
16
|
expect(subject.cmd_string).to eq cmd
|
15
17
|
end
|
16
18
|
end
|
data/spec/options_spec.rb
CHANGED
@@ -19,7 +19,7 @@ describe "Options" do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'should add several options' do
|
22
|
-
subject.add_options key1
|
22
|
+
subject.add_options :key1 => 'value1', :key2 => 'value2'
|
23
23
|
expect(options[:key1]).to eq 'value1'
|
24
24
|
expect(options[:key2]).to eq 'value2'
|
25
25
|
end
|
@@ -36,7 +36,7 @@ describe "Options" do
|
|
36
36
|
end
|
37
37
|
|
38
38
|
it 'can merge options into a string' do
|
39
|
-
subject.add_options key1
|
39
|
+
subject.add_options :key1 => 'value1', :key2 => 'value2'
|
40
40
|
expect(subject.cli_options).to eq "--key1 'value1' --key2 'value2' --first --second"
|
41
41
|
end
|
42
42
|
end
|
data/spec/restore_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'gomon/restore'
|
|
2
2
|
|
3
3
|
describe "Restore" do
|
4
4
|
|
5
|
-
subject { Gomon::Restore.new path
|
5
|
+
subject { Gomon::Restore.new :path => 'dump/dir', :db => 'die_hard', :username => 'john' }
|
6
6
|
let(:tool) { subject.instance_variable_get :@tool }
|
7
7
|
let(:path) { subject.instance_variable_get :@path }
|
8
8
|
let(:options) { subject.instance_variable_get :@options }
|
@@ -20,7 +20,9 @@ describe "Restore" do
|
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'should have a command string' do
|
23
|
-
cmd = "mongorestore
|
23
|
+
cmd = "mongorestore"
|
24
|
+
options.each { |k, v| cmd += " --#{k} '#{v}'" }
|
25
|
+
cmd << " '#{path}'"
|
24
26
|
expect(subject.cmd_string).to eq cmd
|
25
27
|
end
|
26
28
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gomon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,6 +12,22 @@ bindir: bin
|
|
12
12
|
cert_chain: []
|
13
13
|
date: 2013-01-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: activesupport
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
15
31
|
- !ruby/object:Gem::Dependency
|
16
32
|
name: rspec
|
17
33
|
requirement: !ruby/object:Gem::Requirement
|