pry-sql 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +12 -0
- data/README.md +36 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/pry-sql/version.rb +3 -0
- data/lib/pry-sql.rb +61 -0
- data/pry-sql.gemspec +19 -0
- metadata +54 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f816183ad1dd149ebd4273c7d901dae77f77825d
|
4
|
+
data.tar.gz: 0b194da2eca61d2fd869e9fb16348d3eb7bca9a0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 91f480558462486ce80e6655c2de03e3236a3c3ba41db0f9e800f29de845005241ac9293111e8304524cb0b388e0b1116baf63de1a2a1cb6e70fc898a39e17d6
|
7
|
+
data.tar.gz: 1fda526b213d4942f692b10946c87c1f91c232b857efafaa3cf34251f52e5ca6d76e370a35f2fdd1ddad5874fb1d2b9e7b9f9173389c2bcedb0143bd1a835c6d
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# pry-sql
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/pry-sql`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'pry-sql'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install pry-sql
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/akuhn/pry-sql.
|
36
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "pry-sql"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/pry-sql.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require "pry-sql/version"
|
2
|
+
|
3
|
+
module PrySQL
|
4
|
+
|
5
|
+
def self.database
|
6
|
+
@database
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.connect(cmd, fname)
|
10
|
+
unless fname == ':memory:' || fname.ends_with?('.sqlite') || File.exist?(fname)
|
11
|
+
cmd.output.puts "Error: file '#{fname}' not found."
|
12
|
+
return
|
13
|
+
end
|
14
|
+
require "sqlite3"
|
15
|
+
@database = SQLite3::Database.new(fname)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.execute(cmd, query)
|
19
|
+
if @database.nil?
|
20
|
+
cmd.output.puts 'Error: Not connected. Use `connect filename` to open database.'
|
21
|
+
return
|
22
|
+
end
|
23
|
+
@database.execute(query)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
Pry::Commands.create_command 'connect' do
|
29
|
+
|
30
|
+
group 'pry-sql'
|
31
|
+
description 'open SQLite database'
|
32
|
+
command_options argument_required: true, requires_gem: ['sqlite3']
|
33
|
+
|
34
|
+
def process(fname)
|
35
|
+
PrySQL::connect(self, fname)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
Pry::Commands.create_command 'query' do
|
40
|
+
|
41
|
+
group 'pry-sql'
|
42
|
+
description 'Execute SQL query'
|
43
|
+
command_options argument_required: true, keep_retval: true, requires_gem: ['sqlite3']
|
44
|
+
|
45
|
+
def process
|
46
|
+
PrySQL::execute(self, arg_string)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
%w(SELECT INSERT UPDATE CREATE).each do |command|
|
51
|
+
Pry::Commands.create_command(command) do
|
52
|
+
|
53
|
+
group 'pry-sql'
|
54
|
+
description "Execute inline #{command.downcase} command."
|
55
|
+
command_options keep_retval: true, requires_gem: ['sqlite3']
|
56
|
+
|
57
|
+
def process
|
58
|
+
PrySQL::execute(self, "#{command_name} #{arg_string}")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/pry-sql.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'pry-sql/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "pry-sql"
|
8
|
+
spec.version = PrySQL::VERSION
|
9
|
+
spec.authors = ["Adrian Kuhn"]
|
10
|
+
spec.email = ["akuhn@iam.unibe.ch"]
|
11
|
+
|
12
|
+
spec.summary = "Execute SQL commands from the pry command line."
|
13
|
+
spec.homepage = "https://github.com/akuhn/pry-sql"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = "exe"
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pry-sql
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Adrian Kuhn
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-26 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
- akuhn@iam.unibe.ch
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".gitignore"
|
21
|
+
- ".rspec"
|
22
|
+
- ".travis.yml"
|
23
|
+
- Gemfile
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- bin/console
|
27
|
+
- bin/setup
|
28
|
+
- lib/pry-sql.rb
|
29
|
+
- lib/pry-sql/version.rb
|
30
|
+
- pry-sql.gemspec
|
31
|
+
homepage: https://github.com/akuhn/pry-sql
|
32
|
+
licenses: []
|
33
|
+
metadata: {}
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
requirements: []
|
49
|
+
rubyforge_project:
|
50
|
+
rubygems_version: 2.4.6
|
51
|
+
signing_key:
|
52
|
+
specification_version: 4
|
53
|
+
summary: Execute SQL commands from the pry command line.
|
54
|
+
test_files: []
|