rails-pg-extras 5.4.3 → 5.5.0

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
  SHA256:
3
- metadata.gz: d2613f00de9126d3f00845b6c2c7281081171c802b6d9d4617905d4628a8073f
4
- data.tar.gz: f291d8ec0126a57439f1fbcce1c3d7bfff0b3f18c24fd4586ffdba1e83141b1b
3
+ metadata.gz: 7a02d3f90a286c80e215584b471293e8f2aaaaf33a56c56ca42e938d763b08dd
4
+ data.tar.gz: 6326377418830e39a9105347a61e65837e64c1c80e390faa661a98468d6ad565
5
5
  SHA512:
6
- metadata.gz: 338538334bba07ef85d48d9bd0520c62297841c8ff344a17ec2cd9c04b6262c7365280322f3815a31a2acd5eaa4aba9d69693f676c11ab93e4d7bf2c5a1a1b04
7
- data.tar.gz: 01cd4471d8870a830b8bcd424fead5ab0d33019f69f3fa3d3ad4ed716d4e232deeecf11a1d35a10bb529edb707c30bd6dba0c22563abdaa2dd0f5877f0921d64
6
+ metadata.gz: 4f89bd2d2b48f6cc82d9b0663e8d8a02f317d6aa4cc1052f0b123a126abf4bb5286068f1844b82a78c49b5b3fc835331fe16c7488ebc7ecd3b00bbdfeefcfe62
7
+ data.tar.gz: 33fdf43584ee3b879c2497ff28fe90f6494bbdadb77732692805cd99c25ec569d8ce94ff0839a4a255d92c36a5015df2b2f623cc04a8bd1d86dacd4306a45a09
data/.gitattributes ADDED
@@ -0,0 +1,2 @@
1
+ assets/* linguist-vendored
2
+
data/README.md CHANGED
@@ -135,7 +135,7 @@ You can enable UI using a Rails engine by adding the following code in `config/r
135
135
  mount RailsPgExtras::Web::Engine, at: 'pg_extras'
136
136
  ```
137
137
 
138
- You can enable HTTP basic auth by specifying `RAILS_PG_EXTRAS_USER` and `RAILS_PG_EXTRAS_PASSWORD` variables. Authentication is mandatory unless you specify `RAILS_PG_EXTRAS_PUBLIC_DASHBOARD=true` or setting `RailsPgExtras.configuration.public_dashboard` to `true`.
138
+ You can enable HTTP basic auth by specifying `Rails.application.credentials.pg_extras.user` (or `RAILS_PG_EXTRAS_USER`) and `Rails.application.credentials.pg_extras.user` (or `RAILS_PG_EXTRAS_PASSWORD`) values. Authentication is mandatory unless you specify `RAILS_PG_EXTRAS_PUBLIC_DASHBOARD=true` or set `RailsPgExtras.configuration.public_dashboard = true`.
139
139
 
140
140
  You can configure available web actions in `config/initializers/rails_pg_extras.rb`:
141
141
 
@@ -14,14 +14,27 @@ module RailsPgExtras::Web
14
14
 
15
15
  ACTIONS = %i[kill_all pg_stat_statements_reset add_extensions]
16
16
 
17
- if ENV["RAILS_PG_EXTRAS_USER"].present? && ENV["RAILS_PG_EXTRAS_PASSWORD"].present?
18
- http_basic_authenticate_with name: ENV.fetch("RAILS_PG_EXTRAS_USER"), password: ENV.fetch("RAILS_PG_EXTRAS_PASSWORD")
17
+ user = get_user
18
+ password = get_password
19
+
20
+ if user.present? && password.present?
21
+ http_basic_authenticate_with name: user, password: password
19
22
  end
20
23
 
21
24
  def validate_credentials!
22
- if (ENV["RAILS_PG_EXTRAS_USER"].blank? || ENV["RAILS_PG_EXTRAS_PASSWORD"].blank?) && !RailsPgExtras.configuration.public_dashboard
25
+ if (get_user.blank? || get_password.blank?) && RailsPgExtras.configuration.public_dashboard != true
23
26
  raise "Missing credentials for rails-pg-extras dashboard! If you want to enable public dashboard please set RAILS_PG_EXTRAS_PUBLIC_DASHBOARD=true"
24
27
  end
25
28
  end
29
+
30
+ private
31
+
32
+ def get_user
33
+ Rails.application.try(:credentials).try(:pg_extras).try(:user) || ENV["RAILS_PG_EXTRAS_USER"]
34
+ end
35
+
36
+ def get_password
37
+ Rails.application.try(:credentials).try(:pg_extras).try(:password) || ENV["RAILS_PG_EXTRAS_PASSWORD"]
38
+ end
26
39
  end
27
40
  end
@@ -152,7 +152,15 @@ module RailsPgExtras
152
152
 
153
153
  def self.connection
154
154
  if (db_url = ENV["RAILS_PG_EXTRAS_DATABASE_URL"])
155
- ActiveRecord::Base.establish_connection(db_url).connection
155
+ connector = ActiveRecord::Base.establish_connection(db_url)
156
+
157
+ if connector.respond_to?(:connection)
158
+ connector.connection
159
+ elsif connector.respond_to?(:lease_connection)
160
+ connector.lease_connection
161
+ else
162
+ raise "Unsupported connector: #{connector.class}"
163
+ end
156
164
  else
157
165
  ActiveRecord::Base.connection
158
166
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsPgExtras
4
- VERSION = "5.4.3"
4
+ VERSION = "5.5.0"
5
5
  end
@@ -5,7 +5,7 @@ module RailsPgExtras::Web
5
5
  isolate_namespace RailsPgExtras::Web
6
6
  config.middleware.use ActionDispatch::Flash
7
7
  initializer "static assets" do |app|
8
- app.middleware.insert_before(::ActionDispatch::Static, ::ActionDispatch::Static, "#{RailsPgExtras::Web::Engine.root}/assets")
8
+ app.middleware.insert_before(0, ::ActionDispatch::Static, "#{RailsPgExtras::Web::Engine.root}/assets")
9
9
  end
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-pg-extras
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.4.3
4
+ version: 5.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pawurb
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-21 00:00:00.000000000 Z
11
+ date: 2025-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-pg-extras
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 5.4.3
19
+ version: 5.5.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 5.4.3
26
+ version: 5.5.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rails
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -89,6 +89,7 @@ executables: []
89
89
  extensions: []
90
90
  extra_rdoc_files: []
91
91
  files:
92
+ - ".gitattributes"
92
93
  - ".github/workflows/ci.yml"
93
94
  - ".gitignore"
94
95
  - Gemfile
@@ -148,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
149
  - !ruby/object:Gem::Version
149
150
  version: '0'
150
151
  requirements: []
151
- rubygems_version: 3.5.4
152
+ rubygems_version: 3.5.16
152
153
  signing_key:
153
154
  specification_version: 4
154
155
  summary: Rails PostgreSQL performance database insights