pgtk 0.30.5 → 0.30.7

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.
data/lib/pgtk/wire.rb CHANGED
@@ -13,98 +13,94 @@ require_relative '../pgtk'
13
13
  # Copyright:: Copyright (c) 2019-2026 Yegor Bugayenko
14
14
  # License:: MIT
15
15
  module Pgtk::Wire
16
- end
17
-
18
- # Simple wire with details.
19
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
20
- # Copyright:: Copyright (c) 2019-2026 Yegor Bugayenko
21
- # License:: MIT
22
- class Pgtk::Wire::Direct
23
- # Constructor.
24
- #
25
- # @param [String] host Host name of the PostgreSQL server
26
- # @param [Integer] port Port number of the PostgreSQL server
27
- # @param [String] dbname Database name
28
- # @param [String] user Username
29
- # @param [String] password Password
30
- def initialize(host:, port:, dbname:, user:, password:)
31
- raise "The host can't be nil" if host.nil?
32
- @host = host
33
- raise "The port can't be nil" if port.nil?
34
- @port = port
35
- @dbname = dbname
36
- @user = user
37
- @password = password
38
- end
16
+ # Simple wire with details.
17
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
18
+ # Copyright:: Copyright (c) 2019-2026 Yegor Bugayenko
19
+ # License:: MIT
20
+ class Direct
21
+ # Constructor.
22
+ #
23
+ # @param [String] host Host name of the PostgreSQL server
24
+ # @param [Integer] port Port number of the PostgreSQL server
25
+ # @param [String] dbname Database name
26
+ # @param [String] user Username
27
+ # @param [String] password Password
28
+ def initialize(host:, port:, dbname:, user:, password:)
29
+ raise(ArgumentError, "The host can't be nil") if host.nil?
30
+ @host = host
31
+ raise(ArgumentError, "The port can't be nil") if port.nil?
32
+ @port = port
33
+ @dbname = dbname
34
+ @user = user
35
+ @password = password
36
+ end
39
37
 
40
- # Create a new connection to PostgreSQL server.
41
- def connection
42
- PG.connect(
43
- dbname: @dbname, host: @host, port: @port,
44
- user: @user, password: @password
45
- )
38
+ # Create a new connection to PostgreSQL server.
39
+ def connection
40
+ PG.connect(dbname: @dbname, host: @host, port: @port, user: @user, password: @password)
41
+ end
46
42
  end
47
- end
48
43
 
49
- # Using ENV variable.
50
- #
51
- # The value of the variable should be in this format:
52
- #
53
- # postgres://user:password@host:port/dbname
54
- #
55
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
56
- # Copyright:: Copyright (c) 2019-2026 Yegor Bugayenko
57
- # License:: MIT
58
- class Pgtk::Wire::Env
59
- # Constructor.
44
+ # Using ENV variable.
60
45
  #
61
- # @param [String] var The name of the environment variable with the connection URL
62
- def initialize(var = 'DATABASE_URL')
63
- raise "The name of the environment variable can't be nil" if var.nil?
64
- @value = ENV.fetch(var, nil)
65
- raise "The environment variable #{@value.inspect} is not set" if @value.nil?
66
- end
46
+ # The value of the variable should be in this format:
47
+ #
48
+ # postgres://user:password@host:port/dbname
49
+ #
50
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
51
+ # Copyright:: Copyright (c) 2019-2026 Yegor Bugayenko
52
+ # License:: MIT
53
+ class Env
54
+ # Constructor.
55
+ #
56
+ # @param [String] var The name of the environment variable with the connection URL
57
+ def initialize(var = 'DATABASE_URL')
58
+ raise(ArgumentError, "The name of the environment variable can't be nil") if var.nil?
59
+ @value = ENV.fetch(var, nil)
60
+ raise(ArgumentError, "The environment variable #{@value.inspect} is not set") if @value.nil?
61
+ end
67
62
 
68
- # Create a new connection to PostgreSQL server.
69
- def connection
70
- uri = URI(@value)
71
- Pgtk::Wire::Direct.new(
72
- host: CGI.unescape(uri.host),
73
- port: uri.port || 5432,
74
- dbname: CGI.unescape(uri.path[1..]),
75
- user: CGI.unescape(uri.userinfo.split(':')[0]),
76
- password: CGI.unescape(uri.userinfo.split(':')[1])
77
- ).connection
63
+ # Create a new connection to PostgreSQL server.
64
+ def connection
65
+ uri = URI(@value)
66
+ Pgtk::Wire::Direct.new(
67
+ host: CGI.unescape(uri.host),
68
+ port: uri.port || 5432,
69
+ dbname: CGI.unescape(uri.path[1..]),
70
+ user: CGI.unescape(uri.userinfo.split(':')[0]),
71
+ password: CGI.unescape(uri.userinfo.split(':')[1])
72
+ ).connection
73
+ end
78
74
  end
79
- end
80
75
 
