rackdb 0.0.1 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4d345d254f1c2ad27b886c988a50d462a4c9270c
4
- data.tar.gz: 18fbfef83c48dc7f0a7324222487a04a4050c1dd
3
+ metadata.gz: 85abbc78d214e92fed878a662481b862331309e2
4
+ data.tar.gz: 530b4248476a132fb36980655cb5efc3678df949
5
5
  SHA512:
6
- metadata.gz: 475f10e4c91265d9a42c9002160e71cb840a59593ad48fa42657b3c64fe3d1964778574bdef5a2ea3282533faebeec9612e17861c095be54c3a244f85d750d80
7
- data.tar.gz: 1eaec56cd7652b9ae32f55c7d4648089ad05093ab8b84018e8d1fb180802a40847a717ace15b7a06aade5d424c3aa9305e92c8d525049433f05a4ef29eac3333
6
+ metadata.gz: 983755cfed0c92723baae4380791571f2bc1e74aa994aa9349556a69b02d9db9d9fa17ec470acbb2b3d51c2bcdee261882f04d9052e53c4059584636b93ac504
7
+ data.tar.gz: 28db8f413cb0b7b6ad8a7d52a80dac0c1e641493578c88aa274e391c3e6206e49d8f8c7bfb1f2992bbb331f0092d38ad6520290c86c18b487e3bcd424b67adc5
@@ -1,3 +1,15 @@
1
- ## 0.1.0 / 2016-04-14
1
+ ## 0.0.4 (2016-05-03)
2
+
3
+ * 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.
4
+ * Refer to top level constants with a `::` prefix so that error messages in the light of missing dependencies are easier to understand.
5
+ * Require `rack` within the code so that attempts to use the command outside of `bundle exec` stand a greater chance of working correctly anyway.
6
+ * Some code style changes for legibility.
7
+
8
+ ## 0.0.2, 0.0.3 (2016-04-18)
9
+
10
+ * Regenerate `Gemfile.lock` with Bundler 1.11.2 and perform a maintenance update.
11
+ * Ruby 2.1.8 `.ruby_version` file added to source distribution for local development.
12
+
13
+ ## 0.0.1 (2016-04-14)
2
14
 
3
15
  * Initial release, based upon [`racksh`](https://github.com/sickill/racksh) and the Ruby on Rails `dbconsole` [code](https://github.com/rails/rails/blob/master/railties/lib/rails/commands/dbconsole.rb) (as of Railties v4.2.6).
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # `rackdb`
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/rackdb.svg)](https://rubygems.org/gems/rackdb) [![Build Status](https://travis-ci.org/pond/rackdb.svg?branch=master)](https://travis-ci.org/pond/rackdb) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
4
+
3
5
  ## About
4
6
 
5
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/).
data/bin/rackdb CHANGED
@@ -3,7 +3,7 @@
3
3
  require File.expand_path(
4
4
  File.join(
5
5
  File.dirname( __FILE__),
6
- '..', 'lib', 'rackdb', 'init.rb'
6
+ '..', 'lib', 'rackdb', 'console.rb'
7
7
  )
8
8
  )
9
9
 
@@ -2,6 +2,7 @@ require 'erb'
2
2
  require 'yaml'
3
3
  require 'optparse'
4
4
  require 'rbconfig'
5
+ require 'rack'
5
6
  require 'active_record'
6
7
 
7
8
  module Service
@@ -25,7 +26,7 @@ module RackDB
25
26
  exit if options.nil?
26
27
 
27
28
  ENV['RACK_ENV'] = options[:environment] || environment()
28
- Service.config.env = environment()
29
+ ::Service.config.env = environment()
29
30
 
30
31
  case config["adapter"]
31
32
  when /^(jdbc)?mysql/
@@ -104,77 +105,96 @@ module RackDB
104
105
 
105
106
  def config
106
107
  @config ||= begin
107
- if configurations()[environment].blank?
108
+ if configurations()[ environment ].blank?
108
109
  raise ActiveRecord::AdapterNotSpecified, "'#{environment}' database is not configured. Available configuration: #{configurations().inspect}"
109
110
  else
110
- configurations()[environment]
111
+ configurations()[ environment ]
111
112
  end
112
113
  end
113
114
  end
114
115
 
115
116
  def environment
116
- ENV["RACK_ENV"] || "development"
117
+ ENV[ 'RACK_ENV' ] || 'development'
117
118
  end
118
119
 
119
120
  protected
120
121
 
121
122
  def root
122
- if defined?( Application ) && Application.respond_to?( :root )
123
- Application.root # Rails-like
124
- elsif Rack.respond_to?( :root )
125
- Rack.root # Hypothetical
123
+ if defined?( ::Application ) && ::Application.respond_to?( :root )
124
+ ::Application.root # Rails-like
125
+ elsif ::Rack.respond_to?( :root )
126
+ ::Rack.root # Hypothetical
126
127
  elsif defined?( Service ) && Service.respond_to?( :config ) && Service.config.respond_to?( :root ) && Service.config.root != nil
127
- Service.config.root # Hoodoo service
128
+ ::Service.config.root # Hoodoo service
128
129
  else
129
130
  '.'
130
131
  end
131
132
  end
132
133
 
133
134
  def configurations
134
- ActiveRecord::Base.default_timezone = :utc
135
+ ::ActiveRecord::Base.default_timezone = :utc
135
136
 
136
- path = File.join( root(), 'config', 'database.yml' )
137
- erb_yaml_file = File.read( path )
138
- pure_yaml_file = ERB.new( erb_yaml_file ).result
137
+ path = ::File.join( root(), 'config', 'database.yml' )
138
+ erb_yaml_file = ::File.read( path )
139
+ pure_yaml_file = ::ERB.new( erb_yaml_file ).result
139
140
 
140
- ActiveRecord::Base.configurations = YAML.load( pure_yaml_file )
141
- return ActiveRecord::Base.configurations
141
+ ::ActiveRecord::Base.configurations = YAML.load( pure_yaml_file )
142
+ return ::ActiveRecord::Base.configurations
142
143
  end
143
144
 
144
- def parse_arguments(arguments)
145
+ def parse_arguments( arguments )
145
146
  options = {}
146
147
 
147
- OptionParser.new do |opt|
148
- opt.banner = "Usage: rackdb [environment] [options]"
149
- opt.on("-p", "--include-password", "Automatically provide the password from database.yml") do |v|
150
- options['include_password'] = true
148
+ ::OptionParser.new do | opt |
149
+ opt.banner = 'Usage: rackdb [environment] [options]'
150
+
151
+ opt.on(
152
+ '-p',
153
+ '--include-password',
154
+ 'Automatically provide the password from database.yml'
155
+ ) do | v |
156
+ options[ 'include_password' ] = true
151
157
  end
152
158
 
153
- opt.on("--mode [MODE]", ['html', 'list', 'line', 'column'],
154
- "Automatically put the sqlite3 database in the specified mode (html, list, line, column).") do |mode|
155
- options['mode'] = mode
159
+ opt.on(
160
+ '--mode [MODE]', [ 'html', 'list', 'line', 'column' ],
161
+ 'Automatically put the sqlite3 database in the specified mode (html, list, line, column).'
162
+ ) do | mode |
163
+ options[ 'mode' ] = mode
156
164
  end
157
165
 
158
- opt.on("--header", "Turn on sqlite3 database command line header display.") do |h|
159
- options['header'] = h
166
+ opt.on(
167
+ '--header',
168
+ 'Turn on sqlite3 database command line header display.'
169
+ ) do | h |
170
+ options[ 'header' ] = h
160
171
  end
161
172
 
162
- opt.on("-h", "--help", "Show this help message.") do
173
+ opt.on(
174
+ '-h',
175
+ '--help',
176
+ 'Show this help message.'
177
+ ) do
163
178
  puts opt
164
179
  return nil
165
180
  end
166
181
 
167
- opt.on("-e", "--environment=name", String,
168
- "Specifies the environment to run this console under (test/development/production).",
169
- "Default: development"
170
- ) { |v| options[:environment] = v.strip }
182
+ opt.on(
183
+ '-e',
184
+ '--environment=name',
185
+ String,
186
+ 'Specifies the environment to run this console under (e.g. test/development/production).',
187
+ 'Default: development'
188
+ ) do | v |
189
+ options[ :environment ] = v.strip
190
+ end
171
191
 
172
- opt.parse!(arguments)
173
- abort opt.to_s unless (0..1).include?(arguments.size)
192
+ opt.parse!( arguments )
193
+ abort opt.to_s unless ( 0..1 ).include?( arguments.size )
174
194
  end
175
195
 
176
- if arguments.first && arguments.first[0] != '-'
177
- options[:environment] = arguments.first
196
+ if arguments.first && arguments.first[ 0 ] != '-'
197
+ options[ :environment ] = arguments.first
178
198
  end
179
199
 
180
200
  options
@@ -1,3 +1,3 @@
1
1
  module RackDB
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.4'
3
3
  end
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.1
4
+ version: 0.0.4
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-04-14 00:00:00.000000000 Z
11
+ date: 2016-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  version: '0'
115
115
  requirements: []
116
116
  rubyforge_project:
117
- rubygems_version: 2.4.5.1
117
+ rubygems_version: 2.2.5
118
118
  signing_key:
119
119
  specification_version: 4
120
120
  summary: Database console for Rack applications