pgcli-rails 0.1.0 → 0.2.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 +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +22 -16
- data/lib/pgcli/rails/dbconsole.rb +15 -0
- data/lib/pgcli/rails/railtie.rb +2 -14
- data/lib/pgcli/rails/tasks.rake +10 -0
- data/lib/pgcli/rails/version.rb +1 -1
- data/pgcli-rails.gemspec +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 678b1aa5df2b4558367b5b91103879f8f78fe071
|
4
|
+
data.tar.gz: 88d8f732d3c86475d8aeceb014734b1e63db773d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1483bc2a3c3dde8baa4449563585d6daabf619508cf5b3bcf776e2f1609d0c8f0e780d534dfc737288ebd99be8b2dfc73f5b8d76c3f0e8d3c58784cc2c0e1930
|
7
|
+
data.tar.gz: 0266878584a16289ea4c489b13f887b1080e489ec2fb484c8b0551e334853101a3e2ebb5be4fd6bd3a0710b51405ef13b6f5a27884592432df952bee984ec5bc
|
data/CHANGELOG.md
CHANGED
@@ -8,8 +8,15 @@ pgcli-rails is in a pre-1.0 state. This means that its APIs and behavior are sub
|
|
8
8
|
|
9
9
|
* Your contribution here!
|
10
10
|
|
11
|
+
## [0.2.0][] (2016-07-18)
|
12
|
+
|
13
|
+
* Rewrite as a Rake task instead of a monkey patch
|
14
|
+
* New usage: `bin/rake pgcli`
|
15
|
+
|
11
16
|
## 0.1.0 (2016-07-15)
|
12
17
|
|
13
18
|
* Initial release
|
14
19
|
|
15
20
|
[Semver]: http://semver.org
|
21
|
+
[Unreleased]: https://github.com/mattbrictson/pgcli-rails/compare/v0.2.0...HEAD
|
22
|
+
[0.2.0]: https://github.com/mattbrictson/pgcli-rails/compare/v0.1.0...v0.2.0
|
data/README.md
CHANGED
@@ -2,16 +2,22 @@
|
|
2
2
|
|
3
3
|
[](http://badge.fury.io/rb/pgcli-rails)
|
4
4
|
|
5
|
-
Wouldn't it be
|
5
|
+
[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?
|
6
|
+
|
7
|
+
That's where the pgcli-rails gem comes in. It adds a `pgcli` Rake task to your Rails app. Use it in place of `rails dbconsole`.
|
8
|
+
|
9
|
+
# Usage
|
10
|
+
|
11
|
+
Add the gem to your Gemfile and run `bundle install`:
|
6
12
|
|
7
13
|
```ruby
|
8
|
-
gem "pgcli-rails"
|
14
|
+
gem "pgcli-rails"
|
9
15
|
```
|
10
16
|
|
11
|
-
|
17
|
+
Running the `pgcli` Rake task automatically uses your `database.yml` to launch pgcli with the correct connection options:
|
12
18
|
|
13
19
|
```
|
14
|
-
$
|
20
|
+
$ bin/rake pgcli
|
15
21
|
Version: 1.0.0
|
16
22
|
Chat: https://gitter.im/dbcli/pgcli
|
17
23
|
Mail: https://groups.google.com/forum/#!forum/pgcli
|
@@ -23,6 +29,16 @@ my_app_development>
|
|
23
29
|
[F2] Smart Completion: ON [F3] Multiline: OFF [F4] Emacs-mode
|
24
30
|
```
|
25
31
|
|
32
|
+
Other ways to use it:
|
33
|
+
|
34
|
+
```
|
35
|
+
# Rails 5 also supports running Rake tasks via the rails command
|
36
|
+
bin/rails pgcli
|
37
|
+
|
38
|
+
# Connect to the test database
|
39
|
+
RAILS_ENV=test bin/rake pgcli
|
40
|
+
```
|
41
|
+
|
26
42
|
## Requirements
|
27
43
|
|
28
44
|
* Rails 4.2+ using PostgreSQL
|
@@ -31,21 +47,11 @@ my_app_development>
|
|
31
47
|
|
32
48
|
## How it works
|
33
49
|
|
34
|
-
pgcli-rails is a
|
50
|
+
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.
|
35
51
|
|
36
52
|
## Configuration
|
37
53
|
|
38
|
-
There is no configuration
|
39
|
-
|
40
|
-
```ruby
|
41
|
-
# Use pgcli in *all* environments (including production)
|
42
|
-
gem "pgcli-rails"
|
43
|
-
```
|
44
|
-
|
45
|
-
```ruby
|
46
|
-
# Use pgcli only in development and test environments
|
47
|
-
gem "pgcli-rails", groups: %w(development test)
|
48
|
-
```
|
54
|
+
There is no configuration. Like `rails dbconsole`, it simply uses your ActiveRecord database connection as specified in `database.yml`.
|
49
55
|
|
50
56
|
## Roadmap
|
51
57
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "rails/commands/dbconsole"
|
2
|
+
|
3
|
+
module Pgcli
|
4
|
+
module Rails
|
5
|
+
# Subclass the built-in Rails DBConsole to override "psql" with "pgcli".
|
6
|
+
class DBConsole < ::Rails::DBConsole
|
7
|
+
protected
|
8
|
+
|
9
|
+
def find_cmd_and_exec(commands, *args)
|
10
|
+
commands = "pgcli" if commands == "psql"
|
11
|
+
super(commands, *args)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/pgcli/rails/railtie.rb
CHANGED
@@ -1,20 +1,8 @@
|
|
1
1
|
module Pgcli
|
2
2
|
module Rails
|
3
3
|
class Railtie < ::Rails::Railtie
|
4
|
-
|
5
|
-
|
6
|
-
# executable that is used for the pg adapter from "psql" to "pgcli".
|
7
|
-
config.before_configuration do
|
8
|
-
require "rails/commands/dbconsole"
|
9
|
-
class ::Rails::DBConsole
|
10
|
-
protected
|
11
|
-
|
12
|
-
alias original_find_cmd_and_exec find_cmd_and_exec
|
13
|
-
def find_cmd_and_exec(commands, *args)
|
14
|
-
commands = "pgcli" if commands == "psql"
|
15
|
-
original_find_cmd_and_exec(commands, *args)
|
16
|
-
end
|
17
|
-
end
|
4
|
+
rake_tasks do
|
5
|
+
load File.expand_path("../tasks.rake", __FILE__)
|
18
6
|
end
|
19
7
|
end
|
20
8
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
desc "Start pgcli using connection info from database.yml"
|
2
|
+
task :pgcli do
|
3
|
+
require "pgcli/rails/dbconsole"
|
4
|
+
|
5
|
+
# APP_PATH constant must be set for DBConsole to work
|
6
|
+
APP_PATH = Rails.root.join("config", "application") unless defined?(APP_PATH)
|
7
|
+
|
8
|
+
console = Pgcli::Rails::DBConsole.new(["--include-password"])
|
9
|
+
console.start
|
10
|
+
end
|
data/lib/pgcli/rails/version.rb
CHANGED
data/pgcli-rails.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.12"
|
24
24
|
spec.add_development_dependency "chandler"
|
25
|
-
spec.add_development_dependency "rake", "~>
|
25
|
+
spec.add_development_dependency "rake", "~> 11.2"
|
26
26
|
spec.add_development_dependency "minitest", "~> 5.0"
|
27
27
|
spec.add_development_dependency "minitest-reporters"
|
28
28
|
spec.add_development_dependency "rubocop", ">= 0.37.2"
|
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.2.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: 2016-07-
|
11
|
+
date: 2016-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '11.2'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '11.2'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: minitest
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,7 +128,9 @@ files:
|
|
128
128
|
- bin/console
|
129
129
|
- bin/setup
|
130
130
|
- lib/pgcli/rails.rb
|
131
|
+
- lib/pgcli/rails/dbconsole.rb
|
131
132
|
- lib/pgcli/rails/railtie.rb
|
133
|
+
- lib/pgcli/rails/tasks.rake
|
132
134
|
- lib/pgcli/rails/version.rb
|
133
135
|
- pgcli-rails.gemspec
|
134
136
|
homepage: https://github.com/mattbrictson/pgcli-rails
|