rackdb 0.0.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +9 -1
- data/lib/rackdb/console.rb +46 -2
- data/lib/rackdb/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d9d5129e23dfb34e48b8086a9d23977a6c870e01
|
4
|
+
data.tar.gz: b8c864d5f8809b12bdea79f720a8c3f632262f92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7b8781b4027d75998f22e415d78448f84627606f5f137b2ca8a871a6c39ff8d6b2954721e5e0382a72a84ee50b2a212328548c55738ac0d89522a621b416bc0
|
7
|
+
data.tar.gz: 2b56363071f3bfd1bc2f8bd0158bf8699a4f44130acae91bae28a297a3dac0212022e066d4a336f7fa2600fbf1535f88b34fb0df1ec304012ff1ea16154a7fa8
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 1.0.0 (2016-05-04)
|
2
|
+
|
3
|
+
* Adds override of `config.yml` via `DATABASE_URL` environment variable; see `README.md` for details.
|
4
|
+
* RCov added to test suite to verify test coverage of lines of code, albeit not all branch conditions. The coverage report makes it easy to see which things are covered and which things aren't (e.g. because they're imported from another code base with assumed coverage there).
|
5
|
+
* Now considered feature-complete to original design goals and stable, so bumping to version 1.0.0.
|
6
|
+
|
1
7
|
## 0.0.4 (2016-05-03)
|
2
8
|
|
3
9
|
* Fix very silly error where local machine via `bundle exec` resolved renamed file `init.rb` successfully but, of course, the clean deployment didn't; it was renamed to `console.rb`. Fixed and added a couple of simple additional tests to cover the executed binary and make sure it wakes up OK.
|
data/README.md
CHANGED
@@ -6,7 +6,15 @@
|
|
6
6
|
|
7
7
|
**rackdb** is a database console for Ruby applications that run on Rack, which follow the Rails-like convention of a `config/database.yml` file describing the database connection parameters. This includes [Rails applications](http://rubyonrails.org) and [Hoodoo services](http://hoodoo.cloud/).
|
8
8
|
|
9
|
-
|
9
|
+
If environment variable `DATABASE_URL` is defined, it will be assumed to contain a fully qualified URI for connecting to the database of choice and will take precedence over `config.yml`. This is often the case for Hoodoo services in cloud-based deployment configurations with remote database services like RDS, rather than under development or in production with a locally hosted database.
|
10
|
+
|
11
|
+
* The URI is parsed and `config.yml`-style parameters are filled in using its components.
|
12
|
+
* PostgreSQL, MySQL and SQL Server URIs are very similar and should all work in theory, conveying the host, port, username, password and database name options where present in the URI. Only PostgreSQL is actually tested against a real database at the time of writing - the others were coded by observation.
|
13
|
+
* SQLite URIs of `sqlite://` are assumed to be for a SQLite v3 database and the pathname of the URI is taken as the path to the database file on the local filesystem.
|
14
|
+
* Oracle URIs are extremely unusual and are not supported.
|
15
|
+
* A `jdbc:` scheme prefix is ignored if present; for example, `jdbc:mysql://...` and `mysql://` would both be treated the same way.
|
16
|
+
|
17
|
+
The code is based upon [`racksh`](https://github.com/sickill/racksh), the Ruby on Rails `dbconsole` [code](https://github.com/rails/rails/blob/master/railties/lib/rails/commands/dbconsole.rb) and the Hoodoo [service shell](https://github.com/LoyaltyNZ/service_shell). For more information, see the Rails documentation for `dbconsole`.
|
10
18
|
|
11
19
|
## Installation
|
12
20
|
|
data/lib/rackdb/console.rb
CHANGED
@@ -105,10 +105,54 @@ module RackDB
|
|
105
105
|
|
106
106
|
def config
|
107
107
|
@config ||= begin
|
108
|
-
if
|
109
|
-
|
108
|
+
if ENV[ 'DATABASE_URL' ]
|
109
|
+
|
110
|
+
# Assumptions: "jdbc:foo://..." style prefixes break the URI parser
|
111
|
+
# and we don't care about JDBC for parsing; strip it. SQLServer URIs
|
112
|
+
# start with "mssql"; 'sqlite' is taken to mean 'sqlite3'; else they
|
113
|
+
# start with something that works as the datapter verbatim.
|
114
|
+
#
|
115
|
+
# All presently known and supported connection URIs have the target
|
116
|
+
# database name as their path - either just one path element in most
|
117
|
+
# cases, or a full path to a file for SQLite.
|
118
|
+
#
|
119
|
+
# Unsupported: Oracle; URI is deeply bizarre. Custom sockets, pools,
|
120
|
+
# timeouts, query parameters etc. are ignored.
|
121
|
+
|
122
|
+
uri_str = ENV[ 'DATABASE_URL' ].gsub( /^jdbc\:/, '' )
|
123
|
+
uri = URI.parse( uri_str )
|
124
|
+
scheme = uri.scheme.downcase
|
125
|
+
adapter = case scheme
|
126
|
+
when 'mssql'
|
127
|
+
'sqlserver'
|
128
|
+
when 'sqlite'
|
129
|
+
'sqlite3'
|
130
|
+
else
|
131
|
+
scheme
|
132
|
+
end
|
133
|
+
|
134
|
+
path = case adapter
|
135
|
+
when 'sqlite3'
|
136
|
+
uri.path
|
137
|
+
else
|
138
|
+
( uri.path || '' ).gsub( /^\/+/, '' ) # Remove any leading '/'s
|
139
|
+
end
|
140
|
+
|
141
|
+
{
|
142
|
+
'adapter' => adapter,
|
143
|
+
'database' => path,
|
144
|
+
'user' => uri.user,
|
145
|
+
'password' => uri.password,
|
146
|
+
'host' => uri.host,
|
147
|
+
'port' => uri.port
|
148
|
+
}
|
149
|
+
|
150
|
+
elsif configurations()[ environment ].blank?
|
151
|
+
raise ActiveRecord::AdapterNotSpecified, "Neither 'DATABASE_URL' nor 'config.yml' entry '#{environment}' are configured. Available configurations: #{configurations().inspect}"
|
152
|
+
|
110
153
|
else
|
111
154
|
configurations()[ environment ]
|
155
|
+
|
112
156
|
end
|
113
157
|
end
|
114
158
|
end
|
data/lib/rackdb/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rackdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Hodgkinson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '3.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov-rcov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.2'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.2'
|
83
97
|
description: Database console for Ruby applications running on Rack with ActiveRecord
|
84
98
|
and following the Rails "config/database.yml" database configuration pattern
|
85
99
|
email: ahodgkin@rowing.org.uk
|