gomon 0.0.1 → 0.0.2
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/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +26 -0
- data/README.md +3 -1
- data/Rakefile +15 -0
- data/gomon.gemspec +3 -0
- data/lib/gomon/version.rb +1 -1
- data/spec/base_spec.rb +65 -0
- data/spec/dump_spec.rb +16 -0
- data/spec/options_spec.rb +42 -0
- data/spec/restore_spec.rb +26 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/uri_spec.rb +35 -0
- metadata +46 -3
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
gomon (0.0.2)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: http://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.1.3)
|
10
|
+
rake (10.0.3)
|
11
|
+
rspec (2.12.0)
|
12
|
+
rspec-core (~> 2.12.0)
|
13
|
+
rspec-expectations (~> 2.12.0)
|
14
|
+
rspec-mocks (~> 2.12.0)
|
15
|
+
rspec-core (2.12.2)
|
16
|
+
rspec-expectations (2.12.1)
|
17
|
+
diff-lcs (~> 1.1.3)
|
18
|
+
rspec-mocks (2.12.1)
|
19
|
+
|
20
|
+
PLATFORMS
|
21
|
+
ruby
|
22
|
+
|
23
|
+
DEPENDENCIES
|
24
|
+
gomon!
|
25
|
+
rake
|
26
|
+
rspec
|
data/README.md
CHANGED
@@ -4,6 +4,8 @@ Ruby wrappers around mongodb cli tools.
|
|
4
4
|
|
5
5
|
## Prerequisites
|
6
6
|
|
7
|
+
[](https://travis-ci.org/novelys/gomon)
|
8
|
+
|
7
9
|
This gem depends on no other gems. Ruby 1.9+
|
8
10
|
It assumes the presence of `mongorestore` and `mongodump` commands.
|
9
11
|
It was built around the latest tools at the moment of this writing, meaning version 2.2.2. So if is possible that arguments format and/or names have changed from previous versions, making them potentially not compatible with Gomon.
|
@@ -46,7 +48,6 @@ If you want to set options once the object is already created, you can use `add_
|
|
46
48
|
|
47
49
|
## What's next
|
48
50
|
|
49
|
-
* There is no test at all yet. This shall change.
|
50
51
|
* Better support for manipulating options once the object is created.
|
51
52
|
|
52
53
|
## Contributions
|
@@ -58,4 +59,5 @@ If you want to set options once the object is already created, you can use `add_
|
|
58
59
|
|
59
60
|
## Changelog
|
60
61
|
|
62
|
+
* `0.2`: Test coverage.
|
61
63
|
* `0.1`: First version. Provices basic functionnality for `Gomon::Dump` & `Gomon::Restore`
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'bundler/setup'
|
5
|
+
Bundler::GemHelper.install_tasks
|
6
|
+
rescue LoadError
|
7
|
+
puts 'although not required, bundler is recommened for running the tests'
|
8
|
+
end
|
9
|
+
|
10
|
+
task :default => :spec
|
11
|
+
|
12
|
+
require 'rspec/core/rake_task'
|
13
|
+
RSpec::Core::RakeTask.new do |t|
|
14
|
+
t.rspec_opts = ["--color", '--format doc']
|
15
|
+
end
|
data/gomon.gemspec
CHANGED
data/lib/gomon/version.rb
CHANGED
data/spec/base_spec.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'gomon/base'
|
2
|
+
|
3
|
+
describe "Base" do
|
4
|
+
context 'default options' do
|
5
|
+
subject { Gomon::Base.new }
|
6
|
+
let(:options) { subject.instance_variable_get :@options }
|
7
|
+
|
8
|
+
it 'host should be localhost' do
|
9
|
+
expect(options[:host]).to eq 'localhost'
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'port should be 27017' do
|
13
|
+
expect(options[:port]).to eq '27017'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'initialized with uri' do
|
18
|
+
subject { Gomon::Base.new uri: "mongodb://john:wayne@marlon.bran.do:23042/dark_side_of_the_moon" }
|
19
|
+
let(:options) { subject.instance_variable_get :@options }
|
20
|
+
|
21
|
+
it 'should not have uri' do
|
22
|
+
expect(options.has_key?(:uri)).not_to be_true
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should have username' do
|
26
|
+
expect(options[:username]).to be
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should have password' do
|
30
|
+
expect(options[:password]).to be
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should have host' do
|
34
|
+
expect(options[:host]).to be
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should have port' do
|
38
|
+
expect(options[:port]).to be
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should have database' do
|
42
|
+
expect(options[:db]).to be
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'initialized with other' do
|
47
|
+
subject { Gomon::Base.new other: "--first --third" }
|
48
|
+
let(:options) { subject.instance_variable_get :@singular_options }
|
49
|
+
|
50
|
+
it 'should have singular options' do
|
51
|
+
expect(options).to eq '--first --third'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'initialized with options' do
|
56
|
+
subject { Gomon::Base.new host: 'john', username: 'wayne', out: 'side' }
|
57
|
+
let(:options) { subject.instance_variable_get :@options }
|
58
|
+
|
59
|
+
it 'should have options set' do
|
60
|
+
expect(options[:host]).to eq 'john'
|
61
|
+
expect(options[:username]).to eq 'wayne'
|
62
|
+
expect(options[:out]).to eq 'side'
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/spec/dump_spec.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'gomon/dump'
|
2
|
+
|
3
|
+
describe "Dump" do
|
4
|
+
|
5
|
+
subject { Gomon::Dump.new username: 'john', password: 'mcclane', db: 'die_hard'}
|
6
|
+
let(:tool) { subject.instance_variable_get :@tool }
|
7
|
+
|
8
|
+
it 'should have a toolname' do
|
9
|
+
expect(tool).to eq 'mongodump'
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should have a command string' do
|
13
|
+
cmd = "mongodump --host 'localhost' --port '27017' --username 'john' --password 'mcclane' --db 'die_hard'"
|
14
|
+
expect(subject.cmd_string).to eq cmd
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'gomon/options'
|
2
|
+
|
3
|
+
describe "Options" do
|
4
|
+
before :all do
|
5
|
+
class TestObject
|
6
|
+
include Gomon::Options
|
7
|
+
|
8
|
+
def initialize; @options = {}; @singular_options = '--first --second'; end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
subject { TestObject.new }
|
13
|
+
let(:options) { subject.instance_variable_get :@options }
|
14
|
+
let(:singular) { subject.instance_variable_get :@singular_options }
|
15
|
+
|
16
|
+
it 'should add one option' do
|
17
|
+
subject.add_option :key, 'value'
|
18
|
+
expect(options[:key]).to eq 'value'
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should add several options' do
|
22
|
+
subject.add_options key1: 'value1', key2: 'value2'
|
23
|
+
expect(options[:key1]).to eq 'value1'
|
24
|
+
expect(options[:key2]).to eq 'value2'
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should have singular options' do
|
28
|
+
expect(singular).to eq '--first --second'
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'can override previous keys' do
|
32
|
+
subject.add_option :key, 'value'
|
33
|
+
expect(options[:key]).to eq 'value'
|
34
|
+
subject.add_option :key, 'new_value'
|
35
|
+
expect(options[:key]).to eq 'new_value'
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'can merge options into a string' do
|
39
|
+
subject.add_options key1: 'value1', key2: 'value2'
|
40
|
+
expect(subject.cli_options).to eq "--key1 'value1' --key2 'value2' --first --second"
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'gomon/restore'
|
2
|
+
|
3
|
+
describe "Restore" do
|
4
|
+
|
5
|
+
subject { Gomon::Restore.new path: 'dump/dir', db: 'die_hard'}
|
6
|
+
let(:tool) { subject.instance_variable_get :@tool }
|
7
|
+
let(:path) { subject.instance_variable_get :@path }
|
8
|
+
let(:options) { subject.instance_variable_get :@options }
|
9
|
+
|
10
|
+
it 'should have a toolname' do
|
11
|
+
expect(tool).to eq 'mongorestore'
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should not have a path option' do
|
15
|
+
expect(options.has_key?(:path)).to be false
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should have a path' do
|
19
|
+
expect(path).to eq 'dump/dir'
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should have a command string' do
|
23
|
+
cmd = "mongorestore --host 'localhost' --port '27017' --db 'die_hard' 'dump/dir'"
|
24
|
+
expect(subject.cmd_string).to eq cmd
|
25
|
+
end
|
26
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run :focus
|
11
|
+
|
12
|
+
# Run specs in random order to surface order dependencies. If you find an
|
13
|
+
# order dependency and want to debug it, you can fix the order by providing
|
14
|
+
# the seed, which is printed after each run.
|
15
|
+
# --seed 1234
|
16
|
+
config.order = 'random'
|
17
|
+
end
|
data/spec/uri_spec.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'gomon/uri'
|
2
|
+
|
3
|
+
describe "Uri" do
|
4
|
+
before :all do
|
5
|
+
class TestObject
|
6
|
+
include Gomon::Uri
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
subject { TestObject.new }
|
11
|
+
let(:uri) { "mongodb://john:wayne@marlon.bran.do:23042/dark_side_of_the_moon"}
|
12
|
+
let(:opts) { subject.parse_uri uri }
|
13
|
+
|
14
|
+
context 'parsing' do
|
15
|
+
it 'should find username' do
|
16
|
+
expect(opts[:username]).to eq 'john'
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should find password' do
|
20
|
+
expect(opts[:password]).to eq 'wayne'
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should find host' do
|
24
|
+
expect(opts[:host]).to eq 'marlon.bran.do'
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should find port' do
|
28
|
+
expect(opts[:port]).to eq '23042'
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should find database' do
|
32
|
+
expect(opts[:db]).to eq 'dark_side_of_the_moon'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
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.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,8 +10,40 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-01-
|
14
|
-
dependencies:
|
13
|
+
date: 2013-01-14 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: rake
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
15
47
|
description: A set of ruby classing wrapping mongodb cli tools, making them pleasant
|
16
48
|
to integrate to ruby scripts, rake tasks, etc
|
17
49
|
email:
|
@@ -20,7 +52,12 @@ executables: []
|
|
20
52
|
extensions: []
|
21
53
|
extra_rdoc_files: []
|
22
54
|
files:
|
55
|
+
- .rspec
|
56
|
+
- .travis.yml
|
57
|
+
- Gemfile
|
58
|
+
- Gemfile.lock
|
23
59
|
- README.md
|
60
|
+
- Rakefile
|
24
61
|
- gomon.gemspec
|
25
62
|
- lib/gomon.rb
|
26
63
|
- lib/gomon/base.rb
|
@@ -29,6 +66,12 @@ files:
|
|
29
66
|
- lib/gomon/restore.rb
|
30
67
|
- lib/gomon/uri.rb
|
31
68
|
- lib/gomon/version.rb
|
69
|
+
- spec/base_spec.rb
|
70
|
+
- spec/dump_spec.rb
|
71
|
+
- spec/options_spec.rb
|
72
|
+
- spec/restore_spec.rb
|
73
|
+
- spec/spec_helper.rb
|
74
|
+
- spec/uri_spec.rb
|
32
75
|
homepage: http://github.com/novelys/gomon
|
33
76
|
licenses: []
|
34
77
|
post_install_message:
|