pg-ephemeral 0.0.1.pre1-aarch64-linux

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1f9987f9202c74ba05fbe6825df3c773d5e33da2f0eec8041750eae592c8848b
4
+ data.tar.gz: ac9eadf0f25bb8c77da4093a82e07be31c26b0b148df6c95c78b902496ceb4ae
5
+ SHA512:
6
+ metadata.gz: 43757953b062a123907f336b82a6c775bf958bb2ba17e28ddb7060b46fa71e3c64c768f89552c727a10994b92c1355e73cf7513d5164958f6339f61f35a25d6c
7
+ data.tar.gz: 75984c367810aeb6ac0dbd5b2aac0ff53ee1b77658d89938fca1147eb01cf872c32f42c9f39a112dc0368bd98f901e10be40199ab88702a3f3f33abf20befdc1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Markus Schirp
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/bin/pg-ephemeral ADDED
Binary file
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'open3'
4
+ require 'pathname'
5
+ require 'json'
6
+ require 'pg'
7
+ require 'unparser'
8
+ require 'rubygems'
9
+
10
+ module PgEphemeral
11
+ def self.binary_path
12
+ gem_dir = Gem::Specification.find_by_name('pg-ephemeral').gem_dir
13
+ File.join(gem_dir, 'bin', 'pg-ephemeral')
14
+ end
15
+
16
+ def self.version
17
+ stdout, _stderr, status = Open3.capture3(binary_path, '--version')
18
+
19
+ unless status.success?
20
+ raise "Failed to get version from pg-ephemeral binary"
21
+ end
22
+
23
+ match = stdout.match(/\Apg-ephemeral (?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(-(?<pre>.+))?\n\z/)
24
+
25
+ raise "Failed to parse version from pg-ephemeral binary" unless match
26
+
27
+ version = "#{match[:major]}.#{match[:minor]}.#{match[:patch]}"
28
+ version += ".#{match[:pre]}" if match[:pre]
29
+ version
30
+ end
31
+
32
+ def self.platform_supported?
33
+ stdout, status = Open3.capture2(binary_path, 'platform')
34
+ status.success?
35
+ end
36
+
37
+ def self.with_server(instance_name: 'main', config: nil, &block)
38
+ run_server(instance_name, config, &block).from_right
39
+ end
40
+
41
+ def self.with_connection(instance_name: 'main', config: nil, &block)
42
+ with_server(instance_name: instance_name, config: config) do |server|
43
+ connection = PG.connect(server.url)
44
+
45
+ begin
46
+ block.call(connection)
47
+ ensure
48
+ connection.close
49
+ end
50
+ end
51
+ end
52
+
53
+ def self.run_server(instance_name, config, &block)
54
+ command = [binary_path]
55
+
56
+ if config
57
+ command.concat(['--config-file', config])
58
+ end
59
+
60
+ command.concat([
61
+ 'instance',
62
+ '--name', instance_name,
63
+ 'integration-server',
64
+ 'v0'
65
+ ])
66
+
67
+ Open3.popen2(*command) do |stdin, stdout, wait_thread|
68
+ config_json = stdout.gets
69
+
70
+ return Unparser::Either::Left.new('Failed to read server configuration') unless config_json
71
+
72
+ url = JSON.parse(config_json).fetch('url')
73
+ server = Server.new(url, stdin, wait_thread)
74
+
75
+ begin
76
+ Unparser::Either::Right.new(block.call(server))
77
+ ensure
78
+ server.shutdown
79
+ end
80
+ end
81
+ end
82
+ private_class_method :run_server
83
+
84
+ class Server
85
+ attr_reader :url
86
+
87
+ def initialize(url, stdin, wait_thread)
88
+ @url = url
89
+ @stdin = stdin
90
+ @wait_thread = wait_thread
91
+ end
92
+
93
+ def shutdown
94
+ @stdin.close unless @stdin.closed?
95
+ @wait_thread.value
96
+ end
97
+ end
98
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pg-ephemeral
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre1
5
+ platform: aarch64-linux
6
+ authors:
7
+ - Markus Schirp
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: pg
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '1.5'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '1.5'
26
+ - !ruby/object:Gem::Dependency
27
+ name: unparser
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: 0.8.0
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 0.8.0
40
+ - !ruby/object:Gem::Dependency
41
+ name: bundler
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '2.0'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '2.0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: mutant-rspec
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 0.13.0
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: 0.13.0
68
+ - !ruby/object:Gem::Dependency
69
+ name: rspec
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '3.0'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '3.0'
82
+ description: Provides ephemeral PostgreSQL instances for testing, wrapping the pg-ephemeral
83
+ project binary
84
+ email:
85
+ - mbj@schirp-dso.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - LICENSE.txt
91
+ - bin/pg-ephemeral
92
+ - lib/pg_ephemeral.rb
93
+ homepage: https://github.com/mbj/mrs/tree/main/pg-ephemeral
94
+ licenses:
95
+ - MIT
96
+ metadata:
97
+ homepage_uri: https://github.com/mbj/mrs/tree/main/pg-ephemeral
98
+ source_code_uri: https://github.com/mbj/mrs
99
+ changelog_uri: https://github.com/mbj/mrs/blob/main/pg-ephemeral/CHANGELOG.md
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '3.2'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubygems_version: 3.6.9
115
+ specification_version: 4
116
+ summary: Ruby wrapper for pg-ephemeral PostgreSQL testing utility
117
+ test_files: []