aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2017-05-09Increase version v0.0.1 -> v0.0.2HEADv0.0.2masterTeddy Wing
2017-05-09version.rb: Use single quotesTeddy Wing
Match the style in the rest of the project.
2017-05-09Add CHANGELOGTeddy Wing
2017-05-09Merge branch 'fix-undefined-method-desc-exception'Teddy Wing
2017-05-09rails.rb: Check that `Rake` is loaded before loading Rake taskTeddy Wing
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.
2017-05-01dbshell-rails.gemspec: Add homepagev0.0.1Teddy Wing
Link to the project's GitHub page.
2017-05-01dbshell-rails.gemspec: Use SPDX ID for licenseTeddy Wing
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".
2017-05-01rails.rb: Simplify `load` call to include Rake taskTeddy Wing
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
2017-05-01rails.rb: Change to single-quotesTeddy Wing
Follow this package's convention.
2017-05-01License under the LGPLv3+Teddy Wing
2017-05-01README: Remove installation instructions using the `gem` commandTeddy Wing
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.
2017-05-01Add READMETeddy Wing
Include a description and background, usage, and license information. Installation instructions come from the auto-generated README provided by Bundler.
2017-05-01dbshell-rails.gemspec: Add long descriptionTeddy Wing
2017-05-01dbshell-rails.gemspec: Use single-quotesTeddy Wing
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.
2017-05-01dbshell-rails.gemspec: Add a short descriptionTeddy Wing
2017-05-01dbshell.rake: Add a short description to our taskTeddy Wing
This has the additional benefit of making it appear in the `rake -T` output.
2017-04-29dbshell.rake: Add alias to `rake db:shell`Teddy Wing
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.
2017-04-29DBShell::Client::Postgres: Convert port to stringTeddy Wing
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
2017-04-29DBShell::Client::Database: Add support for the 'postgis' adapterTeddy Wing
PostGIS is, for our purposes, no different from Postgres. Both should launch `psql`.
2017-04-29rails.rb: Simplify the Rake task loader callTeddy Wing
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.
2017-04-29rails.rb: Move Rake task loader outside of the module contextTeddy Wing
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
2017-04-29Integrate MySQL supportTeddy Wing
* Create a `.runshell()` method in `DBShell::Client::MySQL` * Delegate to that class & method from `DBShell::Client::Database`
2017-04-29Rename `InvalidDatabaseAdapter` to `UnsupportedDatabaseAdapter`Teddy Wing
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.
2017-04-29Add `DBShell::Client::MySQL`Teddy Wing
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.
2017-04-29Rename `Sqlite3` class to `SQLite3`Teddy Wing
To match the 'sqlite3' gem's and the SQLite project's capitalisation convention.
2017-04-29Move `DBShell::InvalidDatabaseAdapter` to the `Client` moduleTeddy Wing
Now that we have a `Client` module (46b019abd520870ab159b60c03c45675f64dd88a), it makes so much more sense to put this error class inside it.
2017-04-29Rename database client classesTeddy Wing
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)
2017-04-29Update `require` paths in database client filesTeddy Wing
Change the paths in the code to conform to the new file layout introduced in b700c1bef89a67a64f1040fb6bb03c0320eefe91.
2017-04-29Rename database client files to put them in a `Client` moduleTeddy Wing
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.
2017-04-29dbshell.rake: Remove unnecessary commentTeddy Wing
No longer have a use for this information as I've already leveraged in the database client class implementations.
2017-04-29DBShell::PostgresClient: Add `.runshell()`Teddy Wing
Add a method to execute the `psql` command.
2017-04-29dbshell.rake: Use `DBShell::DatabaseClient`Teddy Wing
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.
2017-04-29Add `DBShell::DatabaseClient`Teddy Wing
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.
2017-04-29dbshell.rake: Use correct RAILS_ENVTeddy Wing
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.
2017-04-29Get `rake dbshell` working for SQLite3Teddy Wing
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.
2017-04-29Add `DBShell::Sqlite3Client`Teddy Wing
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
2017-04-29PostgresClient: Basic implementation of #build_commandTeddy Wing
Correctly builds the required arguments. Doesn't handle passwords at all.
2017-04-29postgres_client_spec.rb: Use integer port instead of stringTeddy Wing
Match the expected type with the input.
2017-04-29postgres_client_spec.rb: Add missing `it` blockTeddy Wing
Forgot to add an `it` block for my test, which resulted in it failing with a non-obvious error message.
2017-04-29Add `DBShell::PostgresClient` stubTeddy Wing
Make an empty container to pass the basic tests.
2017-04-29Add preliminary test for `DBShell::PostgresClient`Teddy Wing
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
2017-04-29Rakefile: Add TestTaskTeddy Wing
Make it easier for us to run our specs.
2017-04-29Rakefile: Use single quotesTeddy Wing
Get rid of auto-generated double quotes in the `require` call.
2017-04-29dbshell.rake: Figure out how to get database connection info from RailsTeddy Wing
2017-04-29Add a test Rake taskTeddy Wing
Create a stub for our Rake task to see something working. Inspired by https://github.com/paulelliott/fabrication/blob/b470cd817e1973c14e3253cd76606cf934942ca1/lib/fabrication.rb
2017-04-29Change `Dbshell` to `DBShell`Teddy Wing
Use proper capitalisation for our module name.
2017-04-29Generate Ruby Gem contents with BundlerTeddy Wing
Created from: $ bundle gem dbshell-rails