pg-ephemeral 0.0.1-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: 9b01a1d376a9eef537978c9044bd830065e9cac114bd298a3342c06434ef8d25
4
+ data.tar.gz: a5f8732ac53519f4dd1fbd5da525d0cd8cd19cf4f5f4eaaa6ba2a9c38383a7d7
5
+ SHA512:
6
+ metadata.gz: 61a82312068534418da2cfb238a195044dde45f7896d7abdf2f7edf153c45732e11a0e476662cd6e13bd6254e46f6f1cb317980fcbd198c0a9626797866df80e
7
+ data.tar.gz: ba2dd6dd50f161bec3da5602fd1c00e7276335b9ac8769ab2b4d483c96d6a4d6d9756397f72679f6271350a102a839279556f7b9b3e1376cdfbaab3ac096ce82
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,96 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'open3'
4
+ require 'pathname'
5
+ require 'json'
6
+ require 'pg'
7
+ require 'rubygems'
8
+
9
+ module PgEphemeral
10
+ def self.binary_path
11
+ gem_dir = Gem::Specification.find_by_name('pg-ephemeral').gem_dir
12
+ File.join(gem_dir, 'bin', 'pg-ephemeral')
13
+ end
14
+
15
+ def self.version
16
+ stdout, _stderr, status = Open3.capture3(binary_path, '--version')
17
+
18
+ unless status.success?
19
+ raise "Failed to get version from pg-ephemeral binary"
20
+ end
21
+
22
+ match = stdout.match(/\Apg-ephemeral (?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)(-(?<pre>.+))?\n\z/)
23
+
24
+ raise "Failed to parse version from pg-ephemeral binary" unless match
25
+
26
+ version = "#{match[:major]}.#{match[:minor]}.#{match[:patch]}"
27
+ version += ".#{match[:pre]}" if match[:pre]
28
+ version
29
+ end
30
+
31
+ def self.platform_supported?
32
+ _stdout, status = Open3.capture2(binary_path, 'platform', 'support')
33
+ status.success?
34
+ end
35
+
36
+ def self.with_server(instance_name: 'main', config: nil, &block)
37
+ run_server(instance_name, config, &block)
38
+ end
39
+
40
+ def self.with_connection(instance_name: 'main', config: nil, &block)
41
+ with_server(instance_name: instance_name, config: config) do |server|
42
+ connection = PG.connect(server.url)
43
+
44
+ begin
45
+ block.call(connection)
46
+ ensure
47
+ connection.close
48
+ end
49
+ end
50
+ end
51
+
52
+ def self.run_server(instance_name, config, &block)
53
+ command = [binary_path]
54
+
55
+ if config
56
+ command.concat(['--config-file', config])
57
+ end
58
+
59
+ command.concat([
60
+ 'integration-server',
61
+ '--instance', instance_name,
62
+ '--protocol', 'v0'
63
+ ])
64
+
65
+ Open3.popen2(*command) do |stdin, stdout, wait_thread|
66
+ config_json = stdout.gets
67
+
68
+ raise 'Failed to read server configuration' unless config_json
69
+
70
+ url = JSON.parse(config_json).fetch('url')
71
+ server = Server.new(url, stdin, wait_thread)
72
+
73
+ begin
74
+ block.call(server)
75
+ ensure
76
+ server.shutdown
77
+ end
78
+ end
79
+ end
80
+ private_class_method :run_server
81
+
82
+ class Server
83
+ attr_reader :url
84
+
85
+ def initialize(url, stdin, wait_thread)
86
+ @url = url
87
+ @stdin = stdin
88
+ @wait_thread = wait_thread
89
+ end
90
+
91
+ def shutdown
92
+ @stdin.close unless @stdin.closed?
93
+ @wait_thread.value
94
+ end
95
+ end
96
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pg-ephemeral
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
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
+ description: Provides ephemeral PostgreSQL instances for testing, wrapping the pg-ephemeral
27
+ project binary
28
+ email:
29
+ - mbj@schirp-dso.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - LICENSE.txt
35
+ - bin/pg-ephemeral
36
+ - lib/pg_ephemeral.rb
37
+ homepage: https://github.com/mbj/mrs/tree/main/pg-ephemeral
38
+ licenses:
39
+ - MIT
40
+ metadata:
41
+ homepage_uri: https://github.com/mbj/mrs/tree/main/pg-ephemeral
42
+ source_code_uri: https://github.com/mbj/mrs
43
+ changelog_uri: https://github.com/mbj/mrs/blob/main/pg-ephemeral/CHANGELOG.md
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '3.2'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubygems_version: 3.6.9
59
+ specification_version: 4
60
+ summary: Ruby wrapper for pg-ephemeral PostgreSQL testing utility
61
+ test_files: []