postmodern 0.0.8 → 0.0.9

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65c24efcd6053881f84ed0084efe2442c0a78d82
4
- data.tar.gz: ec44170dedc5a7c2f59f34f91cfb16896bb4d830
3
+ metadata.gz: 0fc59b87120d01d64d1be1ed192f69d0625bffd2
4
+ data.tar.gz: 0f7525513257d166ef098b5c111f943b99a5f6a5
5
5
  SHA512:
6
- metadata.gz: 89e96ef4176c6e887e9ff106033e63d78a0287cae0b0c7908767651de6c19a863eabadf65da699bb2f483be3906696f96662638d668670e4f676a27abeb73119
7
- data.tar.gz: ccd1a255715acd723db55c0619fc49574565a9d8efe2814ca97b9cb82fb75d87197875b14223150d4982c9abdc5fdcef87d516ba726d20eeb861fcb4b2b292f5
6
+ metadata.gz: 91e8a3dcc83684764b9a84f9fd83a27271f0cb89708058a4a86bf68dc7fb5685752d8ed4bcbde7dfd6bd496e5dffb9b72d0601b1518af5d956047226c41707a5
7
+ data.tar.gz: fd1996258734c3e8f70860887e71a8a3231fc40495b215ea2bcbbbc1e94763b78a42af548f83df0d1d564345385963d92c4c88a2bddb507c090ebe801835869b
data/Gemfile CHANGED
@@ -5,6 +5,7 @@ gemspec
5
5
 
6
6
  group :development do
7
7
  gem 'rubocop'
8
+ gem 'pry-nav'
8
9
  end
9
10
 
10
11
  group :test do
data/README.md CHANGED
@@ -5,6 +5,8 @@ Postmodern
5
5
 
6
6
  Tools for managing PostgreSQL databases.
7
7
 
8
+ * WAL archiving and restoration
9
+
8
10
  ## Installation
9
11
 
10
12
  ```bash
@@ -1,3 +1,3 @@
1
1
  module Postmodern
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -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
- log
17
- `#{local_script} #{path} #{filename}`
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
-
@@ -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 postmodern_archive.local', exit: 0) }
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 postmodern_archive.local', exit: 1) }
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 postmodern_restore.local', exit: 0) }
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 postmodern_restore.local', exit: 1) }
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
@@ -1,4 +1,5 @@
1
1
  require 'aruba/rspec'
2
+ require 'pry'
2
3
 
3
4
  RSpec.configure do |config|
4
5
  config.treat_symbols_as_metadata_keys_with_true_values = true
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.8
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: