pgcli-rails 0.7.1 → 0.8.1
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 +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/lib/pgcli/rails/monkey_patch.rb +19 -0
- data/lib/pgcli/rails/tasks.rake +9 -3
- data/lib/pgcli/rails/version.rb +1 -1
- metadata +4 -4
- data/lib/pgcli/rails/dbconsole.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a671dffc45960ad4cc3a56875ae180bd28a756ad355a843c163acdb050b94c1
|
4
|
+
data.tar.gz: a2aa4ce68fe349c2613119d184f221c6aa01f1e4f4e44e0b675c45a98a1e4343
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1f68314d0f77dfb6054cd0c455884eed911d83d5d26e16bbead58a3b30208b4a60272ab38889510e5386ab9969f79b9b419d32fddc6391bc188751f83ce6487
|
7
|
+
data.tar.gz: 355d469d77b3e42426bd55589337b7052f9ac467250b58dfaddc22bcc7231719a28bb03a12db7d21541d2e484b84670ac47a9e9004024832262810369fa4b0f3
|
data/LICENSE.txt
CHANGED
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
|
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
|
data/lib/pgcli/rails/tasks.rake
CHANGED
@@ -1,16 +1,22 @@
|
|
1
1
|
desc "Start pgcli using connection info from database.yml"
|
2
2
|
task :pgcli do
|
3
|
-
|
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.
|
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
|
-
|
18
|
+
require "pgcli/rails/monkey_patch"
|
19
|
+
Pgcli::Rails::MonkeyPatch.apply!
|
20
|
+
Rails::DBConsole.new(opt).start
|
15
21
|
console.start
|
16
22
|
end
|
data/lib/pgcli/rails/version.rb
CHANGED
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.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Brictson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-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/
|
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.
|
65
|
+
rubygems_version: 3.5.5
|
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
|