postmodern 0.3.2 → 0.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e2b671e30a5ee0c8ecfa77d5733c84590ca63fdd
4
- data.tar.gz: 15a7be3b455918273f5f2c8792bf358edcfe9732
3
+ metadata.gz: cbecfcf25d7aab04bd19df71c1edd12680eb84a7
4
+ data.tar.gz: 3a104d4e01a2297319572ff763345a40da950a9a
5
5
  SHA512:
6
- metadata.gz: bde4d0dfe8c99fe8e96f8e3a94605162420693fae1a56661a98595d51eb5c162cf05611ec6b549cb85a7a2367a419e7799e65da5322ad856d8c38f65db990070
7
- data.tar.gz: 00c15cf153c20293a3f51b197c93c33a741fa4ce5034c8e15e685a19b466357b85b4a106e2fecc7e74feca5269fe79c1ec7dab0007e500ebc870ef43ea4925a2
6
+ metadata.gz: 7e133e8e11e56f7cb9dd594c9784cefb9311b68216e1656618f9e06b7896bbc4e6955f6606e8a416af86f2c0b348c0889b09233cd3c0f2520c7a49c366d8cdd3
7
+ data.tar.gz: 8de3bd8f674ae01174bce7b0046d53473d42b245d2da849ea29f037a392c694055012b77df04bf919987dabd765f16c3a88c91c67d8f34411395bc35810e68d1
data/Gemfile CHANGED
@@ -9,8 +9,8 @@ group :development do
9
9
  end
10
10
 
11
11
  group :test do
12
- gem 'rspec'
13
- gem 'aruba-rspec'
12
+ gem 'rspec', '>= 3.0.0'
13
+ gem 'aruba-rspec', '>= 1.0.0'
14
14
  gem 'guard-bundler'
15
15
  gem 'guard-rspec'
16
16
  gem 'timecop'
data/README.md CHANGED
@@ -5,6 +5,7 @@ Postmodern
5
5
 
6
6
  Tools for managing PostgreSQL databases.
7
7
 
8
+ * Vacuum and Vacuum freeze tasks
8
9
  * WAL archiving and restoration
9
10
 
10
11
  ## Dependencies
@@ -1,3 +1,3 @@
1
1
  module Postmodern
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
@@ -1,4 +1,5 @@
1
1
  require 'postmodern/command'
2
+ require 'open3'
2
3
 
3
4
  module Postmodern
4
5
  module WAL
@@ -32,12 +33,10 @@ module Postmodern
32
33
 
33
34
  def run
34
35
  if local_script_exists?
35
- IO.popen("#{local_script} #{path} #{filename}",
36
- env: {
37
- 'WAL_ARCHIVE_PATH' => path,
38
- 'WAL_ARCHIVE_FILE' => filename,
39
- 'PATH' => ENV['PATH']
40
- }) { |f| puts f.gets }
36
+ stdout, stderr, status = Open3.capture3(script_env, "#{local_script} #{path} #{filename}")
37
+ $stdout.print stdout
38
+ $stderr.print stderr
39
+ exit status.exitstatus
41
40
  end
42
41
  end
43
42
 
@@ -58,6 +57,14 @@ module Postmodern
58
57
  def local_script
59
58
  'postmodern_archive.local'
60
59
  end
60
+
61
+ def script_env
62
+ {
63
+ 'WAL_ARCHIVE_PATH' => path,
64
+ 'WAL_ARCHIVE_FILE' => filename,
65
+ 'PATH' => ENV['PATH']
66
+ }
67
+ end
61
68
  end
62
69
  end
63
70
  end
@@ -0,0 +1,6 @@
1
+ #!/bin/bash
2
+
3
+ echo "WAL_ARCHIVE_PATH: ${WAL_ARCHIVE_PATH}"
4
+ echo "WAL_ARCHIVE_FILE: ${WAL_ARCHIVE_FILE}"
5
+
6
+ exit ${EXITSTATUS:-0}
@@ -2,7 +2,9 @@ require 'spec_helper'
2
2
  require 'postmodern/wal/archive'
3
3
 
4
4
  describe Postmodern::WAL::Archive do
5
- before { allow(IO).to receive(:popen) }
5
+ let(:stdout) { double(to_s: '') }
6
+ let(:stderr) { double(to_s: '') }
7
+ let(:status) { double(exitstatus: 0) }
6
8
 
7
9
  let(:filename) { "some_file" }
8
10
  let(:path) { "/path/to/file" }
@@ -10,6 +12,11 @@ describe Postmodern::WAL::Archive do
10
12
 
11
13
  subject(:archiver) { Postmodern::WAL::Archive.new(arguments) }
12
14
 
15
+ before do
16
+ allow(Open3).to receive(:capture3).and_return([stdout, stderr, status])
17
+ allow(archiver).to receive(:exit)
18
+ end
19
+
13
20
  describe '#run' do
14
21
  let(:expected_command) { "postmodern_archive.local #{path} #{filename}" }
15
22
 
@@ -18,12 +25,13 @@ describe Postmodern::WAL::Archive do
18
25
 
19
26
  it 'executes postmodern_archive.local with filename and path' do
20
27
  archiver.run
21
- expect(IO).to have_received(:popen).with(expected_command, env:
28
+ expect(Open3).to have_received(:capture3).with(
22
29
  {
23
30
  'WAL_ARCHIVE_PATH' => path,
24
31
  'WAL_ARCHIVE_FILE' => filename,
25
32
  'PATH' => anything
26
- }
33
+ },
34
+ expected_command
27
35
  )
28
36
  end
29
37
  end
@@ -33,7 +41,7 @@ describe Postmodern::WAL::Archive do
33
41
 
34
42
  it 'executes postmodern_archive.local with filename and path' do
35
43
  archiver.run
36
- expect(IO).not_to have_received(:popen)
44
+ expect(Open3).not_to have_received(:capture3)
37
45
  end
38
46
  end
39
47
  end
@@ -2,7 +2,9 @@ require 'spec_helper'
2
2
  require 'postmodern/wal/restore'
3
3
 
4
4
  describe Postmodern::WAL::Restore do
5
- before { allow(IO).to receive(:popen) }
5
+ let(:stdout) { double(to_s: '') }
6
+ let(:stderr) { double(to_s: '') }
7
+ let(:status) { double(exitstatus: 0) }
6
8
 
7
9
  let(:filename) { "some_file" }
8
10
  let(:path) { "/path/to/file" }
@@ -10,6 +12,11 @@ describe Postmodern::WAL::Restore do
10
12
 
11
13
  subject(:restorer) { Postmodern::WAL::Restore.new(arguments) }
12
14
 
15
+ before do
16
+ allow(Open3).to receive(:capture3).and_return([stdout, stderr, status])
17
+ allow(restorer).to receive(:exit)
18
+ end
19
+
13
20
  describe '#run' do
14
21
  let(:expected_command) { "postmodern_restore.local #{path} #{filename}" }
15
22
 
@@ -18,12 +25,13 @@ describe Postmodern::WAL::Restore do
18
25
 
19
26
  it 'executes postmodern_restore.local with filename and path' do
20
27
  restorer.run
21
- expect(IO).to have_received(:popen).with(expected_command, env:
28
+ expect(Open3).to have_received(:capture3).with(
22
29
  {
23
30
  'WAL_ARCHIVE_PATH' => path,
24
31
  'WAL_ARCHIVE_FILE' => filename,
25
32
  'PATH' => anything
26
- }
33
+ },
34
+ expected_command
27
35
  )
28
36
  end
29
37
  end
@@ -33,7 +41,7 @@ describe Postmodern::WAL::Restore do
33
41
 
34
42
  it 'executes postmodern_restore.local with filename and path' do
35
43
  restorer.run
36
- expect(IO).not_to have_received(:popen)
44
+ expect(Open3).not_to have_received(:capture3)
37
45
  end
38
46
  end
39
47
  end
@@ -5,7 +5,6 @@ require 'timecop'
5
5
  require 'support/logger'
6
6
 
7
7
  RSpec.configure do |config|
8
- config.treat_symbols_as_metadata_keys_with_true_values = true
9
8
  config.run_all_when_everything_filtered = true
10
9
  config.filter_run :focus
11
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: postmodern
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Saxby
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-02 00:00:00.000000000 Z
11
+ date: 2014-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -88,6 +88,7 @@ files:
88
88
  - spec/features/freeze_spec.rb
89
89
  - spec/features/restore_spec.rb
90
90
  - spec/features/vacuum_spec.rb
91
+ - spec/fixtures/wal/env/postmodern_archive.local
91
92
  - spec/postmodern/command_spec.rb
92
93
  - spec/postmodern/db/adapter_spec.rb
93
94
  - spec/postmodern/postmodern_spec.rb
@@ -128,6 +129,7 @@ test_files:
128
129
  - spec/features/freeze_spec.rb
129
130
  - spec/features/restore_spec.rb
130
131
  - spec/features/vacuum_spec.rb
132
+ - spec/fixtures/wal/env/postmodern_archive.local
131
133
  - spec/postmodern/command_spec.rb
132
134
  - spec/postmodern/db/adapter_spec.rb
133
135
  - spec/postmodern/postmodern_spec.rb