Age | Commit message (Collapse) | Author |
|
|
|
Match the style in the rest of the project.
|
|
|
|
|
|
Was getting an exception when trying to start the development server on
a Rails 5.0.1 app:
$ bundle exec rails s
dbshell-rails/lib/dbshell/rails/tasks/dbshell.rake:5:in `<top (required)>': undefined method `desc' for main:Object (NoMethodError)
from .../ruby/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `load'
from .../ruby/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `block in load'
from .../ruby/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
from .../ruby/gems/2.3.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `load'
from dbshell-rails/lib/dbshell/rails.rb:3:in `<top (required)>'
from .../ruby/gems/2.3.0/gems/bundler-1.14.2/lib/bundler/runtime.rb:105:in `require'
from .../ruby/gems/2.3.0/gems/bundler-1.14.2/lib/bundler/runtime.rb:105:in `rescue in block in require'
from .../ruby/gems/2.3.0/gems/bundler-1.14.2/lib/bundler/runtime.rb:82:in `block in require'
from .../ruby/gems/2.3.0/gems/bundler-1.14.2/lib/bundler/runtime.rb:75:in `each'
from .../ruby/gems/2.3.0/gems/bundler-1.14.2/lib/bundler/runtime.rb:75:in `require'
from .../ruby/gems/2.3.0/gems/bundler-1.14.2/lib/bundler.rb:107:in `require'
from rails-app/config/application.rb:7:in `<top (required)>'
from .../ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:88:in `require'
from .../ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:88:in `block in server'
from .../ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:85:in `tap'
from .../ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:85:in `server'
from .../ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from .../ruby/gems/2.3.0/gems/railties-5.0.1/lib/rails/commands.rb:18:in `<top (required)>'
from rails-app/bin/rails:9:in `require'
from rails-app/bin/rails:9:in `<top (required)>'
from .../ruby/gems/2.3.0/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `load'
from .../ruby/gems/2.3.0/gems/spring-2.0.1/lib/spring/client/rails.rb:28:in `call'
from .../ruby/gems/2.3.0/gems/spring-2.0.1/lib/spring/client/command.rb:7:in `call'
from .../ruby/gems/2.3.0/gems/spring-2.0.1/lib/spring/client.rb:30:in `run'
from .../ruby/gems/2.3.0/gems/spring-2.0.1/bin/spring:49:in `<top (required)>'
from .../ruby/gems/2.3.0/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `load'
from .../ruby/gems/2.3.0/gems/spring-2.0.1/lib/spring/binstub.rb:31:in `<top (required)>'
from rails-app/bin/spring:15:in `require'
from rails-app/bin/spring:15:in `<top (required)>'
from bin/rails:3:in `load'
from bin/rails:3:in `<main>'
Looks like Rails is trying to load the task without Rake, and the
interpreter doesn't know what to do with the Rake methods.
Follow the pattern in
https://github.com/paulelliott/fabrication/blob/b470cd817e1973c14e3253cd76606cf934942ca1/lib/fabrication.rb
and guard the load with a check for whether `Rake` is defined.
This makes the server start up and work as expected again.
|
|
Link to the project's GitHub page.
|
|
The RubyGems.org guide
(http://guides.rubygems.org/specification-reference/#license=) specifies
that the `license` field should use "the standard SPDX ID
spdx.org/licenses/ for the license".
|
|
Thanks to the Patterns guide on rubygems.org, I now see that we don't
have to use `__FILE__` at all. Cool!
See:
http://guides.rubygems.org/patterns/#requiring-files-relative-to-each-other
|
|
Follow this package's convention.
|
|
|
|
The Rake task can't be found if the gem isn't included in the Gemfile.
Remove the instructions for installing with the `gem` command because it
isn't going to work using that installation method.
|
|
Include a description and background, usage, and license information.
Installation instructions come from the auto-generated README provided
by Bundler.
|
|
|
|
For consistency with the rest of the application. Leave double quotes on
the ``git ls-files -z`.split("\x0")` line so that the "\x0" gets
interpreted correctly.
|
|
|
|
This has the additional benefit of making it appear in the `rake -T`
output.
|
|
Provide two ways of accessing the task. One saves a character (":") and
is reminiscent of the Django command that this project is inspired by.
The other is more Rails-like and is consistent with the other
`db:`-prefixed Rails Rake tasks.
|
|
Turns out the port actually did need to be a string, contrary to what I
had assumed in e89275bc787ae17bc698ac8cdb8cdaf5ebeb7852. I ended up with
this error when passing a specific port in a real test:
$ bake dbshell
rake aborted!
TypeError: no implicit conversion of Fixnum into String
.../lib/dbshell/client/postgres.rb:8:in `exec'
.../lib/dbshell/client/postgres.rb:8:in `runshell'
.../lib/dbshell/client/database.rb:24:in `runshell'
.../lib/dbshell/rails/tasks/dbshell.rake:6:in `block in <top (required)>'
.../versions/2.3.3/bin/bundle:22:in `load'
.../versions/2.3.3/bin/bundle:22:in `<main>'
Tasks: TOP => dbshell
|
|
PostGIS is, for our purposes, no different from Postgres. Both should
launch `psql`.
|
|
Since we only have a single *.rake file, we can get away with making
this less general. Doing so condenses what was there previously into a
single line and is arguably more explicit.
|
|
I don't think the load call really needs to be inside the module, as
evidenced by
https://github.com/paulelliott/fabrication/blob/b470cd817e1973c14e3253cd76606cf934942ca1/lib/fabrication.rb
|
|
* Create a `.runshell()` method in `DBShell::Client::MySQL`
* Delegate to that class & method from `DBShell::Client::Database`
|
|
Tried this out with MySQL, and got this error since I haven't integrated
it yet. It struck me that "Invalid" doesn't make any sense. Really it's
something that is possible to do but that our gem doesn't support, so we
should be clearer about that fact.
|
|
For now only includes a `.build_command()` method.
Inspired again by:
https://github.com/django/django/blob/66150f7cf61bc09547fa98586790df596eff6d77/django/db/backends/mysql/client.py
although in our case we haven't handled some of the more exotic options.
Eventually we'll probably have to do that.
|
|
To match the 'sqlite3' gem's and the SQLite project's capitalisation
convention.
|
|
Now that we have a `Client` module
(46b019abd520870ab159b60c03c45675f64dd88a), it makes so much more sense
to put this error class inside it.
|
|
Update our class names to reflect the new file structure introduced in
b700c1bef89a67a64f1040fb6bb03c0320eefe91.
Use the
module DBShell
module Client
end
end
syntax intead of `DBShell::Client` so that we don't have to define the
`Client` module in a separate file and require it. Otherwise we'd get an
error:
lib/dbshell/client/sqlite3.rb:1:in `<top (required)>': uninitialized constant DBShell::Client (NameError)
|
|
Change the paths in the code to conform to the new file layout
introduced in b700c1bef89a67a64f1040fb6bb03c0320eefe91.
|
|
Will be modifying the class names in the next commit. Here we change the
file names & locations of the database client files.
The format changes thusly:
<adapter>_client.rb -> client/<adapter>.rb
This organisation feels cleaner to me. Wasn't liking the previous
structure.
|
|
No longer have a use for this information as I've already leveraged in
the database client class implementations.
|
|
Add a method to execute the `psql` command.
|
|
Instead of calling `DBShell::Sqlite3Client` directly, call the wrapper
class that will delegate to `Sqlite3Client`, `PostgresClient`, etc.
depending on the value of `adapter` in the database connection params
passed in.
This allows us to have a single interface that we can call from the Rake
task that can handle any of the database adapters that we support.
|
|
A more generic interface to specific database adapter clients. This
class will act as a frontend to the others.
Calling its `.runshell()` will call the appropriate `.runshell()` for
the adapter provided in `connection_params`.
This way, we have a single entry point to start a database shell from
the Rake `dbshell` task.
|
|
Remove our hard-coded "development" environment and instead get the
current environment dynamically via the `RAILS_ENV` environment
variable. Assume that the current environment is "development" if the
env variable is unset.
|
|
Add `DBShell::Sqlite3.runshell`, which takes database connection
information and starts a SQLite3 shell.
Currently the Rake task just calls the SQLite3 `.runshell` method
directly without any database adapter discrimination and also forces the
development environment. It's nice to see it working. Now, we'll need to
clean up those parts of the Rakefile.
|
|
Much simpler `.build_command` than the Postgres version. Only building
arguments now. Want to try out executing the subprocess command.
Inspired of course by:
https://github.com/django/django/blob/66150f7cf61bc09547fa98586790df596eff6d77/django/db/backends/sqlite3/client.py
|
|
Correctly builds the required arguments. Doesn't handle passwords at
all.
|
|
Match the expected type with the input.
|
|
Forgot to add an `it` block for my test, which resulted in it failing
with a non-obvious error message.
|
|
Make an empty container to pass the basic tests.
|
|
Thinking up an interface for generating command line arguments for the
`psql` command. Based on Django's dbshell:
https://github.com/django/django/blob/66150f7cf61bc09547fa98586790df596eff6d77/tests/dbshell/test_postgresql_psycopg2.py
|
|
Make it easier for us to run our specs.
|
|
Get rid of auto-generated double quotes in the `require` call.
|
|
|
|
Create a stub for our Rake task to see something working.
Inspired by
https://github.com/paulelliott/fabrication/blob/b470cd817e1973c14e3253cd76606cf934942ca1/lib/fabrication.rb
|
|
Use proper capitalisation for our module name.
|
|
Created from:
$ bundle gem dbshell-rails
|