umbrellio-sequel-plugins 0.14.0.192 → 0.15.0.198

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62df42e1d4a608c7a2f6f4d3b33956b0e8d7c962de1f4ba970b5ddb3e858c9df
4
- data.tar.gz: cc6dadf3aaea66e8af9e694996144daee03ca8af13893d8e930fb8b28f20b254
3
+ metadata.gz: b159522b1cb01dea723411ba97da921347c22c98999f23da63df0c1a0a205154
4
+ data.tar.gz: 7bd434016e9d2e5aa93a271e7540f88cee8b2943575739b79a8491a653bcb0c4
5
5
  SHA512:
6
- metadata.gz: '0961d5fce4dd8f7d0aaba3152577c22e097bff92b66cf7b7a716c39693272b020fcfc0fb91f4bca530617559e7cfa4c2ed97cbd7c7807084c0eae458910a6a77'
7
- data.tar.gz: e31c2fc3285cb90b2780d2718f6e854fd8bee2c7d54a9e988df766348ecd3838cb92243c1de210f9b5fc4ff2ef4d3acc53edc5271d8cd66cc65cf5d91547c681
6
+ metadata.gz: e37d16419fd9356d677ee852013947061f3749b3e117fcd7c897b62f2b8dcbd65d0dc4517bde5c87bb781d34780556f899199eaa6dd618d4a2ebc93e1ff56155
7
+ data.tar.gz: 610c27188c8fe14536e143b181455d8a558acd48c7e3b99b6699c61ef26601ea0d264493d50aa75ffc7e38991c225f4e2181eac91c0300b71f56357f4852acb5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- umbrellio-sequel-plugins (0.14.0)
4
+ umbrellio-sequel-plugins (0.15.0)
5
5
  sequel
6
6
  symbiont-ruby
7
7
 
@@ -9,45 +9,86 @@ class Rails::Command::DbconsoleCommand < Rails::Command::Base
9
9
  def perform
10
10
  require "rake"
11
11
  Rake.with_application(&:load_rakefile) # Needed to initialize Rails.application
12
- Rails::DBConsole.start(options)
12
+ start!
13
13
  end
14
- end
15
-
16
- class Rails::DBConsole
17
- DBConfig = Struct.new(:configuration_hash, :adapter, :database)
18
14
 
19
15
  private
20
16
 
21
- def db_config
22
- @db_config ||= DBConfig.new(configuration_hash, adapter, database)
17
+ # See ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.dbconsole
18
+ def start!
19
+ ENV["PGUSER"] = pg_config[:username] if pg_config[:username]
20
+ ENV["PGHOST"] = pg_config[:host] if pg_config[:host]
21
+ ENV["PGPORT"] = pg_config[:port].to_s if pg_config[:port]
22
+
23
+ if pg_config[:password] && options[:include_password]
24
+ ENV["PGPASSWORD"] = pg_config[:password].to_s
25
+ end
26
+
27
+ ENV["PGSSLMODE"] = pg_config[:sslmode].to_s if pg_config[:sslmode]
28
+ ENV["PGSSLCERT"] = pg_config[:sslcert].to_s if pg_config[:sslcert]
29
+ ENV["PGSSLKEY"] = pg_config[:sslkey].to_s if pg_config[:sslkey]
30
+ ENV["PGSSLROOTCERT"] = pg_config[:sslrootcert].to_s if pg_config[:sslrootcert]
31
+
32
+ if pg_config[:variables]
33
+ ENV["PGOPTIONS"] = pg_config[:variables].filter_map do |name, value|
34
+ "-c #{name}=#{value.to_s.gsub(/[ \\]/, '\\\\\0')}" unless value.in?([":default", :default])
35
+ end.join(" ")
36
+ end
37
+
38
+ find_cmd_and_exec("psql", database)
23
39
  end
24
40
 
25
- def configuration_hash
26
- return @configuration_hash if defined?(@configuration_hash)
41
+ def pg_config
42
+ @pg_config ||= begin
43
+ rails_db_config = Rails.application.config.database_configuration
27
44
 
28
- rails_db_config = Rails.application.config.database_configuration
45
+ sequel_configuration = SequelRails::Configuration.new
46
+ SequelRails.configuration = sequel_configuration.merge!(raw: rails_db_config)
29
47
 
30
- sequel_configuration = SequelRails::Configuration.new
31
- SequelRails.configuration = sequel_configuration.merge!(raw: rails_db_config)
48
+ storage = SequelRails::Storage.adapter_for(Rails.env)
49
+ config = storage.config.with_indifferent_access
32
50
 
33
- storage = SequelRails::Storage.adapter_for(Rails.env)
34
- config = storage.config.with_indifferent_access
51
+ if @options[:server]
52
+ server_config = config.fetch(:servers).fetch(@options[:server])
53
+ config.merge!(server_config)
54
+ end
35
55
 
36
- if @options[:server]
37
- server_config = config.fetch(:servers).fetch(@options[:server])
38
- config.merge!(server_config)
56
+ config
39
57
  end
40
-
41
- @configuration_hash = config
42
58
  end
43
59
 
44
- def adapter
45
- mapping = SequelRails::DbConfig::ADAPTER_MAPPING.invert
46
- value = configuration_hash.fetch(:adapter)
47
- mapping[value] || value
60
+ # See ActiveRecord::ConnectionAdapters::AbstractAdapter.find_cmd_and_exec
61
+ def find_cmd_and_exec(commands, *args) # rubocop:disable Metrics/MethodLength
62
+ commands = Array(commands)
63
+
64
+ dirs_on_path = ENV["PATH"].to_s.split(File::PATH_SEPARATOR)
65
+ unless (ext = RbConfig::CONFIG["EXEEXT"]).empty?
66
+ commands = commands.map { |cmd| "#{cmd}#{ext}" }
67
+ end
68
+
69
+ full_path_command = nil
70
+ found = commands.detect do |cmd|
71
+ dirs_on_path.detect do |path|
72
+ full_path_command = File.join(path, cmd)
73
+ begin
74
+ stat = File.stat(full_path_command)
75
+ rescue SystemCallError
76
+ else
77
+ stat.file? && stat.executable?
78
+ end
79
+ end
80
+ end
81
+
82
+ if found
83
+ exec(*[full_path_command, *args].compact)
84
+ else
85
+ abort(
86
+ "Couldn't find database client: #{commands.join(', ')}. Check your $PATH and try again.",
87
+ )
88
+ end
48
89
  end
49
90
 
50
91
  def database
51
- @options[:database] || configuration_hash.fetch(:database)
92
+ options[:database] || pg_config.fetch(:database)
52
93
  end
53
94
  end
@@ -4,7 +4,7 @@ lib = File.expand_path("lib", __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- gem_version = "0.14.0"
7
+ gem_version = "0.15.0"
8
8
 
9
9
  if ENV.fetch("PUBLISH_JOB", nil)
10
10
  release_version = "#{gem_version}.#{ENV.fetch("GITHUB_RUN_NUMBER")}"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: umbrellio-sequel-plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0.192
4
+ version: 0.15.0.198
5
5
  platform: ruby
6
6
  authors:
7
7
  - Team Umbrellio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-15 00:00:00.000000000 Z
11
+ date: 2024-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel