postmodern 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/README.md +2 -0
- data/lib/postmodern/version.rb +1 -1
- data/lib/postmodern/wal/base.rb +6 -10
- data/spec/bin/postmodern_spec.rb +4 -22
- data/spec/postmodern/wal/archive_spec.rb +39 -0
- data/spec/spec_helper.rb +1 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fc59b87120d01d64d1be1ed192f69d0625bffd2
|
4
|
+
data.tar.gz: 0f7525513257d166ef098b5c111f943b99a5f6a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91e8a3dcc83684764b9a84f9fd83a27271f0cb89708058a4a86bf68dc7fb5685752d8ed4bcbde7dfd6bd496e5dffb9b72d0601b1518af5d956047226c41707a5
|
7
|
+
data.tar.gz: fd1996258734c3e8f70860887e71a8a3231fc40495b215ea2bcbbbc1e94763b78a42af548f83df0d1d564345385963d92c4c88a2bddb507c090ebe801835869b
|
data/Gemfile
CHANGED
data/README.md
CHANGED
data/lib/postmodern/version.rb
CHANGED
data/lib/postmodern/wal/base.rb
CHANGED
@@ -6,15 +6,16 @@ module Postmodern
|
|
6
6
|
def initialize(filename, path)
|
7
7
|
@filename = filename
|
8
8
|
@path = path
|
9
|
-
|
10
|
-
ENV['WAL_ARCHIVE_PATH'] = path
|
11
|
-
ENV['WAL_ARCHIVE_FILE'] = filename
|
12
9
|
end
|
13
10
|
|
14
11
|
def run
|
15
12
|
if local_script_exists?
|
16
|
-
|
17
|
-
|
13
|
+
IO.popen("#{local_script} #{path} #{filename}",
|
14
|
+
env: {
|
15
|
+
'WAL_ARCHIVE_PATH' => path,
|
16
|
+
'WAL_ARCHIVE_FILE' => filename,
|
17
|
+
'PATH' => ENV['PATH']
|
18
|
+
})
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
@@ -28,11 +29,6 @@ module Postmodern
|
|
28
29
|
def local_script
|
29
30
|
'postmodern_archive.local'
|
30
31
|
end
|
31
|
-
|
32
|
-
def log
|
33
|
-
puts "Archiving file: #{filename}, path: #{path}"
|
34
|
-
end
|
35
32
|
end
|
36
33
|
end
|
37
34
|
end
|
38
|
-
|
data/spec/bin/postmodern_spec.rb
CHANGED
@@ -6,19 +6,10 @@ describe 'postmodern' do
|
|
6
6
|
|
7
7
|
before do
|
8
8
|
double_cmd('postmodern_archive.local')
|
9
|
-
double_cmd('which', exit: 0)
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'exports second argument as WAL_ARCHIVE_FILE' do
|
13
|
-
expect(command).to include('Archiving file: filename')
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'exports first argument WAL_ARCHIVE_PATH' do
|
17
|
-
expect(command).to include('path: filepath')
|
18
9
|
end
|
19
10
|
|
20
11
|
context 'when local script is present' do
|
21
|
-
before { double_cmd('which
|
12
|
+
before { double_cmd('which', exit: 0) }
|
22
13
|
|
23
14
|
it 'succeeds' do
|
24
15
|
expect { command }.to have_exit_status(0)
|
@@ -30,7 +21,7 @@ describe 'postmodern' do
|
|
30
21
|
end
|
31
22
|
|
32
23
|
context 'when local script is not present' do
|
33
|
-
before { double_cmd('which
|
24
|
+
before { double_cmd('which', exit: 1) }
|
34
25
|
|
35
26
|
it 'succeeds' do
|
36
27
|
expect { command }.to have_exit_status(0)
|
@@ -47,19 +38,10 @@ describe 'postmodern' do
|
|
47
38
|
|
48
39
|
before do
|
49
40
|
double_cmd('postmodern_restore.local')
|
50
|
-
double_cmd('which', exit: 0)
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'exports second argument as WAL_restore_FILE' do
|
54
|
-
expect(command).to include('Restoring file: filename')
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'exports first argument WAL_restore_PATH' do
|
58
|
-
expect(command).to include('path: filepath')
|
59
41
|
end
|
60
42
|
|
61
43
|
context 'when local script is present' do
|
62
|
-
before { double_cmd('which
|
44
|
+
before { double_cmd('which', exit: 0) }
|
63
45
|
|
64
46
|
it 'succeeds' do
|
65
47
|
expect { command }.to have_exit_status(0)
|
@@ -71,7 +53,7 @@ describe 'postmodern' do
|
|
71
53
|
end
|
72
54
|
|
73
55
|
context 'when local script is not present' do
|
74
|
-
before { double_cmd('which
|
56
|
+
before { double_cmd('which', exit: 1) }
|
75
57
|
|
76
58
|
it 'succeeds' do
|
77
59
|
expect { command }.to have_exit_status(0)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'postmodern/wal/archive'
|
3
|
+
|
4
|
+
describe Postmodern::WAL::Archive do
|
5
|
+
before { allow(IO).to receive(:popen) }
|
6
|
+
|
7
|
+
let(:filename) { "some_file" }
|
8
|
+
let(:path) { "/path/to/file" }
|
9
|
+
|
10
|
+
subject(:archiver) { Postmodern::WAL::Archive.new(filename, path) }
|
11
|
+
|
12
|
+
describe '#run' do
|
13
|
+
let(:expected_command) { "postmodern_archive.local #{path} #{filename}" }
|
14
|
+
|
15
|
+
context 'when local script exists' do
|
16
|
+
before { double_cmd('which postmodern_archive.local', exit: 0) }
|
17
|
+
|
18
|
+
it 'executes postmodern_archive.local with filename and path' do
|
19
|
+
archiver.run
|
20
|
+
expect(IO).to have_received(:popen).with(expected_command, env:
|
21
|
+
{
|
22
|
+
'WAL_ARCHIVE_PATH' => path,
|
23
|
+
'WAL_ARCHIVE_FILE' => filename,
|
24
|
+
'PATH' => anything
|
25
|
+
}
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when local script does not exist' do
|
31
|
+
before { double_cmd('which postmodern_archive.local', exit: 1) }
|
32
|
+
|
33
|
+
it 'executes postmodern_archive.local with filename and path' do
|
34
|
+
archiver.run
|
35
|
+
expect(IO).not_to have_received(:popen)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postmodern
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Saxby
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- lib/postmodern/wal/restore.rb
|
65
65
|
- postmodern.gemspec
|
66
66
|
- spec/bin/postmodern_spec.rb
|
67
|
+
- spec/postmodern/wal/archive_spec.rb
|
67
68
|
- spec/spec_helper.rb
|
68
69
|
homepage: https://github.com/wanelo/postmodern
|
69
70
|
licenses:
|
@@ -91,5 +92,6 @@ specification_version: 4
|
|
91
92
|
summary: Tools for managing PostgreSQL
|
92
93
|
test_files:
|
93
94
|
- spec/bin/postmodern_spec.rb
|
95
|
+
- spec/postmodern/wal/archive_spec.rb
|
94
96
|
- spec/spec_helper.rb
|
95
97
|
has_rdoc:
|