pgcli-rails 0.7.1 → 0.8.0

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: 481e6d3d0039de496ba0a3d16e13de2dd5929003c3ba74aadd08f5d8af73deb9
4
- data.tar.gz: 17f81831fc141e47800f8688e619e355204785763efc17e97efe4eabc31ee06e
3
+ metadata.gz: 3fcf132264e4377997cfe3c761a4f40defd41ec677b20953fe87c012e5c9f87f
4
+ data.tar.gz: c3b5f858539b5fd498611bc3b1b3cb65cfb39844449cdec8167e82cb3463f196
5
5
  SHA512:
6
- metadata.gz: 21ef7062757cfc1f8efd4196333e8f001430407ecb514f5181165177c9d3574a83949af5779044b02f6421803a87351f00191aa1ef1345d3e78a292ff0e125e5
7
- data.tar.gz: aa45e43ba98fbd11c110a57cc7751953f9a8081962a3110ad1d2146b72386e1eb51d9afbd286baefb11418c446d69d753294afeb7a7d4b0e21f72cd7a86cf1a1
6
+ metadata.gz: dcd32ff24c09273cab3a5077bb64238ef5f853ced0fd2e05ae8dea265055ad937665ea7a44d8ef2b678e507a6e88188b69951c495bcd55c14bd1868b76f12843
7
+ data.tar.gz: 39d38025056b0a972005659a9a547a752aded31ed90032364942208479e6a58e05d90db713ca428407ace9bbfa39169e6a71a94d1526aae10538b441c1ecd254
data/README.md CHANGED
@@ -49,7 +49,7 @@ RAILS_ENV=test bin/rake pgcli
49
49
 
50
50
  ## How it works
51
51
 
52
- pgcli-rails is simply a Rake task that reuses the existing `Rails::DBConsole` command class provided by Rails. It subclasses DBConsole to execute `pgcli` instead of `psql`. All you need to do is require the pgcli-rails gem by placing it in your Gemfile.
52
+ pgcli-rails is simply a Rake task that reuses the existing `Rails::DBConsole` command class provided by Rails. It applies a monkey patch so that `pgcli` is executed instead of `psql`. All you need to do is require the pgcli-rails gem by placing it in your Gemfile.
53
53
 
54
54
  ## Configuration
55
55
 
@@ -0,0 +1,19 @@
1
+ module Pgcli
2
+ module Rails
3
+ module MonkeyPatch
4
+ def self.apply!
5
+ if ::Rails.gem_version >= Gem::Version.new("7.1.0")
6
+ require "active_record/connection_adapters/postgresql_adapter"
7
+ ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.singleton_class.prepend self
8
+ else
9
+ ::Rails::DBConsole.prepend self
10
+ end
11
+ end
12
+
13
+ def find_cmd_and_exec(commands, *args)
14
+ commands = "pgcli" if commands == "psql"
15
+ super(commands, *args)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,16 +1,22 @@
1
1
  desc "Start pgcli using connection info from database.yml"
2
2
  task :pgcli do
3
- require "pgcli/rails/dbconsole"
3
+ begin
4
+ require "rails/commands/dbconsole"
5
+ rescue LoadError
6
+ require "rails/commands/dbconsole/dbconsole_command"
7
+ end
4
8
 
5
9
  # APP_PATH constant must be set for DBConsole to work
6
10
  APP_PATH = Rails.root.join("config", "application") unless defined?(APP_PATH)
7
11
 
8
- opt = if Rails.version >= "5.1"
12
+ opt = if Rails.gem_version >= Gem::Version.new("5.1.0")
9
13
  { "--include-password" => true }
10
14
  else
11
15
  ["--include-password"]
12
16
  end
13
17
 
14
- console = Pgcli::Rails::DBConsole.new(opt)
18
+ require "pgcli/rails/monkey_patch"
19
+ Pgcli::Rails::MonkeyPatch.apply!
20
+ Rails::DBConsole.new(opt).start
15
21
  console.start
16
22
  end
@@ -1,5 +1,5 @@
1
1
  module Pgcli
2
2
  module Rails
3
- VERSION = "0.7.1".freeze
3
+ VERSION = "0.8.0".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pgcli-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Brictson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-08 00:00:00.000000000 Z
11
+ date: 2023-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -34,7 +34,7 @@ files:
34
34
  - LICENSE.txt
35
35
  - README.md
36
36
  - lib/pgcli/rails.rb
37
- - lib/pgcli/rails/dbconsole.rb
37
+ - lib/pgcli/rails/monkey_patch.rb
38
38
  - lib/pgcli/rails/railtie.rb
39
39
  - lib/pgcli/rails/tasks.rake
40
40
  - lib/pgcli/rails/version.rb
@@ -62,7 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
62
  - !ruby/object:Gem::Version
63
63
  version: '0'
64
64
  requirements: []
65
- rubygems_version: 3.4.15
65
+ rubygems_version: 3.4.21
66
66
  signing_key:
67
67
  specification_version: 4
68
68
  summary: Replaces the Rails PostgreSQL dbconsole with the much nicer pgcli
@@ -1,19 +0,0 @@
1
- begin
2
- require "rails/commands/dbconsole"
3
- rescue LoadError
4
- require "rails/commands/dbconsole/dbconsole_command"
5
- end
6
-
7
- module Pgcli
8
- module Rails
9
- # Subclass the built-in Rails DBConsole to override "psql" with "pgcli".
10
- class DBConsole < ::Rails::DBConsole
11
- protected
12
-
13
- def find_cmd_and_exec(commands, *args)
14
- commands = "pgcli" if commands == "psql"
15
- super(commands, *args)
16
- end
17
- end
18
- end
19
- end