pgcli-rails 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -3
- 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: 3fcf132264e4377997cfe3c761a4f40defd41ec677b20953fe87c012e5c9f87f
|
4
|
+
data.tar.gz: c3b5f858539b5fd498611bc3b1b3cb65cfb39844449cdec8167e82cb3463f196
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcd32ff24c09273cab3a5077bb64238ef5f853ced0fd2e05ae8dea265055ad937665ea7a44d8ef2b678e507a6e88188b69951c495bcd55c14bd1868b76f12843
|
7
|
+
data.tar.gz: 39d38025056b0a972005659a9a547a752aded31ed90032364942208479e6a58e05d90db713ca428407ace9bbfa39169e6a71a94d1526aae10538b441c1ecd254
|
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# pgcli-rails
|
2
2
|
|
3
|
-
[![Gem Version](https://
|
4
|
-
[![
|
3
|
+
[![Gem Version](https://img.shields.io/gem/v/pgcli-rails)](https://rubygems.org/gems/pgcli-rails)
|
4
|
+
[![Gem Downloads](https://img.shields.io/gem/dt/pgcli-rails)](https://www.ruby-toolbox.com/projects/pgcli-rails)
|
5
|
+
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/mattbrictson/pgcli-rails/ci.yml)](https://github.com/mattbrictson/pgcli-rails/actions/workflows/ci.yml)
|
5
6
|
|
6
7
|
[pgcli][] is a command-line interface for PostgreSQL that offers many improvements over `psql`, like auto-completion and syntax highlighting. Wouldn't it be nice to have a convenient way to use `pgcli` with your Rails app?
|
7
8
|
|
@@ -48,7 +49,7 @@ RAILS_ENV=test bin/rake pgcli
|
|
48
49
|
|
49
50
|
## How it works
|
50
51
|
|
51
|
-
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.
|
52
53
|
|
53
54
|
## Configuration
|
54
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.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-
|
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/
|
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.
|
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
|