dbmanager 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dbmanager/adapters/mysql.rb +1 -5
- data/lib/dbmanager/dumpable.rb +1 -0
- data/lib/dbmanager/environment.rb +3 -1
- data/lib/dbmanager/importable.rb +7 -2
- data/lib/dbmanager/runner.rb +1 -0
- data/lib/dbmanager/version.rb +1 -1
- data/spec/lib/adapters/mysql_spec.rb +2 -11
- data/spec/lib/importable_spec.rb +18 -6
- metadata +14 -13
data/lib/dbmanager/dumpable.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'ostruct'
|
2
1
|
# An +Environment+ object is created for each environment listed in the
|
3
2
|
# database.yml file.
|
4
3
|
#
|
@@ -13,6 +12,9 @@ require 'ostruct'
|
|
13
12
|
# If on the other hand you want to be free to overwrite the production db
|
14
13
|
# you need to explicitly set +protected: false+ to that environment in the
|
15
14
|
# database.yml file.
|
15
|
+
|
16
|
+
require 'ostruct'
|
17
|
+
|
16
18
|
module Dbmanager
|
17
19
|
class Environment < OpenStruct
|
18
20
|
|
data/lib/dbmanager/importable.rb
CHANGED
@@ -8,6 +8,7 @@
|
|
8
8
|
# The source and target environment must use the same adapter, ie you cannot
|
9
9
|
# import a mysql database on a sqlite3 database. For that purpose you can use
|
10
10
|
# the taps gem.
|
11
|
+
|
11
12
|
module Dbmanager
|
12
13
|
module Importable
|
13
14
|
def self.extended(base)
|
@@ -16,8 +17,12 @@ module Dbmanager
|
|
16
17
|
|
17
18
|
def run
|
18
19
|
@target = get_env('target')
|
19
|
-
|
20
|
-
|
20
|
+
if target.protected?
|
21
|
+
raise EnvironmentProtectedError
|
22
|
+
else
|
23
|
+
execute_import
|
24
|
+
output.puts 'Database Import completed.'
|
25
|
+
end
|
21
26
|
end
|
22
27
|
|
23
28
|
def execute_import
|
data/lib/dbmanager/runner.rb
CHANGED
data/lib/dbmanager/version.rb
CHANGED
@@ -58,17 +58,8 @@ module Dbmanager
|
|
58
58
|
end
|
59
59
|
|
60
60
|
describe '#import_command' do
|
61
|
-
|
62
|
-
|
63
|
-
subject.import_command.should == 'mysql -ubeta_user < /some/arbitrary/path'
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
context 'when environment is protected' do
|
68
|
-
it 'raises EnvironmentProtectedError' do
|
69
|
-
target.stub! :protected? => true
|
70
|
-
expect { subject.import_command }.to raise_error(EnvironmentProtectedError)
|
71
|
-
end
|
61
|
+
it 'returns expected command' do
|
62
|
+
subject.import_command.should == 'mysql -ubeta_user < /some/arbitrary/path'
|
72
63
|
end
|
73
64
|
end
|
74
65
|
|
data/spec/lib/importable_spec.rb
CHANGED
@@ -20,7 +20,7 @@ module Dbmanager
|
|
20
20
|
before do
|
21
21
|
subject.stub(
|
22
22
|
:source => mock(:adapter => 'mysql2'),
|
23
|
-
:target => mock(:adapter => 'mysql2')
|
23
|
+
:target => mock(:adapter => 'mysql2', :protected? => false)
|
24
24
|
)
|
25
25
|
end
|
26
26
|
|
@@ -49,11 +49,23 @@ module Dbmanager
|
|
49
49
|
end
|
50
50
|
|
51
51
|
describe '#run' do
|
52
|
-
|
53
|
-
subject.stub(:
|
54
|
-
|
55
|
-
|
56
|
-
|
52
|
+
context 'when target is protected' do
|
53
|
+
before { subject.stub :target => mock(:protected? => true) }
|
54
|
+
|
55
|
+
it 'raises EnvironmentProtectedError' do
|
56
|
+
expect { subject.run }.to raise_error(EnvironmentProtectedError)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'when target is not protected' do
|
61
|
+
before { subject.stub :target => mock(:protected? => false) }
|
62
|
+
|
63
|
+
it 'outputs expected messages' do
|
64
|
+
subject.stub(:execute_import => nil)
|
65
|
+
subject.run
|
66
|
+
message = 'Database Import completed.'
|
67
|
+
subject.output.content.should include(message)
|
68
|
+
end
|
57
69
|
end
|
58
70
|
end
|
59
71
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dbmanager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- andrea longhi
|
@@ -15,11 +15,12 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-07-04 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: activesupport
|
22
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
24
|
none: false
|
24
25
|
requirements:
|
25
26
|
- - ">="
|
@@ -29,11 +30,11 @@ dependencies:
|
|
29
30
|
- 0
|
30
31
|
version: "0"
|
31
32
|
type: :runtime
|
32
|
-
|
33
|
-
prerelease: false
|
33
|
+
version_requirements: *id001
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: rspec
|
36
|
-
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
38
|
none: false
|
38
39
|
requirements:
|
39
40
|
- - ">="
|
@@ -43,11 +44,11 @@ dependencies:
|
|
43
44
|
- 0
|
44
45
|
version: "0"
|
45
46
|
type: :development
|
46
|
-
|
47
|
-
prerelease: false
|
47
|
+
version_requirements: *id002
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: rake
|
50
|
-
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
51
52
|
none: false
|
52
53
|
requirements:
|
53
54
|
- - ">="
|
@@ -57,8 +58,7 @@ dependencies:
|
|
57
58
|
- 0
|
58
59
|
version: "0"
|
59
60
|
type: :development
|
60
|
-
|
61
|
-
prerelease: false
|
61
|
+
version_requirements: *id003
|
62
62
|
description: helps manage db dumps and imports via rake tasks
|
63
63
|
email:
|
64
64
|
- andrea.longhi@mikamai.com
|
@@ -146,3 +146,4 @@ test_files:
|
|
146
146
|
- spec/lib/yml_parser_spec.rb
|
147
147
|
- spec/spec_helper.rb
|
148
148
|
- spec/support/std_stub.rb
|
149
|
+
has_rdoc:
|