81
- # Using configuration from YAML file.
82
- # Author:: Yegor Bugayenko (yegor256@gmail.com)
83
- # Copyright:: Copyright (c) 2019-2026 Yegor Bugayenko
84
- # License:: MIT
85
- class Pgtk::Wire::Yaml
86
- # Constructor.
87
- #
88
- # @param [String] file Path to the YAML configuration file
89
- # @param [String] node The root node name in the YAML file containing PostgreSQL configuration
90
- def initialize(file, node = 'pgsql')
91
- raise "The name of the file can't be nil" if file.nil?
92
- @file = file
93
- raise "The name of the node in the YAML file can't be nil" if node.nil?
94
- @node = node
95
- end
76
+ # Using configuration from YAML file.
77
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
78
+ # Copyright:: Copyright (c) 2019-2026 Yegor Bugayenko
79
+ # License:: MIT
80
+ class Yaml
81
+ # Constructor.
82
+ #
83
+ # @param [String] file Path to the YAML configuration file
84
+ # @param [String] node The root node name in the YAML file containing PostgreSQL configuration
85
+ def initialize(file, node = 'pgsql')
86
+ raise(ArgumentError, "The name of the file can't be nil") if file.nil?
87
+ @file = file
88
+ raise(ArgumentError, "The name of the node in the YAML file can't be nil") if node.nil?
89
+ @node = node
90
+ end
96
91
 
97
- # Create a new connection to PostgreSQL server.
98
- def connection
99
- raise "The file #{@file.inspect} not found" unless File.exist?(@file)
100
- cfg = YAML.load_file(@file)
101
- raise "The node '#{@node}' not found in YAML file #{@file.inspect}" unless cfg[@node]
102
- Pgtk::Wire::Direct.new(
103
- host: cfg[@node]['host'],
104
- port: cfg[@node]['port'],
105
- dbname: cfg[@node]['dbname'],
106
- user: cfg[@node]['user'],
107
- password: cfg[@node]['password']
108
- ).connection
92
+ # Create a new connection to PostgreSQL server.
93
+ def connection
94
+ raise(ArgumentError, "The file #{@file.inspect} not found") unless File.exist?(@file)
95
+ cfg = YAML.load_file(@file)
96
+ raise(ArgumentError, "The node '#{@node}' not found in YAML file #{@file.inspect}") unless cfg[@node]
97
+ Pgtk::Wire::Direct.new(
98
+ host: cfg[@node]['host'],
99
+ port: cfg[@node]['port'],
100
+ dbname: cfg[@node]['dbname'],
101
+ user: cfg[@node]['user'],
102
+ password: cfg[@node]['password']
103
+ ).connection
104
+ end
109
105
  end
110
106
  end
data/lib/pgtk.rb CHANGED
@@ -8,5 +8,4 @@
8
8
  # Copyright:: Copyright (c) 2019-2026 Yegor Bugayenko
9
9
  # License:: MIT
10
10
  module Pgtk
11
- # Nothing here.
12
11
  end
data/pgtk.gemspec CHANGED
@@ -9,7 +9,7 @@ lib = File.expand_path('lib', __dir__)
9
9
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
10
10
  require_relative 'lib/pgtk/version'
11
11
  Gem::Specification.new do |s|
12
- s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
12
+ s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to?(:required_rubygems_version=)
13
13
  s.required_ruby_version = '>= 3.2'
14
14
  s.name = 'pgtk'
15
15
  s.version = Pgtk::VERSION
@@ -26,17 +26,17 @@ Gem::Specification.new do |s|
26
26
  s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
27
27
  s.rdoc_options = ['--charset=UTF-8']
28
28
  s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
29
- s.add_dependency 'backtrace', '~>0.4'
30
- s.add_dependency 'concurrent-ruby', '~>1.3'
31
- s.add_dependency 'donce', '~>0.0'
32
- s.add_dependency 'ellipsized', '~>0.3'
33
- s.add_dependency 'joined', '~>0.3'
34
- s.add_dependency 'logger', '~>1.7'
35
- s.add_dependency 'loog', '~>0.6'
36
- s.add_dependency 'pg', '~>1.1'
37
- s.add_dependency 'qbash', '~>0.4'
38
- s.add_dependency 'random-port', '~>0.7'
39
- s.add_dependency 'tago', '~>0.1'
40
- s.add_dependency 'waitutil', '~> 0.2'
29
+ s.add_dependency('backtrace', '~>0.4')
30
+ s.add_dependency('concurrent-ruby', '~>1.3')
31
+ s.add_dependency('donce', '~>0.0')
32
+ s.add_dependency('ellipsized', '~>0.3')
33
+ s.add_dependency('joined', '~>0.3')
34
+ s.add_dependency('logger', '~>1.7')
35
+ s.add_dependency('loog', '~>0.6')
36
+ s.add_dependency('pg', '~>1.1')
37
+ s.add_dependency('qbash', '~>0.4')
38
+ s.add_dependency('random-port', '~>0.7')
39
+ s.add_dependency('tago', '~>0.1')
40
+ s.add_dependency('waitutil', '~> 0.2')
41
41
  s.metadata['rubygems_mfa_required'] = 'true'
42
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pgtk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.30.5
4
+ version: 0.30.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko