pgcli-rails 0.7.1 → 0.8.1

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: 7a671dffc45960ad4cc3a56875ae180bd28a756ad355a843c163acdb050b94c1
4
+ data.tar.gz: a2aa4ce68fe349c2613119d184f221c6aa01f1e4f4e44e0b675c45a98a1e4343
5
5
  SHA512:
6
- metadata.gz: 21ef7062757cfc1f8efd4196333e8f001430407ecb514f5181165177c9d3574a83949af5779044b02f6421803a87351f00191aa1ef1345d3e78a292ff0e125e5
7
- data.tar.gz: aa45e43ba98fbd11c110a57cc7751953f9a8081962a3110ad1d2146b72386e1eb51d9afbd286baefb11418c446d69d753294afeb7a7d4b0e21f72cd7a86cf1a1
6
+ metadata.gz: f1f68314d0f77dfb6054cd0c455884eed911d83d5d26e16bbead58a3b30208b4a60272ab38889510e5386ab9969f79b9b419d32fddc6391bc188751f83ce6487
7
+ data.tar.gz: 355d469d77b3e42426bd55589337b7052f9ac467250b58dfaddc22bcc7231719a28bb03a12db7d21541d2e484b84670ac47a9e9004024832262810369fa4b0f3
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2023 Matt Brictson
3
+ Copyright (c) 2024 Matt Brictson
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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.1".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.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: 2023-08-08 00:00:00.000000000 Z
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/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.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